Game Development Reference
In-Depth Information
7.3
3D Polar Space
Polar coordinates can be used in 3D as well as 2D. As you probably have
already guessed, 3D polar coordinates have three values. But is the third
coordinate another linear distance (like r) or is it another angle (like θ)?
Actually, we can choose to do either; there are two different types of 3D
polar coordinates. If we add a linear distance, we have cylindrical co-
ordinates, which are the subject of the next section. If we add another
angle instead, we have spherical coordinates, which are covered in the later
sections. Although cylindrical coordinates are less commonly used than
spherical coordinates, we describe them first because they are easier to
understand.
Section 7.3.1 discusses one kind of 3D polar coordinates, cylindrical
coordinates, and Section 7.3.2 discusses the other kind of 3D polar coordi-
nates, spherical coordinates. Section 7.3.3 presents some alternative polar
coordinate conventions that are often more streamlined for use in video
game code. Section 7.3.4 describes the special types of aliasing that can
occur in spherical coordinate space. Section 7.3.5 shows how to convert
between spherical coordinates and 3D Cartesian coordinates.
7.3.1
Cylindrical Coordinates
To extend Cartesian coordinates into
3D, we start with the 2D system, used
for working in the plane, and add a
third axis perpendicular to this plane.
This is basically how cylindrical coordi-
nates work to extend polar coordinates
into 3D. Let's call the third axis the
z-axis, as we do with Cartesian coor-
dinates. To locate the point described
by the cylindrical coordinates (r,θ,z),
we start by processing r and θ just like
we would for 2D polar coordinates, and
then move “up” or “down” according
to the z coordinate. Figure 7.5 shows
how to locate a point (r,θ,z) by using
cylindrical coordinates.
Conversion between 3D Cartesian
coordinates and cylindrical coordinates
is straightforward. The z coordinate is
the same in either representation, and we convert between (x,y) and (r,θ)
via the 2D techniques from Section 7.1.3.
Figure 7.5
Cylindrical coordinates
 
Search WWH ::




Custom Search