best way to simulate solar system?
Dear all,
I''ve been looking making my planets rotate, but I''m not sure what the best way to do it is. From what I''ve read in my physics book, it should be possible to caluate postions based on newtons laws, but every site I''ve seen on the web seems to be using other methods. Could someone tell me whats the best method?
Thanks,
Jesse
www.laeuchli.com/jesse/
just read about that...
(writing this the second time, so forgive if i am not so detailed)
p(t) = position at time t
v(t) = velocity at time t
a(t) = acceleration at time t
p(t+2*deltaT) = p(t) + 2*deltaT* v(t+deltaT)
v(t+deltaT) = v(t-deltaT) + 2*deltaT * a(t)
and you can calculate a(t) using this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=103693
Edit: messed up the url-tag, and too tired to check how it works right... copy and paste it
[edited by - OmniBrain on July 11, 2002 7:24:47 PM]
(writing this the second time, so forgive if i am not so detailed)
p(t) = position at time t
v(t) = velocity at time t
a(t) = acceleration at time t
p(t+2*deltaT) = p(t) + 2*deltaT* v(t+deltaT)
v(t+deltaT) = v(t-deltaT) + 2*deltaT * a(t)
and you can calculate a(t) using this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=103693
Edit: messed up the url-tag, and too tired to check how it works right... copy and paste it

[edited by - OmniBrain on July 11, 2002 7:24:47 PM]
-----The scheduled downtime is omitted cause of technical problems.
Do a search on Kepplar''s Laws... you''ll find plenty on the web... they''ll give you everything you need to get correct timings on the orbits of celestial bodies.
Cheers,
Timkin
Cheers,
Timkin
I wrote a solar system demo when I was using GLUT.. if you want it, it''s very simple, and I would be happy to email it to you..
All I did was tell each of the planets to rotate at the same speed (0.3f y rotation)and since some planets are further out then others, mercury will always travel faster (look-wise) than pluto...
~Dwarf
All I did was tell each of the planets to rotate at the same speed (0.3f y rotation)and since some planets are further out then others, mercury will always travel faster (look-wise) than pluto...
~Dwarf
----------[Development Journal]
July 12, 2002 08:51 AM
Kepler tells you the path directly
for the time dependence you''ll have to integrate
For more than one planet and one sun you need
OmniBrain
Is it possible to mix it?
for the time dependence you''ll have to integrate
For more than one planet and one sun you need
OmniBrain
Is it possible to mix it?
For a simple simulation, you could perhaps use this. Let's suppose you have a coordinate system, the sun is at the origin, and the planets are (thus) moving around the origin in a circular way. This can be described by a parametric function (which outputs both x and y when using only one input; t). Written as mathematical equations, they look like this
Each planet has different values for r and T. a is the distance to the origin (the sun). T is the time it takes for one complete orbit. You could save both constants in 2 arrays, but if you know r, you also know T, and the other way round, by solving
for either r or T. Anyways, you should end up with both values, so you can plug them in into your simulation. Then do something like
x = r * cos(1 / T * t);y = r * sin(1 / T * t);
Each planet has different values for r and T. a is the distance to the origin (the sun). T is the time it takes for one complete orbit. You could save both constants in 2 arrays, but if you know r, you also know T, and the other way round, by solving
(pi * r^2 / T)^2 Mass of sun---------------- = G * ----------- r r^2
for either r or T. Anyways, you should end up with both values, so you can plug them in into your simulation. Then do something like
float r[9] = { ?, ?, .. };float T[9] = { ?, ?, .. };for (int i = 0; i<9; i++) renderPlanetAtXY(r * cos(1 / T * t), r * sin(1 / T * t));<br> </pre> <br><br>Hopefully you can use this.<br><br>Nick </i> <br><br><SPAN CLASS=editedby>[edited by - nickm on July 12, 2002 2:17:06 PM]</SPAN>
A few years ago i implemented a solar sytem like this
trajectory for planets and moons
x = center + radius1 * cos(angle)
y = center + radius2 * sin(angle)
center for a planet can be the sun, if you want ellipsoid trajectory you use different values for the radius1 and radius2.
center for a moon can be another planet
{{{{{{{{{{warning}}}}}}}}}}
note:This is a very simple system not based on the real world physics.
trajectory for planets and moons
x = center + radius1 * cos(angle)
y = center + radius2 * sin(angle)
center for a planet can be the sun, if you want ellipsoid trajectory you use different values for the radius1 and radius2.
center for a moon can be another planet
{{{{{{{{{{warning}}}}}}}}}}
note:This is a very simple system not based on the real world physics.

Virtus junxit, mors non separabit
quote:
Original post by Anonymous Poster
Kepler tells you the path directly
for the time dependence you''ll have to integrate
Keplar''s laws also stipulate the period of rotation for a body at a given radius (or semi-major axis for elliptical orbits). Like Newton, he created more than one law.
Cheers,
Timkin
OminBrain on your other post you said:
for each planet do: direction = normalized(PosStar - PosShip) vShip += deltaTime * direction * 6.672*10^-11 * massStar / (distanceToStar ^ 2)
This is Newtons 3d law right? This looks right, but It looks differnet from the other thing you should me:
p(t) = position at time t
v(t) = velocity at time t
a(t) = acceleration at time t
p(t+2*deltaT) = p(t) + 2*deltaT* v(t+deltaT)
v(t+deltaT) = v(t-deltaT) + 2*deltaT * a(t)
Why too different equatsion?
for each planet do: direction = normalized(PosStar - PosShip) vShip += deltaTime * direction * 6.672*10^-11 * massStar / (distanceToStar ^ 2)
This is Newtons 3d law right? This looks right, but It looks differnet from the other thing you should me:
p(t) = position at time t
v(t) = velocity at time t
a(t) = acceleration at time t
p(t+2*deltaT) = p(t) + 2*deltaT* v(t+deltaT)
v(t+deltaT) = v(t-deltaT) + 2*deltaT * a(t)
Why too different equatsion?
Just in case its useful, I have some planetary mechanics formulas on my oac physics formula sheet:
http://mars.spaceports.com/~sedition/
Its got all the kepplers laws ( i think : ) centripital force and acceleration formulas that are sometimes usefull for the planetary mechanincs. it also has escape velocity, gravitational energy, binding energy etc whcih could be usefull in simulating a solar system.
Wallaba
http://mars.spaceports.com/~sedition/
Its got all the kepplers laws ( i think : ) centripital force and acceleration formulas that are sometimes usefull for the planetary mechanincs. it also has escape velocity, gravitational energy, binding energy etc whcih could be usefull in simulating a solar system.
Wallaba
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement