You are on page 1of 14

Chapter 6

Coordinate Systems

6.1 Introduction

In this chapter we revise Cartesian coordinates, axial systems, the distance between
two points in space, and the area of simple 2D shapes. It also covers polar, spherical
polar and cylindrical coordinate systems.

6.2 Background

Rene Descartes is often credited with the invention of the xy-plane, but the French
lawyer and mathematician Pierre de Fermat (1601-1665) was probably the first
inventor. In 1636 Fermat was working on a treatise titled Ad locus pianos et soli-
dos isagoge, which outlined what we now call "analytic geometry". Unfortunately,
Fermat never published his treatise, although he shared his ideas with other mathe-
maticians such as Blaise Pascal (1623-1662). At the same time, Descartes devised
his own system of analytic geometry and in 1637 published his results in the presti-
gious journal Geometric. In the eyes of the scientific world, the publication date of
a technical paper determines when a new idea or invention is released into the pub-
lic domain. Consequently, ever since this publication Descartes has been associated
with the xy-plane, which is why it is called the Cartesian plane.
The Cartesian plane is such a simple idea that it is strange that it took so long
to be discovered. However, although it is true that Rene Descartes showed how
an orthogonal coordinate system could be used for graphs and coordinate geometry,
coordinates had been used by ancient Egyptians, almost 2000 years earlier! If Fermat
had been more efficient in publishing his research results, the xy-plane could have
been called the Fermatian plane! (Boyer and Merzbach, 1989).

© Springer International Publishing Switzerland 2015 95


J. Vince, Foundation Mathematics for Computer Science,
DOI 10.1007/978-3-319-21437-5_6
96 6 Coordinate Systems

Fig. 6.1 The Cartesian plane y


_,,
J

P(3, 2)
2-

~
- - -3 _i)
-, 0 'x
-

-,.
Q(-4 -2)
-J

6.3 The Cartesian Plane

The Cartesian plane provides a mechanism for locating points with a unique, ordered
pair of numbers (x, y) as shown in Fig. 6.1, where P has coordinates (3, 2) and Q has
coordinates (-4, -2). The point (0, 0) is called the origin. As previously mentioned,
Descartes suggested that the letters x and y should be used to represent variables,
and letters at the other end of the alphabet should stand for numbers. Which is why
equations such as y = ax2 +bx+ c, are written this way.
The axes are said to be oriented as the x-axis rotates anticlockwise towards the
y-axis. They could have been oriented in the opposite sense, with the y-axis rotating
anticlockwise towards the x-axis.

6.4 Function Graphs

When functions such as

linear: y = mx + c,
quadratic: y = ax2 + bx + c,
cubic: y = ax3 + bx2 +ex+ d,
trigonometric: y = a sm x,
are drawn as graphs, they create familiar shapes that permit the function to be easily
identified. Linear functions are straight lines; quadratics are parabolas; cubics have
an "S" shape; and trigonometric functions often possess a wave-like trace. Figure6.2
shows examples of each type of function.
6.5 Shape Representation 97

Fig. 6.2 Graphs of four y


function types

quad atic

sinuso d

6.5 Shape Representation

The Cartesian plane also provides a way to represent 2D shapes numerically, which
permits them to be manipulated mathematically. Let's begin with 2D polygons and
show how their internal area can be calculated.

6.5.1 2D Polygons

A polygon is formed from a chain of vertices (points) as shown in Fig. 6.3. A straight
line is assumed to connect each pair of neighbouring vertices; intermediate points
on the line are not explicitly stored. There is no convention for starting a chain
of vertices, but software will often dictate whether polygons have a clockwise or
anticlockwise vertex sequence.

Fig. 6.3 A simple polygon y


created by a chain of vertices (I, 3)
3

(3, 2)
2

(I, I) (3, I)

2 3 4 5 X
98 6 Coordinate Systems

We can now subject this list of coordinates to a variety of arithmetic and mathe-
matical operations. For example, if we double the values of x and y and redraw the
vertices, we discover that the shape's geometric integrity is preserved, but its size
is doubled relative to the origin. Similarly, if we divide the values of x and y by 2,
the shape is still preserved, but its size is halved relative to the origin. On the other
hand, if we add 1 to every x-coordinate, and 2 to every y-coordinate, and redraw the
vertices, the shape's size remains the same but is displaced 1 unit horizontally and 2
units vertically.

6.5.2 Areas of Shapes

The area of a polygonal shape is readily calculated from its list of coordinates. For
example, using the list of coordinates shown in Table 6.1: the area is computed by

1
area= + (x1y2 - x2y1) + (x2y3 + (x3yo - xoy3)].
2[(xoyi - xiyo) - x3y2)

You will observe that the calculation sums the results of multiplying an x by the
next y, minus the next x by the previous y. When the last vertex is selected, it is
paired with the first vertex to complete the process. The result is then halved to reveal
the area. As a simple test, let's apply this formula to the shape described in Fig. 6.3:

1
area= 2((1 x 1 - 3 x 1) + (3 x 2 - 3 x 1) + (3 x 3 - 1 x 2) + (1 x 1 - 1 x 3)]
1
area = -[-2
2
+ 3 + 7 - 2] = 3.

which, by inspection, is the true area. The beauty of this technique is that it works
with any number of vertices and any arbitrary shape.
Another feature of the technique is that if the set of coordinates is clockwise,
the area is negative, which means that the calculation computes vertex orientation as
well as area. To illustrate this feature, the original vertices are reversed to a clockwise
sequence as follows:

Table 6.1 A polygon's X y


coordinates
xo YO
XJ YI
x2 Y2
X3 Y3
6.5 Shape Representation 99

1
area= -[(l x 3 - 1 x 1) + (1 x 2 - 3 x 3) + (3 x 1 - 3 x 2) + (3 x 1 - 1 x 1)]
2
1
area= -[2 - 7 - 3 + 2] = -3.
2

The minus sign confirms that the vertices are in a clockwise sequence.

6.6 Theorem of Pythagoras in 2D

The theorem of Pythagoras is used to calculate the distance between two points.
Figure6.4 shows two arbitrary points P1 (x1, YI) and P2(x2, y2). The distance b.x =
x2 - x1 and b.y = y2 - YI. Therefore, the distanced between P1 and P2 is given by

d = ✓ (b.x)2 + (b.y)2.
For example, given P1 (1, 1), P2(4, 5), then d = J32 + 42 = 5.

6.7 3D Cartesian Coordinates

Two coordinates are required to locate a point on the 2D Cartesian plane, and three
coordinates are required for 3D space. The corresponding axial system requires three
mutually perpendicular axes; however, there are two ways to add the extra z-axis.
Figure6.5 shows the two orientations, which are described as left- and right-handed
axial systems. The left-handed system permits us to align our left hand with the axes
such that the thumb aligns with the x-axis, the first finger aligns with the y-axis,
and the middle finger aligns with the z-axis. The right-handed system permits the
same system of alignment, but using our right hand. The choice between these axial

Fig. 6.4 Calculating the y


distance between two points
P2
Y2 -----------------------

~y d

X
100 6 Coordinate Systems

(b) y

(a) y

z X

X z

Fig. 6.5 a A left-handed system. b A right-handed system

Fig. 6.6 A right-handed y


axial system showing the
coordinates of a point P p
0

z X ,. z X

systems is arbitrary, but one should be aware of the system employed by commercial
computer graphics packages. The main problem arises when projecting 3D points
onto a 2D plane, which has an oriented axial system. A right-handed system is
employed throughout this book, as shown in Fig. 6.6, which also shows a point P
with its coordinates. It also worth noting that handedness has no meaning in spaces
with 4 dimensions or more.

6. 7.1 Theorem of Pythagoras in 3D

The theorem of Pythagoras in 3D is a natural extension of the 2D rule. In fact,


it even works in higher dimensions. Given two arbitrary points P1 (x1, Yl, z 1) and
P2(x2, y2, z2), we compute Lu = x2 - x1, .6.y = Y2 - YI and .6.z = z2 - z1, from
6.7 3D Cartesian Coordinates 101

which the distance d between P1 and P2 is given by

d = J(!),.x)2 + (!),.y)2 + (!),.z)2

and the distance from the origin to a point P (x, y, z) is simply

d = Jx2 + y2 + z2.

Therefore, the point (3, 4, 5) is ✓32 + 42 + 52 ~ 7.07 from the origin.

6.8 Polar Coordinates

Polar coordinates are used for handling data containing angles, rather than linear
offsets. Figure6.7 shows the convention used for 2D polar coordinates, where the
point P(x, y) has equivalent polar coordinates P(p, 0), where:

x = p cos0
y = p sine
p = Jx2 + y2
0 = arc tan (y / x).

For example, the point Q(4, 0.8n) in Fig.6.7 has Cartesian coordinates:

x = 4 cos(0.8n) ~ -3.24
y = 4 sin(0.8n) ~ 2.35

Fig. 6.7 2D polar y


coordinates Q(4, 0.8 7t) 3 P(p, 8) = P(x, y)

-4 3 4 X

-2

-3
102 6 Coordinate Systems

and the point (3, 4) has polar coordinates:

p = J32 + 42 = 5
0 = arctan(4/3) ~ 53.13°.

These conversion formulae work only for the first quadrant. The atan2 function
should be used in a software environment, as it works with all four quadrants.

6.9 Spherical Polar Coordinates

Figure6.8 shows one convention used for spherical polar coordinates, where the
point P(x, y, z) has equivalent polar coordinates P(p, ¢, 0), where:

x = p sin ¢ cos 0
y = p sin ¢ sin 0
z = p cos d:

P J
= x2 + y2 + 22
¢ = arccos(z/ p)
0 = arctan(y /x).
For example, the point (3, 4, 0) has spherical polar coordinates (5, 90°, 53 .13 °):

p = J32 + 42 + 02 = 5
<p = arccos(0/5) = 90°
0 = arctan(4/3) ~ 53.13°.

Fig. 6.8 Spherical polar z


coordinates
P(p, ¢, 0)=-P(x, y, z)

p I
,z
I

fa-----,--~-• y
/

.... : /,, X
------ ---- -- _-......, /

X
6.9 Spherical Polar Coordinates 103

Take great care when using spherical coordinates, as authors often swap </J with 0, as
well as the alignment of the Cartesian axes; not to mention using a left-handed axial
system in preference to a right-handed system!

6.10 Cylindrical Coordinates

Figure6.9 shows one convention used for cylindrical coordinates, where the point
P(x, y, z) has equivalent cylindrical coordinates P(p, 0, z), where

x = p cos0
y = p sin0
z=z

P = Jx2 + y2
0 = arctan ( i) .
For example, the point (3, 4, 6) has cylindrical coordinates (5, 53.13°, 6):

p = J32 + 4 2
= 5

0 = arctan ( i) ~ 5 3 .13 °

z = 6.

Again, be careful when using cylindrical coordinates to ensure compatibility.

Fig. 6.9 Cylindrical z


coordinates

, P(p, -~:; z)=P(x, y, z)


- - - - - - - - - - - - -?

:z
-'<-------'-------+ y
e ', ,P' : , ,X'
' I /
----------~V
y

X
104 6 Coordinate Systems

6.11 Barycentric Coordinates

Barycentric coordinates locate a point in space relative to existing points, rather than
to an origin, and are also known as local coordinates. The German mathematician
August Mobius (1790-1868) is credited with their invention.
Given two points in 2D space A(xa, Ya) and B(xb, Yb), an intermediate point
P(xp, Yp) has barycentric coordinates:

Xp = SXa + t xi,
Yp = SYa + tyb
1 = s + t.

For example, whens = t = 0.5, P is halfway between A and B. In 3D, we simply


add a z-coordinate.
Given three points in 3D space: A(xa, Ya, Za), B(xb, Yb, Zb) and C(xc, Ye, Ze),
then any point P(xp, Yp, Zp) inside the triangle ABC has barycentric coordinates:

Xp = r Xa + s Xb + t Xe
Yp = rv« + SYb + t y;
Zp = rza + SZb + tze
1 = r + s + t.
For example, whenr = 1, s = t = 0, then P =A.Similarly, whens= 1, r = t = 0,
then P = B. When r = s = t = 1/3, then Pis located at the triangle's centroid.

6.12 Homogeneous Coordinates

Homogeneous coordinates surfaced in the early 19th century where they were inde-
pendently proposed by Mobius, Feuerbach, Bobillier, and Plilcker. Homogeneous
coordinates, define a point in a plane using three coordinates instead of two. This
means that for a point (x, y) there exists a homogeneous point (xt, yt, t) where
t is an arbitrary number. For example, the point (3, 4) has homogeneous coordi-
nates (6, 8, 2), because 3 = 6/2 and 4 = 8/2. But the homogeneous point (6, 8, 2)
is not unique to (3, 4); (12, 16, 4), (15, 20, 5) and (300,400, 100) are all possible
homogeneous coordinates for (3, 4).
The reason why this coordinate system is called "homogeneous" is because it is
possible to transform functions such as f (x, y) into the form f (x / t, y / t) without
disturbing the degree of the curve. To the non-mathematician this may not seem
anything to get excited about, but in the field of projective geometry it is a very
powerful concept.
6.12 Homogeneous Coordinates 105

In 3D, a point (x, y, z) becomes (xt, yt, zt , t) and for may applications t = 1,
which seems a futile operation, but in matrix theory it is very useful, as we will
discover.

6.13 Worked Examples

6.13.1 Area of a Shape

Compute the area and orientation of the shape defined by the coordinates in Table 6.2.

1
area= 2[(2 x 2 - 0 x 2) + (2 x 2 - 2 x 1) + (1 x 1 - 2 x 1) + (1 x 1 - 1 x 0)]
1
=2(4+2-1+1)

= 3.

The shape is oriented anticlockwise, as the area is positive.

6.13.2 Distance Between Two Points

Find the distance d12 between P1(1, 1) and P2(6, 7), and d34 between P3(1, 1, 1)
and P4(7, 8, 9).

d12 = J(6 - 1)2 + (7 - 1) 2 = ✓61 ~ 7.81


d34 = JO - 1)2 + (8 - 1)2 + (9 - 1) 2 = -/149 ~ 12.21.

6.13.3 Polar Coordinates

Convert the 2D polar coordinates (3, n /2) to Cartesian form, and the point (4, 5) to
polar form.

Table 6.2 Shape coordinates


X

y
106 6 Coordinate Systems

p=3
0 = n/2
x = p cos0 = 3 cos(n/2) = 0
y = psin0 = 3sin(n/2) = 3

therefore, (3, n /2) = (0, 3).

x=4
y=5
p = Jx2 + y2 = J42 + 52 ~ 6.4
0 = arctan(y/x) = arctan(5/4) ~ 51.34°

therefore, (4, 5) ~ (6.4, 51.34°).

6.13.4 Spherical Polar Coordinates

Convert the spherical polar coordinates (10, n /2, 45°) to Cartesian form, and the
point (3, 4, 5) to spherical form.

p = 10
</J = n/2
0 = 45°
x = p sin </J cos 0 = 10 sin(n /2) cos 45° = 10✓2/2 ~ 7 .07
y = p sin </J sin 0 = 10 sin(n /2) sin 45° = 10✓2/2 ~ 7.07
z =peas¢= lOcos(n/2) = 0

therefore, (10, n /2, 45°) ~ (7.07, 7.07, 0).

x=3
y=4
z=5
P = Jx2 + y2 + z2 = J32 + 42 + 52 ~ 7.07
</J= arccos(z/ p) ~ arccos(5/7.07) = 45°
0 = arctan(y/x) = arctan(4/3) ~ 53.13°

therefore, (3, 4, 5) ~ (7.07, 45°, 53.13°).


6.13 Worked Examples 107

6.13.5 Cylindrical Coordinates

Convert the 3D cylindrical coordinates (10, n /2, 5) to Cartesian form, and the point
(3, 4, 5) to cylindrical form.

p = 10
0 = n/2
z=5
x = pcos0 = lOcos(n/2) = 0
y = p sin 0 = 10 sin(n /2) = 10
z=5

therefore, (10, 7r /2, 5) = (0, 10, 5).

6.13.6 Barycentric Coordinates

Given A(xa, Ya, Za), B(xb, Yb, Zb) and C(xc, Ye, z-), state the barycentric coordi-
nates for A, B, C the points r.:
Pbc and Pea mid-way between AB, BC and CA
respectively, and the centroid Pc.
Table6.3 shows the barycentric coordinates for ABC.

Table 6.3 Barycentric Point r s t


coordinates
A I 0 0
B 0 1 0
C 0 0 I
Pab 0.5 0.5 0
r; 0 0.5 0.5
Pea 0.5 0 0.5
Pc 1/3 1/3 1/3
Chapter 7
Determinants

7 .1 Introduction

When patterns of numbers or symbols occur over and over again, mathematicians
often devise a way to simplify their description and assign a name to them. For
example,

is shorthand for

and

is shorthand for

A determinant is another example of this process, and is a value derived from a


square matrix of terms, often associated with sets of equations. Such problems were
studied by the Babylonians around 300 BC and by the Chinese, between 200 BC
and 100 BC. Since then many mathematicians have been associated with the evolu-
tion of determinants and matrices, including Girolamo Cardano (1501-1576), Jan de
Witt (1625-1672), Takakazu Seki (1642-1708), Gottfried von Leibniz, Guillaume
de L'Hopital (1661-1704), Augustin-Louis Cauchy (1789-1857), Pierre Laplace

© Springer International Publishing Switzerland 2015 109


J. Vince, Foundation Mathematics for Computer Science,
DOI 10.1007/978-3-3 l 9-21437-5_7

You might also like