Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Orbit Location Formulation

Author
Message
A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 15th Feb 2010 19:58 Edited at: 15th Feb 2010 20:02
Hey guys. I am writing a program and I have come to a mathamatical block. What my program is, is a simple thing which allows you to choose one of the planets in our solar system (or more than one) and the orbit of the planet is plotted.

I have set up my program to compensate for the best possible display (if Pluto is not chosen as a planet and perhaps only Mercury is, then the scale resizes itself to give the best possible and most accurate representation of the orbit).

The problem i now have is calculating the X and Y co-ordinates on the orbit to place the little disc of the planet. This is all the information i have on the planets in order to calculate the position of the X and Y. Please if anyone has an answer, could it be in universal formula so i can input any planet.



The reason the dims have a limit of 20 is because you are able to add in your own artificial satiates (max of 11).

I am going to find away of setting up the orbits to the correct speed. My theory is, if i have a max time for each orbit then i can calculate the angle and then use trigonometry to locate the position of the planet. E.G.

All planets increase position by 1 every X loops (depends upon speed). If i have a ratio, for example Earth = 365.25 then as i increase by 1, that increases the angle subtended by X and then trigonometry will give me a method of calculating the co-ordinate.

.CALIBRE - COMING MAY 2010
Alfa x
20
Years of Service
User Offline
Joined: 1st Jul 2006
Location: Colombia
Posted: 15th Feb 2010 20:27
Hi,
you can use sin and cosine to find planets location. x= r*cos(angle)
y= r*sin(angle)

If you a assume a travel time (I dont know planets time, I think they are different for every planet ), you could find where the planet is located.

Altought i'm not sure if planet orbits are circular, I think rather that they are an oval, and in that case a circular formula could prove to be not enought and rather you should need an oval equation to have a better aproximation.
A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 15th Feb 2010 20:40 Edited at: 15th Feb 2010 21:18
I am assuming that they are circular. There is a very small ecliptic effect on the circle. Could you explain in more detail what the inputs are if i havent already understood it. This is what i am getting:

X = Radius * Sin(Days for orbit * 365.25 / 360 * days passed)
Y = Radius * Cos(Days for orbit * 365.25 / 360 * days passed)


Also, to get more technical, the planet travels faster when it is closer to the sun and slower when it is further (moves equal distances over equal areas from point X to point Y).


EDIT The origin or this formula is assuming that the centre of the circle is 0, 0 right?

.CALIBRE - COMING MAY 2010
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 15th Feb 2010 22:45 Edited at: 15th Feb 2010 22:50
Assuming:

Day 0 = an Angle of 0
Center X and Y = 0
Orbit Period = 365.25

Then:

angle = 360 / (OrbitPeriod / Days)

x = sin(angle) * radius + centerx
y = cos(angle) * radius + centery

This is for a circular orbit. If you find out the time it takes for a planet to do a full orbit, then you can plug that number in for the orbit period and have a universal orbit formula.

If you are calculating the position of a moon, set the centerx and centery to the position of the planet the moon is orbiting.

[edit]
Made a minor correction to the formula..

A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 16th Feb 2010 00:22
I worked in the formula before you posted that KISTech But thanks anyway

With I got the orbit time set up like:





The stuff all works fine now guys. Thanks. I am just having some of the planets rotating very slowly while others rotate much too fast. It doesnt look right while one whizzes round and another barely moves... These are some of the things i pulled to show what i mean:

Pluto takes 90779.234375 days to rotate...

And

Mercury only takes 87.6599960327 days to rotate...

.CALIBRE - COMING MAY 2010
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Feb 2010 02:48
you mean revolve, not rotate, assuming you mean mercury takes 87 days to revolve around the sun.


Quote: "All planets increase position by 1 every X loops (depends upon speed)."


1 what? Every planet will need to increment by a different amount to accurately completely one revolution. Otherwise, planets with larger orbits will move faster.

Let's say Earth takes 200 seconds to complete 1 revolution (in the simulation). We'll need to know the length of Earth's orbit. For simplicity, I'll just assume the orbits are circular.

distance_from_sun = 300 (simulation distance)
orbit_length = 2 * 3.14 * distance_from_sun (1884)


So it takes 200 seconds to travel 1884 units in your simulation.

360 / 200 = 1.8

So every 1 second in your simulation, increment the angle by 1.8. After 200 seconds, Earth will have made a complete revolution.

1884 / 200 = 9.42

Earth moves 9.42 units per second, that's how fast it's traveling. If you want planets with a larger orbit to travel at the same speed (thus taking longer to complete their orbits), calculate how much you should increment their angle each second. Earth was 1.8, larger orbits will have a smaller number.

lets say jupiter is 900 units from the sun, giving an orbital length of 5652.

5652 / 9.42 = 600

If it takes 200 seconds for Earth to travel 1884 units, then for Jupiter to travel 5652 units (moving at the same speed) it should take it 600 seconds to complete its revolution around the sun.

360 / 600 = 0.6

So for every second in your simulation, update jupiter's angle by 0.6.




"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 16th Feb 2010 10:45 Edited at: 16th Feb 2010 11:17
I should also explain that all of my measurements in length are in astronomical units and all of the measurements in sidereal period are in years.

By 1, I guess most accurately the variable represents a single day. This is the formula that i derived to operate the entire situation:



Here, OT9 represents one of the possible speeds. If OT9 = 1 then run at 1X speed (there are OT9 = 2 (X2) and OT9 = 3 (X3)). I will explain using the example of Mercury. This is the data i have on Mercury:



The variables read from the data file are:



The variables calculated as a result are:



My theory here is that the angle is the 360 / sidereal period(in days) then this gives you an angle. You can then have a variable to represent the days, which is increased by one per loop. When the variable representing days is equal to or greater than the sidereal period in days the variable resets to 0 (at which point it has completed a single orbit).

The problem is that in comparison some planets will whizz round at a certain speed while others will appear to not move. I am also getting a very strange problem where Pluto goes round incredibly fast while Mercury crawls round. Kepler's law of planetary motion alone proves that this is not the case...

These are the results churned out by my debug. They are the variables in this order:

CalRadius(planetnumber)
CalTime(planetnumber)
PlanetX(planetnumber)
PlanetY(planetnumber)



NB: These values are from Mercury to Pluto.

EDIT - Speed issue resolved. I was dividing by 360, rather then the reverse.

.CALIBRE - COMING MAY 2010
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 16th Feb 2010 15:04
Is it something like this your after
A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 16th Feb 2010 15:25
That looks cool paul. I wish you had of posted sooner. My completed project is attached to this post.

The entire system is in 2D. I am just adding the finishing touch of a custom satellite into the program. I also need to set it up so that if you disable the labels, you also then disable the colour.

.CALIBRE - COMING MAY 2010
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 16th Feb 2010 16:01
Feel free to use any of the data or code in mine,its prety acurate once you allow for the scaling of the planets sizes and distances,the sun had to be scaled by down by 10 times more than every thing else just to be able to show that the planets were actually there and not just names rotating around it.
I was going to add in the moons aswell but because the whole sim works on one day intervals when i added are moon in it just looked like it was stood in the same place all the time.
Best of look finishing yours.
A r e n a s
18
Years of Service
User Offline
Joined: 9th Jun 2008
Location:
Posted: 2nd May 2010 14:08
Thanks for the help again guy. I would just like to say that my marks are in for this project and I recieved 100% on it thanks for all of your help guys, it was really appreciated

Login to post a reply

Server time is: 2026-07-26 12:54:17
Your offset time is: 2026-07-26 12:54:17