Game Development Reference
In-Depth Information
Figure 24- A line in 2D space.
A single line will at a minimum have 2 points, in the context of rendering, if we want to
drawtwoormorecontinuouslineswecanachieveitbyaddingsuccessivepoints,eachnew
point generates a new line, this is known as a line strip.
While lines are often represented with the slope-intercept form:
This form cannot represent vertical lines, a vertical line's slope is undefined. It is far more
useful for our needs to represent lines using the parametric line equation.
Where p is the starting point of the line, and v the direction vector of the line, finally, t is
the parameter it defines how far along the vector v the line will go.
Point to Line Distance
If we happen to find ourselves in a situation in which we have a line, this line could have
manypossiblemeanings,itcouldbetherepresentationofsomeworldboundary,itcouldbe
a simplification of the game world's geometry, it could represent the finish line in a racing
game, whatever the case, we may want to calculate the distance of a point to the line, this
distance can be useful information for the player that we may wish to present, perhaps the
player is equipped with a proximity sensor and any time he gets near any two points, we
display a warning by projecting some UI over the line.
We start from the parametric equation of the line, which as we saw is given by:
Search WWH ::




Custom Search