SimpleSi Posted October 15, 2011 Posted October 15, 2011 ..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
SYNACK Posted October 15, 2011 Posted October 15, 2011 (edited) 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-logarithmic-functions/7-graphs-log-semilog.php Edited October 15, 2011 by SYNACK
LisaW Posted October 15, 2011 Posted October 15, 2011 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.
Progeniga Posted October 18, 2011 Posted October 18, 2011 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
SYNACK Posted October 18, 2011 Posted October 18, 2011 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.
SimpleSi Posted October 18, 2011 Author Posted October 18, 2011 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
Progeniga Posted October 18, 2011 Posted October 18, 2011 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now