Game Development Reference
In-Depth Information
and extract the quaternion t from it using well-known techniques [Shoemake 10].
Once you have that, you compute
e = r t
and
(9.12)
f = s t ,
where r and s are the orientation quaternions of body 1 and 2, respectively.
For the CV joint, the axis of rotation may be different in each body. For that
case, we need two axes or two frames, as before. A full frame helps to define
the zero reference, as for the hinge case. The computations are the same as in
Equation (9.12).
Putting everything together, we can now define the general constraints and
constraint Jacobians in a unified way using three different projection operators P
acting on the relative quaternion q . The meta definition is this:
c ( x )= Pq ,
1
2 P
G (1) =
T ( q ) ,
E
1
2 P
G (2) =
T ( q ) .
G
In turn, the different constraints have the following projection operators:
,
P hinge = x T
P lock =
P
y T
P P
( f )
Q
( e ) ,
(9.13)
P CV = z T
P P
( f )
Q
( e ) .
These projection matrices need to be computed only once, unless we have limits
and drivers, as I explain in the next section.
9.9 Limits and Drivers
The hinge joint leaves one degree of freedom. Good or bad, even this freedom
is sometimes taken away with joint limits, locks, or drivers. Going back to the
definitions in Equations (9.4) and (9.3), we can compute the angle from
θ = 2 atan( q s /q 3 ) .
This is now a scalar function of the vector argument q ,
θ =2 f ( g ( q )) ,