Orbital simulation - Calculate object position over time in a 2d plane

AI Thread Summary
The discussion focuses on issues with simulating a rocket's orbit in a 2D plane, where the user is experiencing incorrect results in velocity and position calculations. The method outlined involves calculating gravitational force, acceleration, and updating velocity and position iteratively, but the user notes discrepancies in expected orbital velocity. Respondents suggest that the Euler method may be numerically unstable for this simulation and recommend alternative integration methods such as Verlet integration or Runge-Kutta for improved stability. The user is encouraged to explore these methods to achieve more accurate orbital dynamics. The conversation highlights the importance of numerical methods in simulating physical systems accurately.
ryanie
Messages
9
Reaction score
0
Hi

Im busy creating an application to simulation a rocket in orbit. I am having trouble as the results I am getting are incorrect. Could someone please check if I am 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.

Method:
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 I am 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 traveling at round about 7700 m/s should be in a roughly circular orbit and one that has a high eccentricity.

Currently with the results I am 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
 
Physics news on Phys.org
I have recently been really interested in the derivation of Hamiltons Principle. On my research I found that with the term ##m \cdot \frac{d}{dt} (\frac{dr}{dt} \cdot \delta r) = 0## (1) one may derivate ##\delta \int (T - V) dt = 0## (2). The derivation itself I understood quiet good, but what I don't understand is where the equation (1) came from, because in my research it was just given and not derived from anywhere. Does anybody know where (1) comes from or why from it the...
Back
Top