Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random | Template Test |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Talkback

Downloads

Information
[parent] Viewing Message
``Calculating planetary coordinates'' by greame on 2011-01-07 05:39:01
I have a very quick question, and I figured because this is an algorithmic question, perhaps someone would be able to answer this for me here.
I've done a small algorithm in c++ to calculate the coordinates of planets based on the force applied to them, which gives the acceleration, velocity, and finally position (all in components)

I'll explain my issue first and attach my code at the bottom.
I'm not sure if this is an issue or not, but the sun is moving (in meters) quite far away from the origin. I'm aware that the sun is supposed to move a small distance due to the pull of the larger planets, but the coordinates are reaching into the tens of thousands of meters - which does not seem to be logical to me.

The processing for my algorithm is as follows:
-Reset force to 0;
-Get the sum of all forces by F += GM(x[j]-x[i])/r^3
-calculate specific planet's acceleration by the equation a = F/m
-calculate specific planet's velocity by V = Vinitial + a*t
-calculate specific planet's position by X = Xinitial + v*t
-loop

To me, this sounds like this should make sense - and so I figured it was an algorithmic error.

Anyone who's good in physics or algorithm have any idea?

http://www.simplyearplugs.co.uk
[ reply | up ]

Interact
reply

Testing some escape charachters for html category with a generator has an injective cogenerator" now escape ” with "