Coding Thread, Need some maths help with my rocket.... in Coding and Web Development; ..simulation
I'm writing a rocket simulator in Scratch and want the rocket to appear to take off and reach orbit ...
-
15th October 2011, 06:09 PM #1 Need some maths help with my rocket....
..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
-
-
IDG Tech News
-
15th October 2011, 06:30 PM #2 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.
-
-
15th October 2011, 07:08 PM #3 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.
-
-
18th October 2011, 10:35 AM #4
- Rep Power
- 0
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
-
-
18th October 2011, 10:49 AM #5 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.
-
-
18th October 2011, 01:36 PM #6 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
-
-
18th October 2011, 02:36 PM #7
- Rep Power
- 0
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
-
SHARE:
Similar Threads
-
By CatherineMay in forum IT News
Replies: 2
Last Post: 26th August 2011, 10:09 AM
-
By Mr_M_Cox in forum Gaming
Replies: 17
Last Post: 21st August 2008, 11:28 AM
-
By darbyshire in forum Networks
Replies: 2
Last Post: 14th May 2008, 10:13 PM
-
By TornUp in forum Networks
Replies: 8
Last Post: 12th May 2008, 10:37 AM
-
Replies: 4
Last Post: 17th March 2008, 04:01 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules