1
votes

I'm having to write my own physics code (if you're curious why, see here). Simulating a single rigid body is pretty simple. But we have assemblies (simulated space colonies) which are composed of multiple rigid bodies, joined by rotating bearings.

A rotating bearing should keep two parts firmly in a constant relative position and spin axis, and allow them to vary only by rotation about that axis.

The primary mechanic for each part is the conservation of angular momentum. This sometimes causes the axis to change pretty dramatically (see here again for an example). But if one end or the other is attached to another object, then that object will either get dragged along or cancel out the axis change (or some combination of both -- depends on their relative mass). It's all further complicated by the fact that the other object may have angular momentum to conserve, too.

I have Physics for Game Developers, but it doesn't cover joints. I've searched the interwebs, but all I've been able to find are articles on using joints in various off-the-shelf physics engines. Can anyone offer advice on how to simulate such a bearing/joint myself?

1
It occurred to me that, due to the particular constraints of this game, I can probably get away with a simple approach: apply conservation of momentum to each part, then find the weighted average axis of rotation of all parts. Then simply set the axis of all parts to that, reconnect all the parts that have gotten separated, and reset the center of mass of the whole system to its original place. ...But other suggestions are still very much appreciated!Joe Strout

1 Answers

0
votes

One standard trick to simplify the computations is to simulate the joint as a rather stiff spring with rest length=length of joint. This allows an asynchronous propagation of moments while keeping the construction of the scene and the physics engine separate.

Standard reference: http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-verlet-based-approach-for-2d-game-physics-r2714

especially the second half where collisions of extended objects are discussed. The idea applies also to forces different from collisions and integration schemes different from Verlet.