Game Development Reference
In-Depth Information
()
P
t
11
() ()
P
t
P
t
11
2 2
()
P
t
22
()
()
Figure 5.2. The distance between skew lines
P
t
and
P
t
is calculated by finding
11
22
()
( )
the parameters t and t minimizing
P
t
P
t
.
11
2 2
where t and t range over all real numbers. Then the squared distance between a
point on the line
()
()
P
t
and a point on the line
P
t
can be written as the fol-
11
22
lowing function of the parameters t and t .
(
)
(
)
(
)
2
(5.6)
f
tt
,
=
P
t
P
t
12
1 1
2 2
()
Expanding the square and substituting the definitions of the functions
P
t
and
11
()
P
t
gives us
22
(
)
()
2
()
2
()
()
ftt
,
=
P
t
+
P
t
2
P
t
P
t
12
11
2 2
11
2 2
(
)
(
)
=+
SV
t
2
+ +
S V
t
2
1
1
1
2
2
2
(
)
2
SS
+
t
VS
+
t
VS
+
t t
VV
1
2
1
1
2
2
2
1
1 2
1
2
2
2
2
2
2
2
=+
S
t Vt
+
2
SV
++
S
t Vt
+
2
S V
1
1
1
1
1
1
2
2
2
2
2
2
(
)
2
SS
+
t
VS
+
t
VS
+
t t
VV .
(5.7)
1
2
1
1
2
2
2
1
1 2
1
2
The minimum value attained by the function f can be found by setting partial
derivatives with respect to t and t equal to zero. This provides us with the
equations
f
2
11
=
2
tV
+
2
SV
2
VS
2
t
VV
=
0
(5.8)
1
1
1
2
2 1
2
1
and
f
2
22
=
2
tV
+
2
SV
2
VS
2
t
VV
=
0
.
(5.9)
2
2
2
1
1 1
2
2