Game Development Reference

In-Depth Information

After removing a factor of two, we can write these equations in matrix form as

follows.

(

)

V

2

−⋅

VV

t

Vt

SSV

−⋅

1

1

2

1

2

1

1

=

(5.10)

(

)

2

SSV

−⋅

VV

⋅

−

2

1

1

2

2

2

2

Solving this equation for
t
and
t
gives us

−

1

(

)

t

V

2

−⋅

VV

SSV

−⋅

1

1

1

2

2

1

1

=

2

(

)

t

VV

⋅

−

V

SSV

−⋅

2

1

2

2

2

1

2

2

(

)

−

V

VV

⋅

SSV

−⋅

1

2

1

2

2

1

1

=

.

(5.11)

(

)

2

2

2

(

)

VV

⋅

−

VV

−⋅

VV

V

2

SSV

−⋅

1

2

1

2

1

2

1

2

1

2

Plugging these values of
t
and
t
back into the function
f
gives us the minimum

squared distance between the two lines. Taking a square root gives us the actual

distance that we want. If the direction vectors

V
and

V
have unit length, then

Equation (5.11) simplifies a bit since

V

2

=

1

and

V

2

2

=

1

.

1

(

)

2

2

2

VV
is zero, then the lines are parallel, in which

case the distance between the two lines is equal to the distance between any point

on one of the lines and the other line. This is illustrated in Figure 5.3. In particu-

lar, we can use Equation (5.3) to measure the distance from the point
S
to the

line

If the quantity

⋅

−

VV

1

2

1

2

()

or the distance from the point
S
to the line

()

P

t

P

t

.

22

11

()

P

t

11

S

1

()

P

t

22

Figure 5.3.
The distance between parallel lines is given by the distance from a point on

one line to the other line.

Search Nedrilad ::

Custom Search