You are on page 1of 101

FUNCTIONS AND PLANES,

CYLINDRICAL, SPHERICAL AND POLAR


COORDINATES
COORDINATES
SYSTEMS 2-2
RECTANGULAR COORDINATE
SYSTEM

2-3
DIFFERENTIAL VOLUME
ELEMENT
VECTOR EXPRESSIONS IN
RECTANGULAR COORDINATES

General Vector, B:

Magnitude of B:

Unit Vector in the


Direction of B:
CYLINDRICAL COORDINATE
SYSTEMS
CYLINDRICAL COORDINATE
SYSTEMS

2-7
CYLINDRICAL COORDINATE
SYSTEMS
EXAMPLE:

2-8
CYLINDRICAL COORDINATE
SYSTEMS

1-9
DIFFERENTIAL VOLUME IN
CYLINDRICAL COORDINATES

2-10
dV = dddz
POINT TRANSFORMATIONS IN
CYLINDRICAL COORDINATES
THE RELATIONSHIP BETWEEN UNITS

1-12
1-13
Transformations between cylindrical and
z Cartesian From Cartesian to
z0 cylindrical
z0  0
  0
r0

0 y
0

x
From cylindrical to Cartesian

r0  x0 , y0 , z0   0 cos  0 ,  0 sin  0 , z0
x0  cos  0 ,  sin  0 , 0
y0  sin  0 , cos  0 0
z0  0, 0, 1
1-15
1-16
Spherical Coordinates
Spherical Coordinates

2-18
Spherical Coordinates

2-19
Spherical Coordinates

2-20
Spherical Coordinates

2-21
SPHERICAL COORDINATES

Point P has coordinates


Specified by P(r)

2-22
DIFFERENTIAL VOLUME IN
SPHERICAL COORDINATES

dV = r2sindrdd

2-23
Transformations between spherical and Cartesian

z
 0 From Cartesian to spherical
0  0  0  x02  y02  z02 ,
  0 z0 x0
0  0  arccos ,  0  arccos
r0 x02  y02  z02 x02  y02

r0   0 ,  0 ,  0
y  0  sin  0 cos  0 , sin  0 sin  0 , cos 0
0  0  cos 0 cos  0 , cos 0 sin  0 ,  sin  0
   sin  , cos  , 0
0 0 0

x
From spherical to Cartesian

r0   0 sin  0 cos  0 ,  0 sin  0 cos  0 ,  0 cos 0
x0  sin  0 cos  0 , cos 0 sin  0 ,  sin  0
y0  sin  0 sin  0 , cos 0 cos  0 , cos  0
z0  cos 0 ,  sin  0 , 0
DIFFERENTIAL ELEMENTS IN
RECTANGULAR
COORDINATE SYSTEMS

2-25
DIFFERENTIAL ELEMENTS IN
CYLINDRICAL
COORDINATE SYSTEMS

2-26
DIFFERENTIAL ELEMENTS IN SPHERICAL
COORDINATE SYSTEMS

2-27
Example A point P with Cartesian coordinates (2, −2, 1) has
spherical coordinates

1-28
Example A point P with spherical coordinates (4, π/3 , 3π/4) has
Cartesian coordinate

1-29
Example: Convert the point (4, π/4 , π/6) from spherical to
rectangular coordinates

Since ρ = 4, θ = π/4, and φ = π/6,


x = ρ sin φ cos θ = 4.sin π/6 . cos π/4 = 4. ½.(1/√2) = √2,
y = r sin φ sin θ = 4.sin π/6. sin π/4 = 4.1/2.(1/√2) =√2,
z = ρ cos φ = 4.cos π/6 = 4.(√3/2) = 2√3.

Thus, the point is (√2, √2, 2/√3) in rectangular coordinates.

1-30
Example: Convert the point (1, −1, − √2) from rectangular to
spherical coordinates.

1-31
1-32
The first equation gives

1-33
EXAMPLE
Given point P(—2, 6, 3) and vector A = yax + (x + z)ay, express P
and A in cylindrical and spherical coordinates.
Solution: At point P: x = - 2 , y = 6, z = 3. Hence,

2-34
1-35
1-36
1-37
1-38
Using Polar Coordinates

Graphing and
converting polar and
rectangular coordinates
3D Polar Space

Chapter 7 Notes 3D Math Primer for Graphics & Game Dev 40


CYLINDRICAL COORDINATES
A natural extension of the 2d polar coordinates are
cylindrical coordinates, since they just add a height value
out of the xy-plane. For completeness here they are:

1-41
3D Polar Space

There are two kinds in common use:


1.Cylindrical coordinates
– 1 angle and 2 distances
2.Spherical coordinates
– 2 angles and 1 distance

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 42


3D Cylindrical Space

To locate the point


described by cylindrical
coordinates (r, θ, z), start
by processing r and θ just
like we would for 2D polar
coordinates, and then
move up or down the z
axis by z.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 43


3D Spherical Coordinates
• As with 2D polar coordinates, 3D spherical
coordinates also work by defining a direction and
distance.
• The only difference is that in 3D it takes two
angles to define a direction.
• There are two polar axes in 3D spherical space.
1. The first axis is horizontal and corresponds to the
polar axis in 2D polar coordinates or +x in our 3D
Cartesian conventions.
2. The other axis is vertical, corresponding to +y in our
3D Cartesian conventions.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 44


B utterflies are among the most celebrated of all insects. It’s
hard not to notice their beautiful colors and graceful flight. Their
symmetry can be explored with trigonometric functions and a
system for plotting points called the polar coordinate system. In
many cases, polar coordinates are simpler and easier to use than
rectangular coordinates.
We are going to look at a
You are familiar with new coordinate system
plotting with a rectangular called the polar
coordinate system. coordinate system.
The center of the graph is Angles are measured from
called the pole. the positive x axis.

Points are
represented by a
radius and an angle
radius

(r, )
To plot the point
 
 5, 
 4
First find the angle
Then move out along
the terminal side 5
The polar coordinate system is formed by fixing a point, O,
which is the pole (or origin).
The polar axis is the ray constructed from O.
Each point P in the plane can be assigned polar coordinates (r, ).
P = (r, )
an ce
t
dis
ct ed
e
dir
r=
O  = directed angle Polar
Pole (Origin) axis

r is the directed distance from O to P.


 is the directed angle (counterclockwise) from the polar
axis to OP.
48
Polar Coordinate Space
• Recall that 2D Cartesian coordinate space has an origin and two
axes that pass through the origin.
• A 2D polar coordinate space also has an origin (known as the pole),
which has the same basic purpose: it defines the center of the
coordinate space.
• A polar coordinate space only has one axis, sometimes called the
polar axis, which is usually depicted as a ray from the origin.
• It is customary in math literature for the polar axis to point to the
right in diagrams, and thus it corresponds to the +x axis in a
Cartesian system.
• It's often convenient to use different conventions than this, as we'll
discuss later in this lecture. Until then, we’ll use the traditional
conventions of the math literature.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 49


Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 50
Polar Coordinates
• In Cartesian coordinates we described a 2D point using
the using two signed distances, x and y.
• Polar coordinates use a distance and an angle.
• By convention, the distance is usually called r (which is
short for radius) and the angle is usually called θ. The
polar coordinate pair (r, θ) species a point in 2D space
as follows:
1. Start at the origin, facing in the direction of the polar
axis, and rotate by angle θ. Positive values of θ are
usually interpreted to mean counterclockwise rotation,
with negative values indicating clockwise rotation.
2. Now move forward from the origin a distance of r units.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 51


Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 52
Examples

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 53


Polar Diagrams

• The grid circles show lines of constant r.


• The straight grid lines that pass through the
origin show lines of constant θ, consisting of
points that are the same direction from the
origin.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 54


Angular Measurement
• It really doesn't matter whether you use degrees or radians (or
grads, mils, minutes, signs, sextants, or Furmans) to measure
angles, so long as you keep it straight.
• In the text of our book we almost always give specific angular
measurements in degrees and use the ° symbol after the number.
• We do this because we are human beings, and most humans who
are not math professors find it easier to deal with whole numbers
rather than fractions of π.
• Indeed, the choice of the number 360 was specifically designed to
make fractions avoidable in many common cases.
• However, computers prefer to work with angles expressed using
radians, and so the code snippets in our book use radians rather
than degrees.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 55


Some Ponderable Questions

1. Can the radial distance r ever be negative?


2. Can θ ever go outside of –180°≤ θ ≤ 180°?
3. The value of the angle directly west of the
origin (i.e. for points where x < 0 and y = 0 using
Cartesian coordinates) is ambiguous. Is θ equal
to +180° or –180° for these points?
4. The polar coordinates for the origin itself are
also ambiguous. Clearly r = 0, but what value of
θ should we use? Wouldn't any value work?
Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 56
Aliasing
• The answer to all of these questions is “yes”.
• In fact, for any given point, there are infinitely many polar
coordinate pairs that can be used to describe that point.
• This phenomenon is known as aliasing.
• Two coordinate pairs are said to be aliases of each other if
they have different numeric values but refer to the same
point in space.
• Notice that aliasing doesn't happen in Cartesian space. Each
point in space is assigned exactly one (x, y) coordinate pair.
• A given point in polar space corresponds to many
coordinate pairs, but a coordinate pair unambiguously
designates exactly one point.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 57


Creating Aliases
• One way to create an alias for a point (r, θ) is to add a
multiple of 360° to θ. Thus (r, θ) and (r, θ + k360°)
describe the same point, where k is an integer.
• We can also generate an alias by adding 180° to θ and
negating r; which means we face the other direction,
but we displace by the opposite amount.
• In general, for any point (r, θ) other than the origin, all
of the polar coordinates that are aliases for (r, θ) be
expressed as:

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 58


Canonical Polar Coordinates

A polar coordinate pair (r, θ) is in canonical form


if all of the following are true:

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 59


Algorithm to Make (r, θ) Canonical

1. If r = 0, then assign θ = 0.
2. If r < 0, then negate r, and add 180° to θ.
3. If θ ≤ 180°, then add 360° until θ > –180°
4. If θ > 180°, then subtract 360° until
θ ≤ 180°.

Chapter 1 Notes 3D Math Primer for Graphics & Game Dev 60


Graphing Polar Coordinates

The grid at the left is a polar grid. The


A typical angles of 30o, 45o, 90o, … are
shown on the graph along with circles of
radius 1, 2, 3, 4, and 5 units.

Points in polar form are given as (r,  )


where r is the radius to the point and  is
the angle of the point.
On one of your polar graphs, plot the
point (3, 90o)?

The point on the graph labeled A is correct.


A negative angle would be measured clockwise like usual.
 5 
 3, 
 4 
To plot a point
with a negative
radius, find the
terminal side of
the angle but then
measure from the
pole in the
negative direction
of the terminal
side.
 2 
  4, 
 3 
Polar coordinates can also be given with the angle in
degrees.

135
120
90
60
45
(8, 210°)
(6, -120°)
150 30

180
0

(-5, 300°)
330
210
315

(-3, 540°)
225
300
240
270

(540°-360°=180°)
Polar coordinates can also be given with the angle in
degrees.

90
(8, 210°)
120 60
135 45

30
150
(6, -120°),-120+360=240
180
0

(-5, 300°), 300-180=120


330
210
315
225
240
300 (-3, 540°), 540-360-180=0
270
Graphing Polar Coordinates

  3 
Now, try graphing  2, .
 4 
A C
Did you get point B?
Polar points have a new aspect. A radius
can be negative! A negative radius
means to go in the exact opposite
B direction of the angle.
To graph (-4, 240o), find 240o and move 4
units in the opposite direction. The opposite
direction is always a 180o difference.
Point C is at (-4, 240o). This point could
also be labeled as (4, 60o).
Graphing Polar Coordinates

How would you write point A with a


negative radius?
A C
A correct answer would be (-3, 270o) or
(-3, -90o).
In fact, there are an infinite number of
ways to label a single polar point.
B Is (3, 450o) the same point?

Don’t forget, you can also use radian angles


as well as angles in degrees.

On your own, find at least 4 different polar


coordinates for point B.
Plotting Points
 
The point (r, )  2, 3 lies two units from the pole on the
 
terminal side of the angle   . 2
3
 
3
 
2, 
3

 0
1 2 3

3,  34 
   3
4
3 units from 3
the pole 2

Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 67


2,
There are many ways to represent the point 3  .
 

2 2,  53 
2, 3   2,  53   2,  23   2, 43 
2, 3 
additional ways
 0
to represent the 1 2 3

point 2, 3  
(r, )   r,   2n 
(r,  )   r,   (2n  1)  3
2

Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 68


Let's plot the following points:    
 7,    7,  
 2  2

 5   3 
 7,   7,  
 2   2 

Notice unlike in the


rectangular
coordinate system,
there are many
ways to list the
same point.
Converting from Rectangular to Polar

Find the polar form for the rectangular point (4, 3).

To find the polar coordinate, we must


calculate the radius and angle to the
(4, 3) given point.
r We can use our knowledge of right
3
 triangle trigonometry to find the radius
and angle.
4
r2 = 32 + 42 tan  = ¾
r2 = 25  = tan-1(¾)
r=5  = 36.87o or 0.64 rad

The polar form of the rectangular point


(4, 3) is (5, 36.87o)
Converting from Rectangular to Polar

In general, the rectangular point (x, y) is converted to polar form (r, θ) by:

1. Finding the radius


r2 = x 2 + y 2
(x, y)
r 2. Finding the angle
y
 tan  = y/x or  = tan-1(y/x)
Recall that some angles require
x the angle to be converted to the
appropriate quadrant.
Converting from Rectangular to Polar

On your own, find polar form for the point (-2, 3).
3
tan  
(-2, 3) 2
r2 = (-2)2 + 32
r2 = 4 + 9  3
  tan 1  
r2 = 13  2 
r = 13
  56.31o
However, the angle must be in the second
quadrant, so we add 180o to the answer
and get an angle of 123.70o.
The polar form is ( 13 , 123.70o)
Converting from Polar to Rectanglar

Convert the polar point (4, 30o) to rectangular coordinates.

We are given the radius of 4 and angle of 30o.


Find the values of x and y.
Using trig to find the values of x and y, we know
4 that cos  = x/r or x = r cos  . Also, sin  = y/r or
y y = r sin  .
30 o

x  r cos  y  r sin
x
 
x  4 cos 30 o y  4sin 30o 
y  4 1  2
3 2
x  4 2 3
2

The point in rectangular form is: 2 3 , 2 
Converting from Polar to Rectanglar

On your own, convert (3, 5π/3) to rectangular coordinates.

We are given the radius of 3 and angle of 5π/3 or


300o. Find the values of x and y.

-60o x  r cos 
y  r sin
 
x  3 cos 300 o
y  3sin 300o 
1 3 3 3
x  3  y  3  3 
2 2 2 2

3 3 3 
The point in rectangular form is:  , 
2 2 
The relationship between rectangular and polar
coordinates is as follows.
y
The point (x, y) lies on a
circle of radius r, therefore,
r2 = x2 + y2.

(x, y) Definitions of
(r, ) trigonometric functions
r y
y sin  
r
cos   x
Pole  r
x y
tan  
(Origin) x x

Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 75


Coordinate Conversion
cos   x x  r cos 
r
y y  r sin 
sin  
r
y 2 2 2
tan  
x
r  x  y (Pythagorean Identity)

Example:
 
Convert the point 4,  3 into rectangular coordinates.
x  r cos   4 cos    4 1  2
3 2   
 
 
y  r sin   4 sin    4   3   2 3
3  2 
 x, y    2, 2 3 
Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 76
Example:
Convert the point (1,1) into polar coordinates.
 x, y   1,1
y 1
tan     1
x 1
 
4
2 2 2 2
r  x  y  1 1  2
One set of polar coordinates is (r, )   
2,  .
4
Another set is (r, )   2, 5 .
4  
Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 77
Let's take a point in the rectangular coordinate system
and convert it to the polar coordinate system.

(3, 4) Based on the trig you


know can you see
r how to find r and  ?
4
 2
3 4 r 2 2

3
r=5
4
tan  
3
We'll find  in radians
41
polar coordinates are: (5, 0.93)   tan    0.93
3
Let's generalize this to find formulas for converting from
rectangular to polar coordinates.

(x, y) 2 2 2
x y r
r
y
 r x y 2 2

x
y
tan  
x
 y1
  tan  
x
Now let's go the other way, from polar to rectangular
coordinates.
Based on the trig you
know can you see
  how to find x and y?
 4, 
4

 x
4 y cos 
x
4
4 4
 2
x  4 2 2

 2 
 y
sin 
rectangular coordinates are: 4 4

2 2, 2 2   2
y  4
 2
2 2


Let's generalize the conversion from polar to rectangular
coordinates.

x
cos  
r
r , 
r x  r cos 
 y
x
y
sin  
r

y  r sin 
Convert the rectangular coordinate system equation to a
polar coordinate system equation.
From conversions, how
2 2
x  y  9 r x y 2 2
r  3
was r related to x 2 and y 2 ?
Here each r
unit is 1/2 and
we went out 3
and did all
angles.

r must be  3 but there is no


Before we do the conversion restriction on  so consider
let's look at the graph. all values.
Convert the rectangular coordinate system equation to a
polar coordinate system equation. 2
x  4y
What are the polar conversions substitute in for
we found for x and y? x and y

x  r cos 
r cos  2
 4r sin  
y  r sin  2 2
r cos   4r sin 

We wouldn't recognize what this equation looked like


in polar coordinates but looking at the rectangular
equation we'd know it was a parabola.
When trying to figure out the graphs of polar equations we
can convert them to rectangular equations particularly if
we recognize the graph in rectangular coordinates.

r  7 We could square both sides


2
r  49
Now use our conversion:
2 2 2
r x y
x 2  y 2  49
We recognize this as a circle
with center at (0, 0) and a
radius of 7.

On polar graph paper it will centered at the origin and out 7


Let's try another: 
 Take the tangent of both sides
3
To graph on a polar plot
  
tan   tan   3 we'd go to where  
3 and make a line. 3
Now use our conversion:
y
tan  
x
y Multiply both
 3 sides by x
x

y  3x
We recognize this as a line with slope square root of 3.
Let's try another: r sin   5

Now use our conversion: y  r sin 

y  5

We recognize this as a
horizontal line 5 units below
the origin (or on a polar plot
below the pole)
Example:
Convert the polar equation r  4sin  into a rectangular
equation.

r  4sin  Polar form


r 2  4r sin  Multiply each side by r.

x2  y 2  4y Substitute rectangular
coordinates.
x2  y 2  4y  0

x   y  2  4
2
2 Equation of a circle with
center (0, 2) and radius of 2
Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 88
Rectangular and Polar Equations

Equations in rectangular form use variables (x, y), while


equations in polar form use variables (r,  ) where  is an angle.

Converting from one form to another involves changing the


variables from one form to the other.

We have already used all of the conversions which are necessary.

Converting Polar to Rectangular Converting Rectanglar to Polar


cos  = x/r x = r cos 
sin  = y/r y = r sin 
tan  = y/x x2 + y 2 = r 2
r2 = x 2 + y 2
Convert Rectangular Equations
to Polar Equations

The goal is to change all x’s and y’s to r’s and  ’s.
When possible, solve for r.

Example 1: Convert x2 + y2 = 16 to polar form.


Since x2 + y2 = r2, substitute into the equation.
r2 = 16
Simplify.

r=4

r = 4 is the equivalent polar equation to x2 + y2 = 16


Example: Converting rectangular equations to polar equations is
quite simple. Recall that x = r cos θ and y = r sin θ. By using this
information, the polar equation that corresponds with the rectangular
equation of 3x – y + 2 = 0 can be found.
Example:
Example:
Convert Rectangular Equations
to Polar Equations

Example 2: Convert y = 3 to polar form.


Since y = r sin  , substitute into the equation.
r sin  = 3
Solve for r when possible.

r = 3 / sin 

r = 3 csc  is the equivalent polar equation.


Convert Rectangular Equations
to Polar Equations

Example 3: Convert (x - 3)2 + (y + 3)2 = 18 to polar form.


Square each binomial.
x2 – 6x + 9 + y2 + 6y + 9 = 18
Since x2 + y2 = r2, re-write and simplify by combining like terms.
x2 + y2 – 6x + 6y = 0
Substitute r2 for x2 + y2, r cos  for x and r sin  for y.
r2 – 6rcos  + 6rsin  = 0
Factor r as a common factor.
r(r – 6cos  + 6sin  ) = 0
r = 0 or r – 6cos  + 6sin  = 0
Solve for r: r = 0 or r = 6cos  – 6sin 
Convert Polar Equations
to Rectangular Equations

The goal is to change all r’s and  ’s to x’s and y’s.

Example 1: Convert r = 5 to rectangular form.


Since r2 = x2 + y2, square both sides to get r2.
r2 = 25
Substitute.

x2 + y2 = 25

x2 + y2 = 25 is the equivalent polar equation to r = 5


Convert Polar Equations
to Rectangular Equations

Example 2: Convert r = 5 cos  to rectangular form.

Multiply both sides by r

r2 = 5 r cos

Substitute x for r cos 

r2 = 5x

Substitute for r2.

x2 + y2 = 5x is rectangular form.
Convert Polar Equations
to Rectangular Equations

Example 3: Convert r = 2 csc  to rectangular form.


Since csc ß = 1/sin, substitute for csc  .

1
r  2*
sin 
Multiply both sides by 1/sin.
1 sin 
r sin   2 * *
sin  1
Simplify

y = 2 is rectangular form.
 You will notice that polar equations have
graphs like the following:
Relations between Cartesian, Cylindrical, and Spherical
Coordinates

You might also like