This might sound like madness but I'm trying to constrain the orientation of two bodies using torque impulses. In theory this could work but I'm having trouble calculating the correct torques.
My approach is to try and find the angular velocities that the bodies would need to correct their current orientation. I think I have it working for rigid constraints so I'll explain how I've done that first:
I find the difference in orientation between the two bodies:
DiffQuat = Quat1 * Inv(Quat2)
I then use this difference to find an angular velocity (I'm not convinced this part if correct):
AngVel = Vec(DiffQuat.x, DiffQuat.y, DiffQuat.z) * 2
AngVel += Body1->AngVel - Body2->AngVel
From this I'm then calculating angular velocities for each body using a ratio I've calculated based on their different inertias. I then apply the torques and things seem to work even if the results are a little loose.
My first question is then: Is what I've done reasonable or madness?
My second question is: How do I extend this approach so the constraint only works when the orientations exceed some limits I want to specify somehow?
p.s. I'm aware there are better ways of implementing constraints however understanding that stuff is a way off for me. Please be gentle
