Graphics Reference
In-Depth Information
Step 1:
The matrix whose columns are
q
1
,
q
2
, and
q
3
sends
e
1
to
q
1
,
e
2
to
q
2
,
and
e
3
to
q
3
. Unfortunately, it does not necessarily send
u
to
q
4
; instead, it sends
u
=
e
1
+
e
2
+
e
3
to
q
1
+
q
2
+
q
3
, that is, the sum of the columns. If we scale
up each column by a different factor, the resultant matrix will still send
e
i
to a
multiple of
q
i
for
i
=
1, 2, 3, but it will send
u
to a sum of
multiples
of the
q
's. We
therefore, as a first step, write
q
4
as a linear combination of
q
1
,
q
2
,
q
3
,
q
4
=
α
q
1
+
β
q
2
+
γ
q
3
,
(12.6)
which is exactly the same thing as writing
Q
4
in barycentric coordinates with
respect to
Q
1
,
Q
2
, and
Q
3
. Note that because of the general position assumption,
α
,
β
, and
γ
are all nonzero.
Inline Exercise 12.4:
Explain this last statement.
we build a matrix
2
Q
=
q
1
;
q
2
;
q
3
In terms of code, to find
α
,
β
, and
γ
and let
⎡
⎤
α
β
γ
⎣
⎦
=
Q
−
1
q
4
.
(12.7)
Inline Exercise 12.5:
Explain why the solution to Equation 12.7 is in fact a
solution to Equation 12.6.
Now consider the matrix
A
=[
α
q
1
;
β
q
2
;
γ
q
3
]
.
(12.8)
It's straightforward to verify that it sends
e
i
to a multiple of
q
i
for
i
=
1, 2, 3, and
it sends
u
to the sum of its columns, which is, by Equation 12.7, exactly
q
4
.
Step 2:
Repeating this process, we can find a matrix transformation with
matrix
B
sending
e
1
,
e
2
,
e
3
,
u
to multiples of
p
1
,
p
2
,
p
3
,
p
4
.
Step 3:
The matrix
AB
−
1
then sends the
p
's to multiples of the correspond-
ing
q
's.
Note that in solving this problem we solved a 3
×
3 system of equations and
inverteda3
×
3 matrix—which required far less computation than solving a 13
×
13
system of equations.
Inline Exercise 12.6:
Explain why the matrix
B
=
α
p
1
γ
p
3
, where
β
p
2
α
,
γ
are the barycentric coordinates of
P
4
with respect to
P
1
,
P
2
, and
P
3
,
is invertible. Hint: Write
B
=
PS
, where
S
is diagonal and
P
has
p
1
,
p
2
,
p
3
as columns. Now apply the general-position assumption about the points
P
i
(
i
=
1,
β
,
...
,4
)
.
The 3D portion of the library is completely analogous to the 2D one, except that
rotations are somewhat more complicated. To implement rotation about an arbi-
trary vector, we use Rodrigues' formula; to implement rotation about an arbitrary
2. Recall that semicolons indicate that the items listed are the
columns
of the matrix.