Simulating attraction between large objects.

Post Reply
Westend101
Posts: 1
Joined: Sat Nov 24, 2007 5:06 am

Simulating attraction between large objects.

Post by Westend101 » Sat Nov 24, 2007 5:16 am

Hi,

I'm looking to build a basic simulation of a planetary system. Therefore I need to know if Bullet can calculate forces of attraction between large bodies.

I've scanned through the SDK, FAQ, DOCS and this forum but cannot find if Bullet will help me with this.

If it cannot does anyone on this forum have any suggestions of an open source physics library that will? I've written my own but it's not efficient and does not scale well with hundreds of objects.

Best regards,

Pete.

bone
Posts: 235
Joined: Tue Feb 20, 2007 4:56 pm

Re: Simulating attraction between large objects.

Post by bone » Tue Nov 27, 2007 5:11 pm

I doubt there's any native support for calculating this force, but it's easy to add the forces yourself.

Newton's Law of Universal Gravitation:

Force = G * m1 * m2 / r^2

G is the universal gravitational constant (6.67 × 10^?11 N m2 kg?2)
m1 is the mass of the first object (kg)
m2 is the mass of the other object (kg)
r is the distance between the objects (in meters)

AlexSilverman
Posts: 145
Joined: Mon Jul 02, 2007 5:12 pm

Re: Simulating attraction between large objects.

Post by AlexSilverman » Tue Nov 27, 2007 10:10 pm

Hi,

One word of warning when doing something like this. I would recommend changing the value of gravity for the smaller bodies to be affected by the larger body, rather than adding the gravitational force as an external force (ie: body->addForce() ). The reason is that if you use the latter method, it is reliant upon your framerate. I was trying to simulate wind acting on a body, and I until I changed the gravity on the body to be (VEC3(0, -10, 0) + WindSpeed) my results would be inconsistent because my framerate was not constant.

You can easily update this each frame, same as you would need to if you were applying a force, so it shouldn't change your implementation much.

- Alex

Post Reply