Game Development Reference
In-Depth Information
9.2.2 Special 2D Representations of Lines
Now let's look a bit closer at some special ways of describing (infinite) lines.
These methods are applicable only in 2D; in 3D, techniques similar to these
are used to define a plane, as we show in Section 9.5. A 2D ray inherently
has four degrees of freedom (x 0 , y 0 , ∆x, and ∆y), but an infinite line has
only two degrees of freedom.
Most readers are probably familiar with the slope-intercept form, which
is an implicit method for representing an infinite line in 2D:
y = mx + y 0 .
(9.2)
Slope-intercept form
The symbol m is the traditional one
used to denote the slope of the line, ex-
pressed as a ratio of rise over run: for
every rise units that we move up, we
will move run units to the right (see
Figure 9.5). The y-intercept is where
the line crosses the y-axis, and is the
value that we have denoted y 0 in Equa-
tion (9.2). (We're bucking tradition and
not using the traditional variable, b, in
order to avoid some confusion later on.)
Substituting x = 0 clearly shows that
the line crosses the y-axis at y = y 0 .
The slope-intercept makes it easy to
verify that an infinite line does, in fact,
have two degrees of freedom: one degree
for rotation and another for translation. Unfortunately, a vertical line has
infinite slope and cannot be represented in slope-intercept form, since the
implicit form of a vertical line is x = k. (Horizontal lines are no problem,
their slope is zero.)
We can work around this singularity by using the slightly different im-
plicit form
Figure 9.5
The slope and y -intercept of a line
Implicit definition of
infinite line in 2D
ax + by = d.
(9.3)
Most sources use the form ax+by+d = 0. This flips the sign of d compared
to our equations. We will use the form in Equation (9.3) because it has fewer
terms, and we also feel that d has a more intuitive meaning geometrically
in this form.
 
Search WWH ::




Custom Search