Game Development Reference
In-Depth Information
the three basic types of linear segments, and also clarify some terminology.
In classical geometry, the following definitions are used:
A line extends infinitely in two directions.
A line segment is a finite portion of a line that has two endpoints.
A ray is “half” of a line that has an origin and extends infinitely in
one direction.
In computer science and computational geometry, there are variations
on these definitions. This topic uses the classical definitions for line and
line segment. However, the definition of “ray” is altered slightly:
A ray is a directed line segment.
So to us, a ray will have an origin and an endpoint. Thus a ray defines a
position, a finite length, and (unless the ray has zero length) a direction.
Since a ray is just a line segment where we have differentiated between the
two ends, and a ray also can be used to define an infinite line, rays are of
fundamental importance in computational geometry and graphics and will
be the focus of this section. A ray can be imagined as the result of sweeping
a point through space over time; rays are everywhere in video games. An
obvious example is the rendering strategy known as raytracing, which uses
eponymous rays representing the paths of photons. For AI, we trace “line
of sight” rays through the environment to detect whether an enemy can
see the player. Many user interface tools use raytracing to determine what
object is under the mouse cursor. Bullets and lasers are always whizzing
through the air in video games, and we need rays to determine what they
hit. Figure 9.2 compares the line, line segment, and ray.
Figure 9.2
Line, line
segment,
and ray
Search WWH ::




Custom Search