Graphics Reference
In-Depth Information
3.12 The equation of a line segment
The line segment is very important in computer graphics as it is a fundamental building block
for 2D and 3D polygons, and all sorts of surface meshes. In R 2 we need to clip line segments
against rectangular windows; in R 3 we need to clip line segments against a viewing frustum;
and in R 2 and R 3 we need to compute the potential intersection of two line segments.
The parametric form of the straight-line equation is the most practical basis for manipulating
straight-line segments, where the controlling parameter can be used to determine the position
of a point along the segment.
Y
P 1
λ v
P
P 2
p 1
p
p 2
X
Figure 3.32.
With reference to Fig. 3.32, we define a line segment by two points P 1 x 1 y 1 and P 2 x 2 y 2
and their respective position vectors p 1 and p 2 . P x P y P is a point on the line segment with
position vector p .
Let
v
=
p 2
p 1
and
p
=
p 1 +
v
Therefore,
x P =
x 1 +
x 2
x 1
y P =
y 1 +
y 2
y 1
P is between P 1 and P 2 for
0 1.
By changing between 0 and 1, we slide along the line segment.
3.13 The intersection of two straight lines
The need to compute line intersections arises in 2D and 3D clipping, modeling, and animation.
Most of the time we are concerned with line segments, rather than infinite lines, although the
latter are required in illumination calculations, ray casting, and ray tracing. To set the scene, let
us calculate the point of intersection of two straight lines in R 2 .
 
Search WWH ::




Custom Search