Graphics Reference
In-Depth Information
7.7.2 Parametric-Implicit Line Intersection
Now suppose we're given a parametric form for one line and an implicit form for
a second line. How can we compute their intersection? We need to find the value
t 0 of t with the property that
γ
( t 0 )=( 1
t 0 ) P + t 0 Q
(7.80)
is on the line defined by
=
{
X :( X
S )
·
n = 0
}
.
For this to be true, we need that
(
γ
( t 0 )
S )
·
n = 0,
(7.81)
that is
(( 1
t 0 ) P + t 0 Q
S )
·
n = 0.
(7.82)
Once again the vector form becomes useful as we simplify:
( P + t 0 ( Q
P )
S )
·
n = 0, so
(7.83)
( t 0 ( Q
P )+( P
S ))
·
n = 0.
(7.84)
Writing u = Q
P and v = P
S ,wehave
t 0 u
·
n + v
·
n = 0
(7.85)
t 0 u
·
n =
v
·
n
(7.86)
t 0 =
v
·
n
n .
(7.87)
u
·
Plugging this into the formula for
γ
( t 0 ) yields the xy -coordinates of the intersec-
tion point P .
Inline Exercise 7.10: Carry out this final computation to find the coordinates
of P . Try to do all your computations using dot products and vector operations
rather than explicit coordinate computations.
Note that this computation gives us two things. It tells us where along the line
determined by
γ
the intersection lies, by giving us t 0 ;if t 0 is between 0 and 1, for
instance, we know that the intersection lies between P and Q . It also tells us the
actual coordinates of the intersection point ( x 0 , y 0 ) , that is, it provides an explicit
point on the line that's determined implicitly by Ax + By + C = 0. If we only care
about intersections between P and Q , but find t 0 is not between 0 and 1, we can
avoid the second part of the computation.
7.8 Intersections, More Generally
In talking about intersections of lines, we've advocated the use of vectors and
inner products. There are several advantages to this approach.
• Rather than writing out everything two (in two dimensions) or three (in
three dimensions) times, once per coordinate, we write things just once,
reducing the chance of error.
 
 
 
 
Search WWH ::




Custom Search