You are on page 1of 86

University of Illinois-Chicago

Chapter 3
Transformation and
Manipulation of Objects
Principles of
Computer-Aided
Design and
Manufacturing
Second Edition 2004
ISBN 0-13-064631-8

Author: Prof. Farid. Amirouche


University of Illinois-Chicago

3.1 Introduction

Motorcycle Engine Design

3D Detailed Building Layouts

Automobile Body Display

An Auxiliary View of a Building

3.2 Transformation Matrix

Cnew R.Cold
3.3 2D Transformation

x
y

new

R11

R21

R12 x
R22 y

xnew xold R11 yold R12


ynew xold R21 yold R22

old

x
y

new

x
a
y

old

1
R
shy

shx
1

Where
sh y= Shear along x-direction.
shx =

Shear along y-direction

3.4 Arbitrary Rotation about the Origin

Counterclockwise rotation of x and y to obtain and


x

x1 x1 cos y1 sin
y1 x2 sin y1 cos
x1

x1'
'
1

cos

sin

sin x1
cos y1

Where
cos
sin

sin
cos

is the rotation matrix.

3.5 Rotation by Different Angles


x'
1
y ' cos( )

2
1

cos 2
sin
1

sin 2 x
cos1 y

Arbitrary rotation of axes x and y

3.6 Concatenation
Cnew Rs Rr Cold

R Rs Rr
3.7 2D Translation

xnew xold x
ynew yold y
xnew xold x
y y y

new old

R=

a b
c d

0 0

x
y
1

1 0 x

R= 0 1 y

0 0 1

x1
y
1
1

x2
y2
1

x3 1 0 x x1 x
y3 0 1 y y1 y
1 0 0 1
1

Reverse the order of the 2 matrices

x2 x
y2 y
1

x3 x
y3 y
1

3.8 Projection onto a 2D Plane


1 0 p
0 1 q

0 0 1

R1 =

where

H px qy 1
X*=x, y*=y

x * , y * , 1

H H

3.9 Overall Scaling


C * R.C
100
R= 010

00s
.

x*

1
n
y*
s

s00
0s0

001

1
value of the desired scale

P1

(0,0)

An example for overall scaling of an 2D object

3.10 Rotation about an Arbitrary Point

Example
Rotation of an Object about an Arbitrary Point in 2D
Let C describe an object or configuration of some geometry, where C is
an array of data-point coordinates.

Solution:
1 0 m
0 1 n

0 0 1

cos
sin

sin
cos
0

0
0
1

1 0 m
0 1 n C C *

0 0 1

C * [ R][C ]
sin

cos
0

b'

c'

a'

+
- cos sin m(cos 1) n sin
[R] =

m sin n(cos 1)

d'
P
m d

(0,0)

Rotation about arbitrary point.

Example
Uniform Scaling in 2D
Find the transformation matrix that would produce rotation
of the geometry about point A, s shown in Figure 3.11(a),
followed by a uniform scaling of the geometry down to
half its original size.

Solution:
Step 1: Place the points into a matrix.
Step 2: Translate point A to the origin, that is, -2- along the xaxis and -10 along the y
Axis, as shown in Figure 3.11(b).
Step 3: Rotate the object 30 degrees about the z-axis, as
shown is Figure 3.12(c).
Step 4: Translate point A to its original position as shown in
Figure 3.12(d).
Step 5: Scale the object to half its original size, as shown is
Figure 3.13(e).

Y
Y
Point A
Point A

(0,5) (3,5)
(4,3)

(12,5)

(15,5)

(11,3)

(15,0)

Point
O

(a)

(b)

First step

Point A

Point A

X
(c)

(d)

Step 2 and 3

Point A

(e)

Final step

3.11 2D Reflection
Y

1 0 0
0 1 0
R=

0 0 0

(0,0)

Reflection about y-axis

R=

1 0 0
0 1 0

0 0 1

(0,0)

Reflection about x-axis

Reflection about any arbitrary Point


1 0 m
0 1 n
T=

0 0 1
1 0 0

R= 0 1 0
0 0 1

1 0 m

T1= 0 1 n
0 0 1

Reflection about arbitrary point

Reflection about arbitrary axis:


a) Coordinate transformation to move the line so it passes through o .

T1=

1 0 0
0 1 0

0 c 1

1 0 0
0 1 c

0 0 1

b) Rotation to make the x-axis align with the given line

T2 =

cos( ) sin( ) 0
sin( ) cos( ) 0

0
0
1

c) Reflection about the x-axis


R=

1 0 0
0 1 0

0 0 1

d) Rotation back by an angle


T3 =

cos( ) sin( ) 0
sin( ) cos( ) 0

0
0
1

The concatenated matrix expressing the above steps is defined by

Cnew T3.R.T2T1Cold

Y
Y

(0,0)

Reflection about an arbitrary axis y=mx+c

(0,0)

Reflection of the object

3.12 3D TRANSFORMATION

A trailer with a lower-attachment

An energy-fuel vehicle

3.13 3D Scaling
(a) Local Scaling:

a 0 0 0
0 b 0 0

R
0 0 c 0

0 0 0 1

Scaling : Overall scaling

(b) Overall
can be achieved by the following
transformation matrix where the final coordinates need to be normalized

1
0
R
0

where

0
0
0

n
0
R
0

0
0
0

0
1
0
0

0
0
1
0

1
1

value of the desired scale n

0
n
0
0

0
0
n
0

x*
s

y*
s

z*
1
s

Overall scaling

RsC C *
0
0

2 2
1 1
0 1 0 1 0 1 0 1

C=

Let

0
0

2 2 0
0 0 1

0
1

1 1 1

1
0
R=
0
0

0
2
0
0

Then

C * RC

0
0
1
0

0
0

0
1

1 1

Figure 3.21 Application of zooming effect in computer graphics

3D Scaling

3.14 3D Rotation of objects

Rx

3 0
Matrix
0

0 1

0
0
1

0 cos sin

0 sin cos

x x'
y y ' cos z sin
z z ' cos y ' sin

Rotation about x-axis

0
x' 1
y ' 0 cos

z ' 0 sin

0
1

R-1 = 0 cos
0 sin
0
x 1
y 0 cos

z 0 sin

0 x
sin y
cos z

0
sin = RT
cos
0
sin
cos

x '
y '

z '

Or

x
x'
y R y '
x

z
z '

Ry =

cos
0

0 sin
1
0

sin 0 cos

Rotation about y-axis

cos
sin
Rz =
0

sin
cos
0

Rotation about z-axis

0
0

Example 3.5: Rotation in 3D Space

The box shown in Figure 3.26(A) will demonstrate rotation about an


axis in 3D space. The box shown in the figure is at the initial
starting point for all three rotations. The labeled points of the box
listed in matrix format (see Sec. 3.3) are used with the
transformation rotation matrices, equations (3.37), (3.39), and
(3.40), to obtain the new coordinates after rotation (rotations are in a
counterclockwise direction in this example)

Solution:
C A

B C

x
G y
z

0 0 0 2 2 2 0 2

[C]= 0 1 1 1 0 0 0 1
0 1 0 0 0 1 1 1

Rotation about the x Axis:

[C * ] [ R ] [C ]

[C*]=

3
2
1
2

0 0 0 2 2 2 0 2

1 0 1 1 1 0 0 0 1

2 0 1 0 0 0 1 1 1

3 1

2 2

3
2

3
2

3 1

2 2

0 1
3

2 2

1
2

1
2

3
2

3
2

3 1

2 2

Rotation about x-axis for 30 degrees.

*
Rotation about the y Axis: C R y C

3
2

[C*]=

1
2

0 1

1

2 0

0 0

0
3
2

0
1
1

0
1
0

2
1
0

2
0
0

2
0
1

1
3
2

3
2

3
1
2

3
2

3
1
2

2
1
1

0
0
1

1
3
2

Rotation about y-axis for 30 degrees

C R C
*

Rotation about the z Axis:

1
0
2

3
0

2
0 1

3
2
1
2
0

[C*] =

0 0 0 2 2 2 0 2
0 1 1 1 0 0 0 1

0 1 0 0 0 1 1 1

1
2

1
2

1
2

3
2

3
2

3
2

1
0

3 0

1
3
2

1
1

Rotation about z-axis for 30 degrees

3.15 3D Reflection and mirror imaging

An example for symmetry

Reflection about the x-y plane is given:

Reflection about the y-z plane is given:

Reflection about the x-z plane is given:

1
0
Rr
0

0 0 0
1 0 0
0 1 0

0
1
0
0

0
0
1
0

0
0
0

1 0
0 1
Rr
0 0

0 0

0
0
1
0

0
0
0

1
0
Rr
0

Example : Building of a Block


Symmetry is the similarity between two objects with
respect to a point or a line or a plane. Dimensions of the
object with measured from the symmetric plane will be
equal for both the object. One object look similar to the
mirror image of the other assuming that the central plane
acts as a mirror. This concept of symmetry and mirroring
are widely used in design and modeling field to reduce
model creation time. Use reflection to simplify the
creation of the block shown in

Coordinate description using a quarter portion of the block.

Solution:
C1 a b

c d

1
2

1
2

1
2

1
4
1
2

h i

1
2
1
2
1
2
1

1
2
1
2

1
2

1
4
1
2
1
2
1

1
4

1
2

1
2

1
4

1
2
1

1
2
1

m n

Step 1: Establish the transformation matrix to reflect the quarter block about the x-y plane
1
0
[C*] = CR1 = C
0
0

0 0
1 0
0 1
0 0

0
0

0
1

C
*

1
2

1
2

1 1 0
1

1
2
1
1
0
2
2
1
0 1 1
2
1 1 1
1
0

1
4
1
2

1
2
1
2

1
2

1
4
1
2
1

2
1

1
4

1
2

1
2

1
4

1
1 1
2
1 1
1

1

2
1

Half block obtained by reflection about the xy plane

Step 2: Reflect the half portion of the block about the y-z plane

C
**

1
0
R2C a
0

0
1
0
0

0
0
1
0

0
0
C
0

C
Ca *
C
Reflection of half portion of the block about yz plane.

0 1 1 0 0 1 1 1 0 1 1 1 1 1

2
2
4
2
2
4
4 2
2
4

0
[C c ]

1
2

1
2

**

[Cc* ]
**

1
2

1 1
1

C * *

C**
C

**
C C*

1
0
2

0
1
2

1
2
1
2
1

1
4
1
2

0 1

1
2
1
2
1

2
1

1
2

1
2

1
2
1
2

1
2

1
2
1
2
1

1
4
1
2
1

2
1

1
4

1
2

1
1

2
1

1
2
1

1
2

1
1
2
1

1
4

1
1

2
1

3.16 3D TRANSLATION

z ' z z
x' x x
y ' y y
1 0 0 x
0 1 0 y
RT =

0 0 1 z

0
0
0
1

C * RC

Example : Translation of a Block in 3D

Using the same box of Figure in Example 3.5,


translate the box 2 units in the x direction, 1 unit in
the y direction, and 1 unit in the z direction.

Solution:
Using previous equation, we substitute the numerical values into the
translation matrix and apply equation C * RC to find the new
coordinates of the points after translation. We know x=2, y=1,
and z=1. The new coordinates of the box are
1
0
C *
0

0
1
0
0

0
0
1
0

2
1
1

2 2 2 4
1 2 2 2
*
C
1 3 1 1

1 1 1 1

0
0

0
1
2
1

0
1
0
1

4 4 2
1 1 1
1 2 2

2
1
0
1

1 1 1

2
0
0
1

2
0
1
1

0
0
1

3.17 3D ROTATION ABOUT AN ARBITRARY AXIS

Transformation matrix could be achieved through


a procedure as described below:
1. The object is translated such that the origin of
coordinates passes through the line
2. Rotation is accomplished
3. The object is translated back to its origin

Rotation about an arbitrary axis can be classified into 3 types


1) Axis of rotation parallel to any one of the coordinate
axes.

Rotation about a parallel axis

Translation of axis to coordinate axis

2. Axis passing through origin and not parallel with any


coordinate axis.

Rotation about an axis passing through origin

3. Arbitrary line not passing through the origin and not


parallel to any of the coordinate axis.

Rotation about an axis not passing through origin

If we concatenate the three foregoing transformation matrices, we obtain:

C * Rt1Rr Rt 2C
where
1 0
0 1
Rt1
0 0

0 0
where

0 x
1
0
0 y
Rt 2
0
1 z

0
0
1

S1 sin ,

0
1
0
0

0 x
0 y
1 z

0 1

C2C3 C1S3 S1S 2C3


C S C C S S S
Rr 2 3 1 3 1 2 3
S2
S1C2

0
0

S 2 sin , S 3 sin .

C1 cos , C2 cos , C3 cos ,

S1S3 C1S 2C3


S1C3 C1S 2 S3
C1C2
0

0
0
0

Rr Rx Ry Rz

Successive rotation of x, y, z by , , .

Example : Rotation of a Box in 3D Space

Using the box of Figure in Example 3.5, find the new


coordinates of the box if it is rotated 30 degrees about the
x-axis, 60 degrees about the y-axis, and 90 degrees about
the z-axis. (Rotations are in the counterclockwise
direction.) The rotations of the coordinate reference
frames are illustrated in Figure 3.21. x, y, and z
indicate the new coordinate system where the box resides
[C*].

Solution:
C * C R

where

0
0
C
0

0
1
0
1

0
1
1
1

0
0
1
1

2
1
0
1

2
0
0
1

2
0
1
1

2
1
1

And substituting =30, =60, and =90

1
R 2
3

2
0

3
2
3

4
1

4
0

1
2
3
4
3
4
0

The final answer is

1
C 2
3

2
0

3
2

3
2
3

4
1

4
0

1
2
3
4
3
4
0

1
3

2 2

0 0

0
0 1

0 0 0 2 2 2 2
1 1 0 1 0 0 1
0 1 1 0 0 1 1

1
2

3
2

1 1 1 1 1 1 1

C
*

3
1
4

3
4

1
3
4

3 3

4 4

3
4

1 3 3

4
4

1
2

1
3

2 2

1
4

1
3


4 4

3 3
4

1 5 3

4
4

Example : Rotation and Translation of a Cube in 3D Space


Given the unit cube shown as follows, find the
transformation matrix required for the display of the cube

Initial position of the cube

Step1: Place the points in matrix form.

0
1
C
1

1
1
1
1

1
1
0
1

0
1
0
1

0
0
1
1

1
0
1
1

1
0
0
1

0
0
0

Rotation about x-axis

Step 2: Rotate the cube +90 degrees about the x-axis

0
0
1
0 cos 90 sin 90
Rs1
0 sin 90 cos 90

0
0
0

0
0
0

Rotation about y-axis 1

Step 3: Rotate the cube +90 degrees about the y-axis


cos 90

Rs 2
sin 90

0 sin 90 0
1
0
0
0 cos 90 0

1
0
1

By combining the transformation matrices, we have

C * Rs1 Rs 2C
The final answer is

1
0
*
C
0

1
1
0
1

0
1
0
1

0 1 1
0 0
0 0 1 1
0
0 1 1 1 1

1 1 1 1 1

Example : Pyramid Rotation and Translation


Give the concatenated transformation matrix that would generate
the new position of the object shown in Figure 3.41. (Face A
given by points ABCD lies in the x-z plane with its center along
the x-axis.)

Initial position of the pyramid

Solution:
Step1: Determine the matrix to rotate the pyramid
along the x-axis by 90 degrees
0
0
1
0 cos 90 sin 90
R1
0 sin 90 cos 90

0
0
0

Rotation about the x-axis for 90 degrees

Step 2: Determine the matrix to translate the object h


units along the x-axis
1 0 0 h
0 1 0 0

R2
0 0 1 0

0 0 0 1

Translation along the x-axis for h units

Step 3: Rotate the object 90 degrees about the z-axis


cos 90 sin 90
sin 90 cos 90
R3

0
0

0
0

0 0
0 0
1 0

0 1

C R R R C
*

Rotation about the z-axis for 90 degrees

3.18 3D VISUALIZATION
3.19 TRIMETRIC PROJECTION
C * RC
3

3 0

Rotation
0

matrix
0


0
0 1
0

3 0

Rotation
0

matrix
0

0
0 1
0
3

1 0 0 0
0 1 0 0
0 0 0 0

0 0 0 1

1
0

0
1
0
0

0
0
0
t

0
0
0

(For z=0)

If we were to project the object onto x=0 or x=r plane, the projecti
matrix takes the following form:
0 0 0 0
0 1 0 0

R
0 0 1 0

0
0
0
1

(For x=0)

0 0 0 r
0 1 0 0

R
0 0 1 0

0
0
0
1

(For x=r)

In a similar fashion, the projection onto the y=0 or y=s plane is


1 0 0 0
0 0 0 0

R
0 0 1 0

0
0
0
1

(For y=0)

1 0 0 0
0 0 0 s

R
0 0 1 0

0
0
0
1

(For y=s)

Consider the following transformation :


1
0

0 0 0
1 0 0
0 1 0


p q r 1

y
y

z
z

1
px qy rz
1

px qy rz 1 0 defines the equation of a plane

In the case where q = 0 and p = 0, the equation becomes rx +1 = 0


and the distance from the origin is D = 1/ r. Therefore for a projection
onto a plane defined by as x = a, the projection matrix is

0 0 0
0
1 0 0
0
0 1 0

1/ a 0 0 1

R *C

x
y

0
y

x 1
1
a

The equation of the plane x=a can also be written as

x
1 0
a

In order to normalize the representation of C matrix and have the


last element equal to 1 we need to substitute the above
( 0 y z -x/r+1) by moving the geometry such that all coordinates
have x=r and y and z are kept unchanged. Therefore,

Cnew

x r
y

Example : Projection on a Plane

Determine the projection of box in (a) x=6, (b) y=6, and (c) z=6.
Solution:
C A B C
0
0
C
0

0
1
0
1

0
1
1
1

0
0
1
1

2
1
0
1

D
2
0
0
1

E
2
0
1
1

2
1
1

(a) The projection of the box on x=6 plane (see Figure 3.46) has the
following transformation matrix:
0
0
R
0

6
0
0
*
C
0

0
1
0
0

0
0
1
0

6
0
0

0 0 6
1 0 0
0 1 0

0 0 0 0 2 2 2 2
0 1 1 0 1 0 0 1

0 1 1 1 0 0 1 1

0 0 1 1 1 1 1 1 1 1 1

6 6 6 6
0 1 1 0
*
C
0 2 0 1

1 1 1 1

C R C

6 6 6 6

1 0 0 1
0 0 1 1

1 1 1 1

(b) The projection of the box on the y=6 plane has the following
transformation matrix:
1
0
R
0

0
0
0
0

1
0
*
C
0

0 0 0
0 0 6
0 1 0

0
0
1
0

0
6
0

Therefore, the coordinates for the projection are

0
6
*
C
0

0 0 0 0 2 2 2 2
0 1 1 0 1 0 0 1

0 0 1 1 0 0 1 1

0 0 1 1 1 1 1 1 1 1 1
0
6
2
1

0
6
1
1

0
6
1
1

2
6
0
1

2
6
0
1

2
6
1
1

2
6
1

(c) The projection of the box on the z=6 plane has the following
transformation matrix:
1
0
R
0

0
1
0
0

0
0
0
0

0
0
6

Therefore, the coordinates for the projection are


C * R C

1
0
*
C
0

0
0
0
*
C 6

0 0 0 0
1 0 0 0
0 0 6 0

0 0 1 1
0 0 0 2
1 1 0 1
6 6 6 6
1 1 1 1

0 0 0 2 2 2 2
1
0
1
2
0
6
1

1
1
1
2
0
6
1

2
1

0 1 0 0 1
1 0 0 1 1

1 1 1 1 1

Projection on the plane z=6

3.20 ISOMETRIC PROJECTION

1.
2.
3.
4.
5.

Combined rotations followed by projection from infinity form the


bases for generating all axonometric projections. We perform the
following:
Rotate about the y-axis
Rotate about the x-axis
Project about the z=0 plane
Apply the final transformation conditions of foreshortening all axes
equally
Get the final transformation matrix to yield the isometric view

Isometric view

Consider a point P given by (x y z 1). Let us find the isometric


projection of this point while using the previous definitions. Operating
on P by and , we get
x*
*
y
z*

1

1
0

0
cos

0
sin

0 sin

0
0

cos
0

0 cos
0 0
0 sin

1 0

0 sin
1
0
0
0

cos
0

0 x
0 y
0 z

1 1

where [x* y* z*] represents the coordinates of the rotated point P about
the y and x axes. The concatenated transformation matrix is given by
cos
0
R
sin

sin sin
cos
cos sin
0

sin cos
sin
cos cos
0

0
0
0

Suppose point P denotes different unit vectors along the x, y, and z-axes.
Hence alone x, we have [1 0 0 1],
x*

*
y

R
*
z

x* cos

1
0

*
where y sin sin

z * sin cos

If we consider the unit vector along the y-axis, it transforms into

x*

y*
R
*

0
1

0

x* 0
where

y * cos

z * sin

nx

ny
nx

x y z
* 2

* 2

* 2

cos 2 sin 2 sin 2

x y z
x y z
* 2

* 2

* 2

* 2

* 2

* 2

and then
2
sin

2
nx n y sin
1 sin 2

1 2 sin 2
n y nz sin
1 sin 2
2

cos
2

sin 2 cos 2 sin 2

Using trigonometric relationships and the method of


substitution, we can solve for and which yield
=35.26, =45. We can then conclude that given
geometry in 3D represented by [C}, its isometric projection
is obtained by premultiplying it by R with and being
35.26 and 45 respectively. The resulting [C*] represents
the projection for which we are looking.

You might also like