Cant you use log(x) or xlog(x) to compress from an exponential series to a linier one? Its been a while so I could be way out.
http://www.intmath.com/exponential-l...og-semilog.php
..simulation
I'm writing a rocket simulator in Scratch and want the rocket to appear to take off and reach orbit but I need some non-linear function to translate the real distances 0 - 1000000 metres to -170 to 50 (these are Scratch Screen units)
I'm looking for a function that will approach a limit on screen of y=50 when real height is 1000000 but if the rocketeer makes a bigger orbit - I need the function to stop the image disappear off the top of screen
My maths mojo has deserted me! help please
Si
Cant you use log(x) or xlog(x) to compress from an exponential series to a linier one? Its been a while so I could be way out.
http://www.intmath.com/exponential-l...og-semilog.php
Last edited by SYNACK; 15th October 2011 at 06:35 PM.
Scratch has the 'if 'control loop and the 'touching x ' sensing item, you can choose 'edge' to make something happen when your rocket reaches the edge. The 'if on edge bounce' motion item is useful in some circumstances too. Hope this helps.
I'm not quite sure what you're getting at... if you want the rocket to reach a height greater than 1,000,000 and have a limit of 50 in Scratch then surely you need to recalculate the steps so the 50 Scratch units matches your yMax
The other easy solution is having a simple: if(rocket.Y > yMax) Then rocket.Y = yMax... that would stop it disappearing, but will also stop moving
Not sure if either are massively helpful suggestions
The other thing you could do is add a scaling component as well so that depending on your viewpoint the vehicle gets smaller as it gets further away etc.
What I'm looking (I think anyway) is some sort of non-linear relationship between "real" height of rocket and Scratch y screen units so that as the rocket gets higher it doesn't appear to move as much on the screen.
I've already got a simpel scaling factor in
here is effort so far (Which isn't too bad)
Scratch | Project | rocket4
Si
How about moving your rocket relative to the distance between where it is and its target height?
I've just done it in flash(actionscript) and it looks like this:
rocket_mc.y -= (rocket_mc.y - yMax)/speed;
speed += accel;
(Bear in mind the coordinate system is upside down in flash which is why there's a - sign)
As (rocket_mc.y - yMax) gets tends towards 0 as the rocket approaches yMax the distance moved will tend towards 0 also.
I put it together in a flash file over lunch too: rocketlaunch
There are currently 1 users browsing this thread. (0 members and 1 guests)