Game Development Reference

In-Depth Information

9.6 A New Take on Quaternion-Based Constraints

The Jacobians of any quaternion-based constraint can be computed using just one

master Jacobian matrix and various projections. This is done using the matrix rep-

resentation described in Section 9.5. Consider two rigid bodies with quaternions

r
,
s

and angular velocities
ω
(1)
and
ω
(2)
, respectively. The definition of the

relative quaternion is
q

∈
H

. The first task is to relate the rate of change of
q
to

the angular velocities
ω
(1)
and
ω
(2)
. The time derivative of
q
is

q
=
r
†
s
+
r
†
s
=(
r
†
r
)
r
†
s
+
r
†
s
(
s
†
s
)

=(
r
†
r
)
q
+
q
(
s
†
s
)
.

∈
H

(9.9)

So now, using the matrix representation of the quaternion product, taking the left

product using

P

(
q
) on the first term and the right product using

Q

(
q
) on the

second, and substituting the identities in Equation (9.7), we have

1

2
P

T
ω
(1)
+
1

T
ω
(2)

q
=

−

(
q
)

P

2
Q

(
q
)

P

(9.10)

1

2
E

(
q
)
T
ω
(1)
+
1

(
q
)
T
ω
(2)
.

=

−

2
G

The only Jacobians you need for all three quaternion constraints defined here are

these. It might seem that we took a very long detour to arrive at Equation (9.10),

which is very simple since we just need matrices

(
q
) and
G
(
q
) in the end.

Looking at the indicators defined above in Equations (9.2), (9.4), and (9.6), the

different Jacobians are simply different projections of the same proto-Jacobian,

namely,

E

1

1

G
(1)

2
P
E
(
q
)
T
,

G
(2)

2
P
G
(
q
)
T
,

lock
=
−

lock
=

1

1

G
(1)

2
P
hinge
E
(
q
)
T
,

G
(2)

2
P
hinge
G
(
q
)
T
,

hinge
=
−

hinge
=

(9.11)

1

1

G
(1)

2
P
CV
E
(
q
)
T
,

G
(2)

2
P
CV
G
(
q
)
T
.

CV
=
−

CV
=

9.7 Why It Works

The dot product representation of the indicators for rotational constraints is as

follows:

⎡

⎤

⎡

⎤

n
(1)

·

u
(2)

0

0

0

⎣

⎦
=

⎣

⎦
,

n
(1)

v
(2)

c
dlock
=

·

u
(1)

·
n
(2)