Graphics Programs Reference
In-Depth Information
B
a
c
c
a
C
b
A
θ
b
a
cos
C
b
−
a
cos
C
(a)
(b)
Figure A.1: Law of Cosines.
the three sides of a triangle. Applying the law of cosines to this triangle yields
c
2
=
a
2
+
b
2
−
2
ab
cos
θ.
(A.1)
Applying the dot product to vector
c
yields
c
2
=
c
x
+
c
y
+
c
z
=
c • c
=(
a − b
)
•
(
a − b
)
=
a
•
a
+
b
•
b
−
2(
a
•
b
)
=
a
2
+
b
2
−
2(
a
•
b
)
.
(A.2)
Equating Equations (A.1) and (A.2) yields
a
b
=
ab
cos
θ
.
The triple product (
P
•
Q
)
R
is sometimes useful. It can be represented as
•
(
P
•
Q
)
R
=(
P
x
Q
x
+
P
y
Q
y
+
P
z
Q
z
)(
R
x
,R
y
,R
z
)
=
(
P
x
Q
x
+
P
y
Q
y
+
P
z
Q
z
)
R
x
,
(
P
x
Q
x
+
P
y
Q
y
+
P
z
Q
z
)
R
y
,
(
P
x
Q
x
+
P
y
Q
y
+
P
z
Q
z
)
R
z
⎛
⎞
P
x
R
x
P
y
R
x
P
z
R
x
⎝
⎠
=(
Q
x
,Q
y
,Q
z
)
P
x
R
y
P
y
R
y
P
z
R
y
P
x
R
z
P
y
R
z
P
z
R
z
=
Q
(
PR
)
,
(A.3)
where the notation (
PR
) stands for the 3
×
3 matrix above. (This material is used in
Section 1.4.3.)
The cross product of two vectors (also called the
vector product
) is denoted by
P
×
Q
and is defined as the vector
(
P
2
Q
3
− P
3
Q
2
, −P
1
Q
3
+
P
3
Q
1
,P
1
Q
2
− P
2
Q
1
)
.
(A.4)
It is easy to show that
P
×
Q
is perpendicular to both
P
and
Q
.
Search WWH ::
Custom Search