Game Development Reference
In-Depth Information
One final way to define a line is as the perpendicular bisector of two
points, to which we assign the variables q and r (see Figure 9.8). This
is actually one of the earliest definitions of a line: the set of all points
equidistant from two given points.
Figure 9.8
Defining a line as the perpendicular bisector of a
line segment
9.2.3
Converting between Representations
Now let's give a few examples of how to convert a ray or line between the
various representation techniques. We will not cover all of the combinations.
Remember that the techniques we learned for infinite lines are applicable
only in 2D.
To convert a ray defined using two points to parametric form:
p 0 = p org ,
d = p end
p org .
The opposite conversion, from parametric form to two-points form, is
p org = p 0 ,
p end = p 0 + d .
Given a parametric ray, we can compute the implicit line that contains
this ray:
a = d y ,
b = −d x ,
d = x org d y
− y org d x .
(9.5)
To convert a line expressed implicitly to slope-intercept form:
m = −a/b,
y 0 = d/b.
(9.6)
Converting a line expressed implicitly to “normal and distance” form:
n =
a b
/
a 2 + b 2 ,
distance = d/
a 2 + b 2 .
 
Search WWH ::




Custom Search