This module is part of the collection, A First Course in Electrical and Computer Engineering. The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.
We now consider the storage and manipulation of three-dimensional objects. We will continue to use homogeneous coordinates so that translation
can be included in composite operators. Homogeneous coordinates in three
dimensions will also allow us to do perspective projections so that we can view
a three-dimensional object from any point in space.
Image Representation. The three-dimensional form of the point matrix in homogeneous coordinates is
G
=
x
1
x
2
x
3
...
x
n
y
l
y
2
y
3
...
y
n
z
1
z
2
z
3
...
z
n
1
1
1
...
1
∈
R
4
×
n
.
G
=
x
1
x
2
x
3
...
x
n
y
l
y
2
y
3
...
y
n
z
1
z
2
z
3
...
z
n
1
1
1
...
1
∈
R
4
×
n
.
(1)
The line matrix
H
H is exactly as before, pointing to pairs of columns in
G
G to
connect with lines. Any other grouping matrices for objects, etc., are also
unchanged.
Image manipulations are done by a 4×44×4 matrix A. To ensure that the
fourth coordinate remains a 1, the operator A must have the structure
A=a11a12a13a14a21a22a23a24a31a32a33a340001.
A=a11a12a13a14a21a22a23a24a31a32a33a340001.
(2)The new image has point matrix
G
n
e
w
=
A
G
.
G
n
e
w
=
A
G
.
(3)
If the coordinates of the ithith point in G are (xi,yi,zi,1)(xi,yi,zi,1), what
are the coordinates of the ithith point in Gnew=Gnew= AG when A is as given in
Equation 2?
Write down the point matrix
G
G for the unit cube (the cube with
sides of length 1, with one corner at the origin and extending in the positive
direction along each axis). Draw a sketch of the cube, numbering the vertices
according to their order in your point matrix. Now write down the line matrix
H
H to complete the representation of the cube.
Left- and Right-Handed Coordinate Systems. In this book we
work exclusively with right-handed coordinate systems. However, it is worth
pointing out that there are two ways to arrange the axes in three dimensions.
Figure 1(a) shows the usual right-handed coordinates, and the left-handed
variation is shown in Figure 1(b). All possible choices of labels x,yx,y, and
z
z
for the three coordinate axes can be rotated to fit one of these two figures,
but no rotation will go from one to the other.
Be careful to sketch a right-handed coordinate system when you are
solving problems in this chapter. Some answers will not be the same for a
left-handed system.
Image Transformation. Three-dimensional operations are a little
more complicated than their two-dimensional counterparts. For scaling and
translation we now have three independent directions, so we generalize the
operators of Equation 10 from "Vector Graphics: Homogeneous Coordinates" as
S
(
s
x
,
s
y
,
s
z
)
=
s
x
0
0
0
0
s
y
0
0
0
0
s
z
0
0
0
0
1
T
(
t
x
,
t
y
,
t
z
)
=
1
0
0
t
x
0
1
0
t
y
0
0
1
t
z
0
0
0
1
.
S
(
s
x
,
s
y
,
s
z
)
=
s
x
0
0
0
0
s
y
0
0
0
0
s
z
0
0
0
0
1
T
(
t
x
,
t
y
,
t
z
)
=
1
0
0
t
x
0
1
0
t
y
0
0
1
t
z
0
0
0
1
.
(4)
Show that T(-tx,-ty,-tz)T(-tx,-ty,-tz) is the inverse of T(tx,ty,tz).T-1T(tx,ty,tz).T-1
undoes the work of
T
T.
Rotation may be done about any arbitrary line in three dimensions. We
will build up to the general case by first presenting the operators that rotate
about the three coordinate axes. Rx(θ)Rx(θ) rotates by angle
θ
θ about the x-axis,
with positive
θ
θ going from the y-axis to the z-axis, as shown in Figure 2. In
a similar fashion, positive rotation about the y-axis using Ry(θ)Ry(θ) goes from
z
z
to
x
x, and positive rotation about the z-axis goes from
x
x to
y
y, just as in two
dimensions. We have the fundamental rotations
R
x
(
θ
)
=
1
0
0
0
0
c
o
s
θ
-
s
i
n
θ
0
0
s
i
n
θ
c
o
s
θ
0
0
0
0
1
R
y
(
θ
)
=
c
o
s
θ
0
s
i
n
θ
0
0
1
0
0
-
s
i
n
θ
0
c
o
s
θ
0
0
0
0
1
R
z
(
θ
)
=
c
o
s
θ
-
s
i
n
θ
0
0
s
i
n
θ
c
o
s
θ
0
0
0
0
1
0
0
0
0
1
.
R
x
(
θ
)
=
1
0
0
0
0
c
o
s
θ
-
s
i
n
θ
0
0
s
i
n
θ
c
o
s
θ
0
0
0
0
1
R
y
(
θ
)
=
c
o
s
θ
0
s
i
n
θ
0
0
1
0
0
-
s
i
n
θ
0
c
o
s
θ
0
0
0
0
1
R
z
(
θ
)
=
c
o
s
θ
-
s
i
n
θ
0
0
s
i
n
θ
c
o
s
θ
0
0
0
0
1
0
0
0
0
1
.
(5)
A more general rotation about any line through the origin can be constructed
by composition of the three fundamental rotations. Finally, by composing
translation with the fundamental rotations, we can build an operator that
rotates about any arbitrary line in space.
To rotate by angle
φ
φ about the line LL, which lies in the
x
-
y
x-y plane in Figure 3, we would
- rotate LL to the x-axis with Rz(-θ)Rz(-θ);
- rotate by
φ
φ about the x-axis with Rx(φ)Rx(φ); and
- rotate back to LL with Rz(θ)Rz(θ).
The composite operation would be
A
(
θ
,
φ
)
=
R
z
(
θ
)
R
x
(
φ
)
R
z
(
-
θ
)
.
A
(
θ
,
φ
)
=
R
z
(
θ
)
R
x
(
φ
)
R
z
(
-
θ
)
.
(6)
Direction Cosines. As discussed in the chapter on Linear Algebra, a vector
v
v may be
specified by its coordinates (x,y,z)(x,y,z) or by its length and direction. The length
of
v
v is ||v||||v||, and the direction can be specified in terms of the three direction cosines ( cosθxcosθx, cosθycosθy, cosθzcosθz). The angle
θ
x
θ
x
is measured between the vector
v
v and the x-axis or, equivalently, between the vector
v
v and the vector ex=ex=[100]T[100]T. We have
cos
θ
x
=
(
v
,
e
x
)
|
|
v
|
|
|
|
e
x
|
|
=
x
|
|
v
|
|
cos
θ
x
=
(
v
,
e
x
)
|
|
v
|
|
|
|
e
x
|
|
=
x
|
|
v
|
|
(7)
Likewise,
θ
y
θ
y
is measured between
v
v and ey=[010]Tey=[010]T, and
θ
z
θ
z
is measured
between
v
v and ez=[001]Tez=[001]T. Thus
cos
θ
y
=
y
|
|
v
|
|
cos
θ
z
=
z
|
|
v
|
|
cos
θ
y
=
y
|
|
v
|
|
cos
θ
z
=
z
|
|
v
|
|
(8)
The vector
u
=
cos
θ
x
cos
θ
y
cos
θ
z
u
=
cos
θ
x
cos
θ
y
cos
θ
z
(9)is a unit vector in the direction of
v
v, so we have
v=||v||u=||v||cosθxcosθycosθz.v=||v||u=||v||cosθxcosθycosθz.
(10)
Show that
u
u is a unit vector (i.e. 1 u||=1u||=1).
The direction cosines are useful for specifying a line in space. Instead
of giving two points
P
1
P
1
and
P
2
P
2
on the line, we can give one point
P
1
P
1
plus the
direction cosines of any vector that points along the line. One such vector is
the vector from
P
1
P
1
to
P
2
P
2
.
Arc tangents. Consider a vector v=xyv=xy in two dimensions. We
know that
tan
θ
=
y
x
tan
θ
=
y
x
(11)
for the angle
θ
θ shown in Figure 4. If we know
x
x and
y
y, we can find
θ
θ using
the arc tangent function
θ=tan-1(yx).θ=tan-1(yx).
(12)
In MATLAB,
Unfortunately, the arc tangent always gives answers between -π2-π2 and π2π2 corresponding to points
v
v in quadrants I and IV. The problem is that the ratio
-
y
-
x
-
y
-
x
is the same as the ratio ---xA---xA so quadrant III cannot be distinguished from quadrant I by the ratio
y
x
y
x
Likewise, quadrants II and IV are indistinguishable.
The solution is the two-argument arc tangent function. In MATLAB,
will give the true angle θθ
-π-π and
π
π in any of the four quadrants.
Consider the direction vector u=cosθxcosθycosθzu=cosθxcosθycosθz, as shown
in Figure 5. What is the angle
φ
y
φ
y
between the projection of
u
u into the x-yx-y
plane and the y-axis? This is important because it is Rz(φy)Rz(φy) that will put
u
u
in the y-zy-z plane, and we need to know the angle
φ
y
φ
y
in order to carry out this
rotation. First note that it is not the same as
θ
y
θ
y
. From the geometry of the
figure, we can write
tanφy=cosθxcosθytanφy=cosθxcosθy
(13)This gives us a formula for
φ
y
φ
y
in terms of the direction cosines of
u
u. With
the two-argument arc tangent, we can write
φy=tan-1(cosθx,cosθy).φy=tan-1(cosθx,cosθy).
(14)
- Suppose point
p
'
p' is in the
y
-
z
y-z plane in three dimensions, p'=(0,y','',1)p'=(0,y','',1).
Find
θ
θ so that Rx(θ)Rx(θ) will rotate
p
'
p' to the positive z-axis. (Hint: Use the
two-argument arc tangent.
θ
θ will be a function of y'y' and z'.z'.)
- Let
p
p be any point in three-dimensional space, p=(x,y,z,1)p=(x,y,z,1). Find
ψ
ψ
so that Rz(ψ)Rz(ψ) rotates
p
p into the
y
-
z
y-z plane. (Hint: Sketch the situation in
three-dimensions, then sketch a two-dimensional view looking down at the
x
-
y
x-y
plane from the positive z-axis. Compare with Example 2.)
Your answers to parts (a) and (b) can be composed into an operator
Z(p)Z(p) that rotates a given point
p
p to the positive z-axis, Z(p)=Rx(θ)Rz(ψ)Z(p)=Rx(θ)Rz(ψ).
- Let LL be a line in three-dimensional space specified by a point 1 ==(x,y,z,1)(x,y,z,1) and the direction cosines ( cosθxcosθx, cosθycosθy, cosθzcosθz). Use the following procedure to derive a composite operator R(φ,L)R(φ,L) that rotates by angle φ
about the line LL:
- translate 1 to the origin;
- let u=u=( cosθxcosθx, cosθycosθy, cosθz,1cosθz,1) and use Z(u)Z(u) to align LL with the z-axis;
- rotate by
φ
φ about the z-axis;
- undo step (ii); and
- undo step (i).
"Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"