Graphics Reference
In-Depth Information
Therefore, using (10.38),
x (
1)
y (1)
(0
×−
1
1
×
1) = 0
x
y + 1 = 0
(10.40)
which is the general equation for the line. We now convert it to the Hessian
normal form:
y +1
1 2 +(
x
=
x
y +1
2
=0
1) 2
x
2
y
2 +
1
2 = 0
(10.41)
The choice of sign in the denominator anticipates the two directions for the
normal vector, and the sign of d .
10.3 Intersection Points
10.3.1 Intersection Point of Two Straight Lines
Given two line equations of the form
a 1 x + b 1 y + c 1 =0
a 2 x + b 2 y + c 2 = 0
(10.42)
the intersection point ( x i ,y i )isgivenby
b 1 c 2
b 2 c 1
and y i = c 1 a 2
c 2 a 1
x i =
(10.43)
a 1 b 2
a 2 b 1
a 1 b 2
a 2 b 1
If the denominator is zero, the equations are linearly dependent, indicating
that there is no intersection.
10.3.2 Intersection Point of Two Line Segments
We are often concerned with line segments in computer graphics as they rep-
resent the edges of shapes and objects. So let's investigate how to compute
the intersection of two 2D-line segments.
Figure 10.21 shows two line segments defined by their end-points ( P 1
P 2 )
and ( P 3
P 4 ). If we locate position vectors at these points, we can write the
following vector equations to identify the point of intersection:
P i = P 1 + t ( P 2
P 1 )
P i = P 3 + s ( P 4
P 3 )
(10.44)
where parameters s and t vary between 0 and 1. For the point of intersection,
we can write
P 1 + t ( P 2
P 1 )= P 3 + s ( P 4
P 3 )
(10.45)
Search WWH ::




Custom Search