Graphics Reference
In-Depth Information
Therefore,
1
2
0
=
1 =
1
1
×−
1
1
×
or
=
+
1
2
10
11 =
1
1
1
+
and
x P =
x R +
x a =
2
1
=
1
y P =
y R +
y a =
=
2
1
1
making the intersection point 11, which is correct.
3.14 The point of intersection of two 2D line segments
In Section 3.13 we calculated the intersection point of two infinite 2D lines, and in this section
we exploit this knowledge to detect the potential intersection of two finite 2D line segments.
As the segments are represented by parametric vectors, the value of the parameter is the key to
identifying intersections, non-intersections, and touch conditions.
Y
S 1
b
R 2
P
s 1
a
R 1
S 2
r 2
s
r 1
r
s 2
X
Figure 3.35.
We let the end points of the line segments be defined by R 1 x R1 y R1 , R 2 x R2 y R2 and
S 1 x S1 y S1 , S 2 x S2 y S2 , where P x P y P is the point of intersection. From Fig. 3.35, we see that
a
=
r 2
r 1 and b
=
s 2
s 1
and the line segment equations are
r
=
r 1 +
a and s
=
s 1 +
b
 
Search WWH ::




Custom Search