+ Post New Thread
Results 1 to 7 of 7
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 ...
  1. #1

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,780
    Thank Post
    1,469
    Thanked 591 Times in 443 Posts
    Rep Power
    168

    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

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,991
    Thank Post
    851
    Thanked 2,653 Times in 2,253 Posts
    Blog Entries
    9
    Rep Power
    764
    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.

  3. #3

    Join Date
    Jan 2009
    Location
    Essex
    Posts
    23
    Thank Post
    14
    Thanked 7 Times in 4 Posts
    Rep Power
    27
    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.

  4. #4

    Join Date
    Oct 2010
    Location
    Cambridge
    Posts
    11
    Thank Post
    0
    Thanked 1 Time in 1 Post
    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

  5. #5

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,991
    Thank Post
    851
    Thanked 2,653 Times in 2,253 Posts
    Blog Entries
    9
    Rep Power
    764
    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.

  6. #6

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,780
    Thank Post
    1,469
    Thanked 591 Times in 443 Posts
    Rep Power
    168
    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

  7. #7

    Join Date
    Oct 2010
    Location
    Cambridge
    Posts
    11
    Thank Post
    0
    Thanked 1 Time in 1 Post
    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:
+ Post New Thread

Similar Threads

  1. I need help with my Galaxy S and email!!
    By CatherineMay in forum IT News
    Replies: 2
    Last Post: 26th August 2011, 10:09 AM
  2. Replies: 17
    Last Post: 21st August 2008, 11:28 AM
  3. can someone help with my wireless
    By darbyshire in forum Wireless Networks
    Replies: 2
    Last Post: 14th May 2008, 10:13 PM
  4. HELP WITH MY NEW IP LAYOUT
    By TornUp in forum Wireless Networks
    Replies: 8
    Last Post: 12th May 2008, 10:37 AM
  5. Replies: 4
    Last Post: 17th March 2008, 03: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
  •