Constrain point on rigid body to line or line segment

Please don't post Bullet support questions here, use the above forums instead.
h4tt3n
Posts: 25
Joined: Wed Mar 12, 2008 9:08 am

Constrain point on rigid body to line or line segment

Hello folks,

I am implementing a number of rigid body constraints for a small proof-of-concept 2D game demo, and now I'm working on a constraint that limits a point on one rigid body to only move along a line or line segment mapped onto another rigid body. I have a working prototype, but I'd like to be sure I'm doing everything right.

I've been looking at the really nice tutorials by the author of the dyn4j engine.

Basically, I am applying an impulse that is proportional to the displacement perpendicular to the unit vector of the line. This works fine, however, I am not sure how to calculate the right mass matrix. Since I am only constraining motion along one axis, it should be 1x1 ie. a scalar.

Is this right: M = 1/ma + 1/Ia * ( ra x t )^2 + 1/mb + 1/Ib * ( ( rb + u ) x t )^2

where ma and mb are masses, Ia and Ib are moments of inertia, ra and rb are point vectors, u is unt vector and t tangent vector.

Cheers, Mike