Looking for formula to calculate postion of celestial bodies

Started by
1 comment, last by TechnoGoth 20 years, 4 months ago
I''m working on game that consist of interplantary combat. Basically you launch attacks at other planets and I need a formula to calculate the postion of the planets. here the information so far. O - Planets Orbital speed R - Planets Rotational speed neither can equal 0, a positive value represent clockwise rotation and negative value represent counter clockwise rotation. For simplisity all planets have the same rotational axis and orbit in the same plane. C - is the speed of light also the games maxium velocity. Now each planet has a distance D which represents the distance between a planet and the current planet. There is also a delay value which represent the time it takes for light to travel from one planet to current which I think is equal to D/C. What I need is a formula to calculate displacement. Displacement - is the diffrence between a planets current postion and it perceived postion by the current planet. Also in the game there are weapons each weapon has a Velocity V which is greater then 0 and <= C. An example usage would be this: Earth is attacking planet Vega which is 2 light minutes away. Earth fires its laser cannon which has V=C. So in order to hit the planet the player has fire the cannon at the location where Vega will be in 2 minutes. They will then have to wait 4 minutes afer firing to see the effect. any help would be greatly appreciated. ----------------------------------------------------- Writer, Programer, Cook, I''m a Jack of all Trades Current Design project Chaos Factor Design Document
Advertisement
To find the laws of planetary motion look up Kepler''s equations. I took astronautics last year and should remember them... but I don''t. To find the planet''s current position you just predict its position for a given time ''t.'' To predict the apparent position to a planet ''x'' light-minutes away you predict its position for a time ''t-x.''
There's several ways to know the position of the planets. I can think of two very quickly:

If you do not care to be extremely accurate, and if you wish to add your own planets other than the ones that already exist, then you can compute the gravitational forces yourself, with accurate speed / masses of the planets / sun, and let the simulation run on its own, as I did with my own simple (DOS) gravity program:
http://www.jasondoucette.com/games.html#Gravity

Or, you can use equations to compute where the planets should be. Ken Silverman did this for his Globe program:
http://advsys.net/ken/download.htm
You will have to download the program and read the readme files to see where he got his information from. This is probably much more accurate than computing gravity yourself, but it means you cannot change the simulation, to add more planets / stars.

Jason Doucette | Matthew Doucette
Programming Windows , 5th Edition by Charles Petzold, Errata Addendum
projects / games | real-time graphics | artificial intelligence | world records | wallpapers / desktops / backgrounds
"Great minds discuss ideas, average minds discuss events, small minds discuss people." - Anna Eleanor Roosevelt, 1884-1962

[edited by - Jason Doucette on November 30, 2003 4:48:43 PM]
Jason Doucette / Xona.comDuality: ZF — Xbox 360 classic arcade shmup featuring Dual Play

This topic is closed to new replies.

Advertisement