Hinge constraint

Hi,

Hopefully this post isn't too long winded:

I am attempting to implement a hinge constraint in 3D, however the revolute joint of Box2D is classified as a hinge because in 2D there is no additional axes of rotation.

The constraint equations I have attempted to use are:

C1 = xa + ra - xb - rb (Revolute joint)
C2 = t1.(thetaA - thetaB) where t1 is orthogonal to the hinge free axis and thetas are the orientations of the bodies
C3 = t2.(thetaA - thetaB) similar to C2

The K matrix JM^-1JT derived is:

Row1:

Ma^-1 + [~ra]TIa^-1[~ra] + Mb^-1 + [~rb]TIb^-1[~rb]
[~ra]TIa^-1t1 + [~rb]TIb^-1t1
[~ra]TIa^-1t2 + [~rb]TIb^-1t2

Row 2:

t1TIa^-1[~ra] + t1TIb^-1[~rb]
t1TIa^-1t1 + t1TIb^-1t1
t1TIa^-1t2 + t1TIb^-1t2

Row 3:

t2TIa^-1[~ra] + t2TIb^-1[~rb]
t2TIa^-1t1 + t2TIb^-1t1
t2TIa^-1t2 + t2TIb^-1t2

Where M is the inverse mass matrix and I is the inverse tensor, T denotes a transpose [~] is a skew symmetric matrix and so on

This is a 5x5 matrix, meaning 5 degrees of freedom have been removed

I have a problem when another body collides with one of the bodies involved in the constraint, the system becomes unstable

Has anyone had a similar problem?

Original thread: https://box2d.org/forum/viewtopic.php?t=9019