Page 1 of 1

Gravity Calculations, Attractors, and Game Physics.

Posted: 18.12.2003, 01:00
by Ice
I'm working on a virtual model of gravity in a text based game simulation (MUD game that will have planets and stars), I'm curious about what matmatic formulas are used for proper orbital mechanics, at the very liest, an attractor setup and a system to calculate orbits in this system, also planetary and even galactic drift is an eventual goal. My system would be totally fictional, but I'd also like to be able to generate a galaxy map for Celestia, or Maya (which I am familiar with the file formats at this time, and currently use for output visualization) The desire is to have a static or dynamic snapshot of planets with Celestia to see how the system's working.
I am also considering adding a backup system utility to allow me to test out the addition of new systems on future or current galactic position.
This MUD is a text based one that uses a varient of the Forth programming language to do it's work. Forth concepts of math and sintax are applied to a language set that is specific to the server. 1 1 + equils 2, for example.
- Ice
--------
"Ramble ramble ramble, if only I could code as fast as I ramble." - Ice

static on the airways.

Posted: 23.03.2004, 08:41
by Ice
I feel... cold.
okay, codebase aside, I am just curious about formulas.
I still need to add drift, but simple question, is there a formula for determining how much two bodies would attrack each other... o.O and how insane am I for wondering that.

Posted: 23.03.2004, 09:02
by Kendrix
Yes ! The Universal Attraction Law of Newton :

F = G · m1 · m2 / d^2

where m1 and m2 are the mass of the 2 objects and d the distance between them.

G is the constant of gravitation which is 6.672e-11 (in Nm^2 / Kg^2)

Posted: 04.05.2004, 06:09
by Liquidscript
Something like this?
http://www.celestiaproject.net/forum/viewtopic.php?t=4990

I am working on a simple real time gravity simulation that approximates various orbiting bodies and the forces between them. I'll be happy to help.

Ok, the above equation works correctly if you want to use enormous mass values (which correspond to real world values) but in my simulation i set G == 1 unit to simplify the calculations. This way, the masses are easier to handle as round numbers like 500 or 100 or 10.

Another important equation if you want to make "an attractor setup and a system to calculate orbits in this system" is:

Fc = m v^2 / r, where m is mass, v is velocity, and r is the radius between the bodies.

This way, you can set up two bodies, such as a central star and a smaller planet that orbits it, and create a circular orbit by solving Fg = Fc, where Fg = G m1 m2 / d^2 and Fc = m1 v^2 / r. Solve for the velocity to get:

v = (+ or -) sqrt(G m2 / r) because d = r, so they cancel a bit.

This velocity is the velocity of the smaller mass for a circular orbit. It can be used to make circular orbits between 2 bodies. This can be used to create individual stable orbits in a solar system of your design.

Posted: 04.05.2004, 18:25
by tony873004
Ice... Are you Seth from Orbiter? I can help you with the formulas.