Game Development Reference
In-Depth Information
Q
QS
d
V
S
(
)
proj
V QS
Figure 5.1. The distance d from a point Q to the line
SV is found by calculating the
+
t
length of the perpendicular component of
S with respect to the line.
Q
rem, the squared distance between the point Q and the line can be obtained by
subtracting the square of the projection of
S onto the direction V from the
Q
square of
S . This gives us
Q
2
(
)
2
[
(
)
]
2
d
=− −
QS
proj
QS
QSV
V
(
)
2
−⋅
(
)
2
=− −
QS
V .
(5.3)
2
V
Simplifying a bit and taking the square root gives us the distance d that we
desire:
[
(
)
]
2
QSV
V −⋅
(
)
2
d
=−−
QS
.
(5.4)
2
5.1.2 Distance Between Two Lines
In two dimensions, two lines are either parallel or they intersect at a single point.
In three dimensions, there are more possibilities. Two lines that are not parallel
and do not intersect are called skew . A formula giving the minimum distance be-
tween points on skew lines can be found by using a little calculus.
Suppose that we have two lines, as shown in Figure 5.2, defined by the par-
ametric functions
()
P
t
=+
=+
S
t
V
11
1
11
P
()
t
S
t
,
(5.5)
22
2
22
Search Nedrilad ::




Custom Search