|Register to reply||
Orbital simulation - Calculate object position over time in a 2d plane
|Share this thread:|
Apr9-14, 04:20 PM
Im busy creating an application to simulation a rocket in orbit. Im having trouble as the results im getting are incorrect. Could someone please check if im using the correct method as stated below.
Everything works on a 2d plane, and has a x and y coordinate and a x and y velocity and a mass
coordinates are in meters and the mass is in kg.
Calculate the distance between the rocket and the planet using the distance formula
distance = sqrt[ ( x2 - x1)^2 - (y2 - y1)^2 ]
calculate the force earth exerts on the rocket using the The Universal Law of Gravitation where G is the Gravitational constant m is the mass of an object and r is the distance between them
force = (G*m1*m2) / distance^2
Using the inverse of tan get the angle to calculate the the x and y components ( I know for a fact im getting this is correct, its a bit tricky to explain) I calculate the angle for each quadrant going from the x axis to the y axis
Calculate the acceleration of the rocket
acceleration = force / mass
Calculate velocity change over timer ( this is usually 0.01 seconds )
deltaVelocity = acceleration * time
Calculate the x velocity component
deltaXvelocity = deltaVelocity * cos(angle)
Calculate the y velocity component
deltaYvelocity = deltaVelocity * sin(angle)
Calculate the new x velocity
newXvelocity = currentXvelocity + deltaXvelocity
Calculate the new y velocity
newYvelocity = currentYvelocity + deltaYvelocity
set the new position of the rocket
newXposition = currentXposition + ( newXvelocity * time )
newYposition = currentYposition + ( newYvelocity * time )
Something is wrong with this method and i do know what.
I know for a fact that a an object in orbit round about 420km travelling at round about 7700 m/s should be in a roughly circular orbit and one that has a high eccentricity.
Currently with the results im getting to obtain a roughly circular orbit at 420km i need to have a velocity of round about 5500m/s
Thanks for taking the time
Apr9-14, 04:25 PM
It sounds like you are using the Euler method, which is numerically unstable.
You should try Verlet integration https://en.wikipedia.org/wiki/Verlet_integration
or a Runge-Kutta method https://en.wikipedia.org/wiki/Runge%...93Kutta_method
both of which have better stability properties.
Or try https://en.wikipedia.org/wiki/Leapfrog_method which is almost as simple as the Euler method.
This page has a decent description of why Euler method fails. https://en.wikipedia.org/wiki/Euler_integration
|Register to reply|
|Calculate the z position of the particle as a function of time.||Introductory Physics Homework||1|
|Three-Body orbital simulation reference plane||Astronomy & Astrophysics||4|
|Position time graph of object moving in a straight line||Engineering, Comp Sci, & Technology Homework||1|
|Position of an object after a certain amount of time?||Introductory Physics Homework||9|
|Position of an object in time and force||Introductory Physics Homework||5|