Pages: [1]



Author

Topic: The Leyland Maneuver, does it actually exist? (Read 2067 times)

Angelfish
Enlightened
Offline
Posts: 568

I'm no genius in physics, but when trying to implement gravity wells into my code, the resulting gravity well doesn't actually generate a Gravity Whip effect when I move the ship past it. When approaching the planet the ship accellerates towards the planet. (I increase the x and y velocities by a value based on the angle and distance to the planet, aswell as the mass of the planet itself.) But when it moves away from the planet it decelerates in the same way so that the effect is neutralized.
So, either my physics coding is wrong, or gravity whips can't actually be performed in real life . If the latter is the case, I'll decrease the gravity effect when the ship moves away from the planet by a certain factor.
Any advice is welcome


« Last Edit: July 18, 2009, 07:10:11 pm by Angelfish »

Logged




jschmerge
Zebranky food
Offline
Posts: 7

Umm, your math is wrong. What you are mistaking for an increase in velocity should actually be a *change* in acceleration (acceleration is a vector, just like veloscity). I'm not going to get too much into the math here (any good calculus or physics text book will have several sections on modeling newtonian dynamics), but simply put you need two equations:
1.) Force of gravity exerted by the planet. This is proportional to the square of the distance from the planet, or F(d) = C/d^2 (where C is a constant, larger values for larger masses).
2.) An equation for the velocity of the ship. This is expressed as a sum of three terms: current velocity, current acceleration (i.e. caused by the ship's thrust), and acceleration base on gravity. All three of these terms are expressed as separate vectors, and when added together produce the resulting velocity. So the equation for velocity, as expressed as an absolute function of time would look something like: V(t) = v' + a * t + F(d) * t , where v' is the current velocity, and F(d) is the vector of acceleration *towards* the planetary mass.
That equation doesn't work well for rendering graphics though... What you *really* want is an equation that can give you the current position and velocity based on (last position, last known velocity, current acceleration, and time delta). This works extremely well when running through an event loop that renders the graphics. I'll leave it up to you to figure out the math. If you like, I'll supply more information, but I think you need to figure this out for yourself



Logged





jschmerge
Zebranky food
Offline
Posts: 7

I'm not sure what a whether phenomenon has to do with modeling Newtonian bodies
You'll seriously get the gravity whip with just the math I presented.



Logged





Angelfish
Enlightened
Offline
Posts: 568

Umm, your math is wrong. What you are mistaking for an increase in velocity should actually be a *change* in acceleration (acceleration is a vector, just like veloscity). I'm not going to get too much into the math here (any good calculus or physics text book will have several sections on modeling newtonian dynamics), but simply put you need two equations: 1.) Force of gravity exerted by the planet. This is proportional to the square of the distance from the planet, or F(d) = C/d^2 (where C is a constant, larger values for larger masses). 2.) An equation for the velocity of the ship. This is expressed as a sum of three terms: current velocity, current acceleration (i.e. caused by the ship's thrust), and acceleration base on gravity. All three of these terms are expressed as separate vectors, and when added together produce the resulting velocity. So the equation for velocity, as expressed as an absolute function of time would look something like: V(t) = v' + a * t + F(d) * t , where v' is the current velocity, and F(d) is the vector of acceleration *towards* the planetary mass. That equation doesn't work well for rendering graphics though... What you *really* want is an equation that can give you the current position and velocity based on (last position, last known velocity, current acceleration, and time delta). This works extremely well when running through an event loop that renders the graphics. I'll leave it up to you to figure out the math. If you like, I'll supply more information, but I think you need to figure this out for yourself Actually, I think you misunderstood the way I did things. I do have gravity and acceleration vectors which result in the current velocity vector . When using not the distance, but the square of the distance in the force of gravity calculation, my gravity well is working perfectly. Although I have to say that it's more difficult to use it than it is in SC2 (it takes more precisio).


« Last Edit: July 18, 2009, 07:55:35 pm by Angelfish »

Logged




Mormont
*Smell* controller
Offline
Posts: 253
I love YaBB 1G  SP1!

Yes something similar does exist, and NASA uses it sometimes (such as the Voyager missions). The SC2 version is a huge simplification of course.



Logged





Angelfish
Enlightened
Offline
Posts: 568

Thanks for all the help, guys . I'm still trying to figure out how to make my gravity wells behave the same way as in SC2 though, but I think that's just a matter of tweaking etc .



Logged





Pages: [1]




