Game Development Reference
In-Depth Information
to be concise he could abbreviate the “East 2nd Street” to “2” and the
“North 4th Street” to “4” and say to his lady love, somewhat cryptically,
“Meet you at (2,4).”
The ordered pair (2,4) is an example of what are called Cartesian coor-
dinates. In 2D, two numbers are used to specify a location. (The fact that
we use two numbers to describe the location of a point is the reason it's
called two-dimensional space. In 3D, we will use three numbers.) The first
coordinate (the 2 in our example (2,4)) is called the x-coordinate, and the
second coordinate (the 4 in our example (2,4)) is called the y-coordinate.
Analogous to the street names in
Cartesia, each of the two coordinates
specifies which side of the origin the
point is on and how far away the point is
from the origin in that direction. More
precisely, each coordinate is the signed
distance (that is, positive in one direc-
tion and negative in the other) to one
of the axes, measured along a line par-
allel to the other axis. Essentially, we
use positive coordinates for east and
north streets and negative coordinates
for south and west streets. As shown
in Figure 1.8, the x-coordinate desig-
nates the signed distance from the point
to the y-axis, measured along a line
parallel to the x-axis. Likewise, the
y-coordinate designates the signed dis-
tance from the point to the x-axis, measured along a line parallel to the
y-axis.
Figure 1.9 shows several points and their Cartesian coordinates. Notice
that the points to the left of the y-axis have negative x values, and those to
the right of the y-axis have positive x values. Likewise, points with positive
y are located above the x-axis, and points with negative y are below the
x-axis. Also notice that any point can be specified, not just the points at
grid line intersections. You should study this figure until you are sure that
you understand the pattern.
Let's take a closer look at the grid lines usually shown in a diagram.
Notice that a vertical grid line is composed of points that all have the same
x-coordinate. In other words, a vertical grid line (actually any vertical
line) marks a line of constant x. Likewise, a horizontal grid line marks a
line of constant y; all the points on that line have the same y coordinate.
We'll come back to this idea in a bit when we discuss polar coordinate
spaces.
Figure 1.8
How to locate a point using 2D Cartesian
coordinates
Search WWH ::




Custom Search