You are on page 1of 72

CHAPTER 3

TRANSFORMATION

This chapter discusses the transformation in both 2D and 3D environment. Then, it

will follow with the discussion on the compound transformation. The discussion

proceeds with the application of transformation in the projection for visualization

purposes. Finally, the discussion on the application of transformation in animation

and modelling are followed.

3.1 2D AND 3D TRANSFORMATION MATRIX

Transformation has been used widely in any geometric modeling. Moving a circle on

a screen requires transformation matrix, or even displaying the solid object also

requires transformation matrices.

In CAD, the transformation matrix will be applied to geometrical properties of

the entities such as coordinates of the vertex. The geometrical properties can be

represented in three forms; Cartesian coordinate, vector coordinate, and homogenous

coordinate. Table 3.1 shows the representation of all the coordinate systems.

Table 3.1: Coordinate System

Type 2D 3D

Cartesian Coordinate (x,y) (x, y, z)

3-1
Vector Coordinate  x  x
[x y] or  
 y [x y z] or  y 
 
 z 

Homogenous Coordinate  x  x
 y
[x y 1] or  y 
  [x y z 1] or  
 1  z
 
1 

In the case of applying transformation matrix to the geometrical properties,

homogenous coordinate system is the suitable representation. The third axis for 2D

and fourth axis for 3D are in fact the homogenous axis. Basically, all the coordinates

can be scaled individually on this axis. As in the above example, the homogenous

coordinate is set to 1, it shows the scaling factor along the homogenous axis is 1 and

therefore, it will maintain its original coordinate system. Moreover, the introduction

of homogenous coordinates allows the matrix calculation to be carried out and

therefore, calculation related to geometrical properties will be easier to be done.

a1 a 2 a3
x' y ' 1  x y 1b1 b2 b3 … (3.1)
 c1 c 2 c3

Where x' y' 1 : homogenous representation of the coordinate after

application of the transformation

x y 1 : Homogeneous representation of the original coordinate

a1 a 2 a3
b1 b2 b3 : Matrix
 
 c1 c2 c3

3-2
Equation 3.1 shows the calculation using matrix. The matrix is applied to

coordinate [x y 1] and as a result, coordinates [x’ y’ 1] are the resulted of the

application of the matrix to [x y 1].

Matrix in Eq 3.1 can be replaced with transformation matrix. As a result, Eq.

3.2 ca be applied to 2D (2D).

x' y' 1  x y 12 D  … (3.2)

Where: 2 D : 2D transformation matrix

Similarly, Eq 3.3 is applicable to 3D coordinate system

x' y' z ' 1  x y z 13D  … (3.3)

Where: 3 D  : 3D transformation matrix

Similarly, the application of the transformation can have in other format as in

Eq. 3.4 and 3.5.

 x'  x
 y '    y  … (3.4)
  2D  

 1   1 

 x'  x
 y '  
   3 D  y  … (3.5)
 z' z
   
1 1 

In this book, format as in Eq 3.2 and 3.3 are used. 2D transformation is 3 x 3

matrix format, whilst 3D transformation is 4 x 4 matrix format. In Eq 3.2 and 3.3,

there is only one vertex is used in the calculation, however in practical more vertices

3-3
are required. Therefore, Eq 3.2 and 3.3 are expanded to Eq. 3.6 and 3.7 to cater n

vertices.

 x'1 y '1 1  x1 y1 1
 x' y '2 1  x2 y2 1
 2    … (3.6)
 ...   ...  2D
   
 x 'n y 'n 1  xn yn 1

Where x’i, y’i: 2Dcoordinate of i vertex after application of transformation

xi, yi: 2D coordinate of i vertex before application of transformation

 x'1 y '1 z '1 1  x1 y1 z1 1


 x' y '2 z '2 1  x2 y2 z2 1
 2    … (3.7)
 ...   ...  3D
   
 x 'n y 'n z 'n 1  xn yn zn 1

Where x’i, y’i, z’i: coordinate of i vertex after application of transformation

xi, yi, zi: 3D coordinate of i vertex before application of transformation

Prior to apply the matrix transformation, the model can be represented into

homogenous matrix format. Following in Table 3.2 shows the representation of

entities into their matrix representation.

Table 3.2 Matrix representation of the sample entities

Entities Matrix Representation

10 20 1
20 20 1

30 30 1
 
30 20 1

3-4
 0 0 10 1
10 0 0 1
 
 0 10 0 1

(0,1,1)
0 0 0 1
(1,1,1)
1 0 0 1 

(0,0,1)
1 1 0 2
(0,1,0)
 
... ... ... ...
Z
Y (1,1,0)
 1 1 1 1 
(0,0,0)
X (1,0,0)

3.2 FORMS OF TRANSFORMATION

This section discusses the matrix of the selected transformation. The application of

the transformation matrix will be similar regardless whether the 2D or 3D

transformation. However, there are two differences between them, especially when

the transformation requires reference. The first one, when 2D transformation requires

a point as the reference, the same 3D transformation will require axis. The second one

is when 2D transformation requires axis, the same 3D transformation requires plane.

Figure 3.1 graphically illustrates the differences.

3-5
Figure 3.1 Differences between the reference of 2D and 3D transformation

3.2.1 Translation

Translation will move one entity to another position. Figure 3.1 shows the translation

of 2D and 3D entities as well as the initial and final coordinates. Mathematically, Eq

3.8, 3.9, and 3.10 can be used to calculate the position after translation is applied.

Figure 3.1 Translation of 2D and 3D entities

x'  x  x … (3.8)

y '  y  y … (3.10)

3-6
z '  z  z … (3.11)

where x, y, z: translation based on the respective axis.

The matrix representation for translation will be as follows

1 0 0
T2 D   0 1 0 …(3.12)
x y 1

1 0 0 0
0 1 0 0
T3 D  …(3.13)
0 0 1 0
 
x y z 1

3.2.2 Rotation

Rotation is a process to rotate an entity about rotation center. To rotate 2D entity, the

rotation center will become the reference, whilst for 3D rotation, the reference for

rotation will be an axis. Eq 3.14 and 3.15 will calculate the position of the vertex after

rotation is applied on 2D entities and Figure 3.2 illustrates the 2D rotation. The center

of rotation for both equation is at (0, 0)

x'  x cos( )  y sin(  ) … 3.14

y '  x sin(  )  y cos( ) … 3.15

3-7
Figure 3.2 Rotation about a vertex

In the case of 3D rotation, the rotation is carried out on axis, x, y, and z axis.

The equation to calculate the position of the final entity after the rotation is applied

according to the axis is as the following.

X Axis: x'  x … 3.16

y '  y cos( )  z sin(  ) … 3.17

z '  y sin(  )  z cos( ) … 3.18

Y Axis: x'  z sin(  )  x cos( ) … 3.19

y'  y … 3.20

z '  z cos( )  x sin(  ) … 3.21

Z Axis: x'  x cos( )  y sin(  ) … 3.22

y '  x sin(  )  y cos( ) … 3.23

z'  z … 3.21

These equations can form the following 2D and 3D matrices are as the

following:

2D rotational matrix

 cos  sin  0
R2 D   sin  cos  0 …(3.22)
 0 0 1

3D rotational matrix: X axis

3-8
1 0 0 0
0 cos  sin  0
R3 D X  …(3.23)
0  sin  cos  0
 
0 0 0 1

3D rotational matrix: Y axis

cos  0  sin  0
 0 1 0 0
R3 DY  …(3.24)
 sin  0 cos  0
 
 0 0 0 1

3D rotational matrix: Z axis

cos  sin  0 0
 sin  cos  0 0
R3 DZ  …(3.25)
 0 0 1 0
 
 0 0 0 1

All the equations (Eq 3.14 – 3.21) and matrices (Eq 3.22 – 3.23) are based on the

assumption the center of rotation are at origin (0, 0) for 2D rotation and at the

principal axis for 3D rotation. Any rotation that is carried out other than the origin for

2D and the principle axis for 3D, the rotational center should be transformed to the

reference center point or principal axis. Therefore, translation should be carried out to

transform the reference as the center or axis of rotation before applying the rotational

matrix.

The calculated vertices when rotation is applied is based on center or axis of the

translated one. However, rotation should be carried on the specified vertex or axis,

and therefore, the calculated vertices should be translated back to ensure rotation is

based on the actual the center or axis.

3-9
In all, any rotation that is not at the center point for 2D or principal axis for 3D,

translation is firstly carried out to make the reference point to be either center or

principal axis and it is followed with the application of the rotation transformation.

Finally, translation is carried out to make the calculated vertices to be referred to their

earliest origin. Therefore, the procedure will be as follows:

i. Translate the center or axis of rotation to its origin vertex or principle axis.

In the case of 2D, the coordinate of rotation center will be used as the reference,

whilst in the case of 3D, any vertex on the axis can be used as the reference. Let say,

the actual center of rotation is (x, y) and any point of the axis of rotation is (x, y, z).

The translation should be done to ensure (x, y) turns to (0, 0) and (x, y, z) turns to (0,

0, 0), therefore the translation matrix will be the negative value of every coordinate as

such x and y for 2D will be deducted by the value x and y for 2D translation and

additional z will be deducted by the value of z for 3D translation.

The translation matrix before the application rotational matrices is

1 0 0
2D 
T2 D1   0 1 0 … (3.26)
 x  y 1

1 0 0 0
0 1 0 0
3D T3 D1   … (3.27)
0 0 1 0
 
 x  y  z 1

Therefore, the original vertices (xi, yi) for 2D entities and (xi, yi, zi) for 3D entities will

be translated to (x’i, y’i) and (x’i, y’i, z’i) respectively using 3.27 and 3.28 for 2D and

3D translation respectively.

3-10
 x'1 A y'1 A 1  x1 y1 1
 x' y'2 A 1  x2 y2 1
 2A  2 D1  … (3.28)
 ...   ... 
   
 x'nA y'n A 1  xn yn 1

 x'1 A y '1 A z '1 A 1  x1 y1 z1 1


 x' y '2 A z '2 A 1  x2 y2 z2 1
 2A    … (3.28)
 ...   ...  3 D1
   
 x'nA y 'nA z 'nA 1  xn yn zn 1

This translation process will make the reference center point and principle axis to

become (0, 0) and (0, 0, 0) respectively and this causes the rotational transformation

can be carried out in step (ii).

ii. Apply the rotation matrix

As the translation matric converts the center point to (0, 0) for 2D or (0, 0, 0) for

3D, rotation can be applied to the entities. Eq 3.29 and 3.30 calculates the vertices

when rotation matrix is applied that will transform (x’A, y’A) or (x’A, y’A, z’A) to (x’B,

y’B) or (x’B, y’B, z’B), respectively.

 x'1B y'1B 1  x'1 A y'1 A 1


 x' y '2 B 1  x'2 A y'2 A 1
 2B  R  … (3.29)
 ...   ...  2D
   
 x'nB y'nB 1  x'nA y'nA 1

 x'1B y '1B z '1B 1  x'1 A y'1 A z '1 A 1


 x' y '2 B z '2 B 1  x'2 A y '2 A z '2 A 1
 2B  R  … (3.30)
 ...   ...  3D
   
 x'nB y 'nB z 'nB 1  x'nA y 'nA z 'nA 1

iii. Apply translation to compensate the application the first translation

3-11
In step I, the application of the translation matrix will translate all the

coordinates to its original position with the intention to make the center of rotation

will be at its origin or principle axis. Therefore, at this step, it will translate back all

the coordinates to their original position. Therefore, translation matrix is applied that

has the negative value of the translation applied in step 1.

The translation matrices are as follows:

1 0 0 
2D T2 D2  0 1 0 … (3.31)
 x y 1

1 0 0 0 
0 1 0 0
3D T3 D2   … (3.32)
0 0 1 0
 
 x y z 1

The final vertices can be calculated using Eq 3.32 and 3.31 that will translate

(x’B, y’B) or (x’B, y’B, z’B) to (x’C, y’C) or (x’C, y’C, z’C) to (x’C, y’C) or (x’C, y’C, z’C).

 x'1C y'1C 1  x'1B y'1B 1


 x' y '2 C 1  x'2 B y '2 B 1
 2C  T  … (3.33)
 ...   ...  2 D 2
   
 x'nC y'nC 1  x'nB y'nB 1

 x'1C y'1C z '1C 1  x'1B y '1B z '1B 1


 x' y '2 C z '2 C 1  x'2 B y '2 B z '2 B 1
 2C  T  … (3.34)
 ...   ...  3 D 2
   
 x'nC y'nC z 'nC 1  x'nB y 'nB z 'nB 1

Example 3.1

a) Create the transformation matrices when shape is rotated by 35o in counter

clockwise direction and point (4, 5) is the center of rotation,

3-12
b) Calculate the transformed vertices if the polygon with the following vertices

are been transformed using the similar rotation in (a). The vertices are (10, 8),

(16, 8), and (13, 13).

Solution

(a) Since the shape is not rotated at (0,0), the translation must be applied before

and after the rotation matrix.

Therefore, the compound matrix will be

   T RT  ,
comp 1 2

1 0 0

T1   0 1 0
 4  5 1

Dx = -4 and Dy = -5 to make rotation point transform from (4, 5) to (0,0)

 cos 35o sin 35o 0


 
R   sin 35o cos 35o 0
 0 0 1

Rotation can be applied once the origin is transformed into (0, 0)

1 0 0
T2  0 1 0
4 5 1

Dx = 4 and Dy = 5 to make rotation point transform from (0, 0) to its original

coordinate (4,5)

As a result the compound transformation matrix will

3-13
1 0 0  cos 35o sin 35o 0  1 0 0 
 
comp   0 1 0  sin 35o cos 35o 0 0 1 0
 4  5 1  0 0 1 4 5 1
 0.819 0.574 0
  0.574 0.819 0
 3.591  1.39 1

(b) The homogenous representation of the polygon will be

10 8 1
P
polygon   16 8 1
13 13 1

As a result, the final vertices after the transformation will be

 x1 ' y1 ' 1
x '
 2 y2 ' 1 
 Ppolygon comp 
 x3 ' y3 ' 1
10 8 1  0.819 0.574 0
 16 8 1  0.574 0.819 0
13 13 1  3.591  1.39 1
 7.2 10.9 1
 12.1 14.3 1
 6.8 16.7 1

Therefore, the respective transformed vertices will be (7.2, 10.9), (12.1, 14.3), and

(6.8, 16.7) and Figure 3.3 illustrates the process of the rotation graphically

3-14
Figure 3.3 Example 3.1

3.2.3 Mirror

Mirror is similar to process of sitting in a mirror, the reflection inside the mirror is

actually the result of the mirroring process. In 2D, x and y axis are used as mirror and

in 3D plane, plane xy, yz, and xz will become the mirror.

Eq 3.35 and 3.36 are the matrices for 2D mirror.

1 0 0
X axis M 2D X  0  1 0 … Eq 3.35
0 0 1

  1 0 0
Y axis M 2 D Y   0 1 0 … Eq 3.36
 0 0 1

Eq 3.36 – 3.38 are the matrices for 3D mirror based on the plane.

3-15
1 0 0 0
0 1 0 0
Plane XY T3 D  XY  … (3.37)
0 0 1 0
 
0 0 0 1

 1 0 0 0
0 1 0 0
Plane YZ T3 D YZ  … (3.38)
0 0 1 0
 
0 0 0 1

1 0 0 0
0  1 0 0
Plane XZ T3 D  XZ  … (3.39)
0 0 1 0
 
0 0 0 1

In mirror process, the mirror axis or planes are based on the principle axis. If the

mirror axis or planes are not based the principle axis, translation matrix should be

before to allow the mirror axis and plane to set on principle axis and after to convert

the coordinates to their original coordinates.

In 2D mirror process, the axis can translated into straight line equation as in the

following.

X axis y=0 … (3.40)

Y axis x=0 … (3.41)

Therefore, if the mirror process is carried out using axis other than X or Y axis,

the mirror axis must be converted into X or Y axis that is having straight line equation

as in equation 3.40 or 3.41 respectively. This is done by applying the translation

matrix before mirror process can take place. This translation process will convert the

mirror axis as X or Y principle axis.

If the mirror axis is parallel to X axis, the equation of the mirror axis will
3-16
y = Cx … (3.42)

where Cx: constant

Therefore, to convert the mirror into X principle axis, translation matrix as in

equation 3.43 is applied.

1 0 0

T2 DX 1  0 1 0 … (3.43)
0  Cx 1

Then, the mirror can be applied as the mirror axis is equal to X principle axis.

After that translation will be applied to convert all the coordinates to its original

position. The translation matrix after the mirror will be as in equation 3.44.

1 0 0
T2 DX  2  0 1 0 … (3.44)
0 Cx 1

In the case of the mirror axis is parallel to Y axis, the equation for mirror axis

will be as in equation 3.45.

x = Cy … (3.45)

where Cy : constant

Therefore, translation by –Cy is carried out on x coordinate to change the mirror

axis as principle y axis (or x = 0). Equation 3.46 will convert all the coordinates.

 1 0 0
 
T2 DY 1   0 1 0 … (3.46)
 C y 0 1

3-17
Then, mirror process using Y principle axis is carried out. It will be followed

with translation using equation 3.47 to make all the entities referred to their original

coordinate system.

1 0 0
 
T2 DY  2 0 1 0 … (3.47)
C y 0 1

Similarly, in the case of 3D mirror, translation before (T3D-1) and after ((T3D-2)

should be applied to homogenous matrix if the mirror plane is parallel to XY, YZ, or

ZX plane. The translation matrices are as follows

Parallel to XY plane: z coordinate is constant (Zxy)

1 0 0 0
0 1 0 0
T3 D  XY 1   …(3.48)
0 0 1 0
 
0 0  Z xy 1

1 0 0 0
0 1 0 0
T3 D  XY  2  … (3.49)
0 0 1 0
 
0 0 Z xy 1

Parallel to YZ plane: x coordinates is constant (Xyz)

 1 0 0 0
 0 1 0 0
T3 D YZ 1   …(3.50)
 0 0 1 0
 
 X yz 0 0 1

 1 0 0 0
 0 1 0 0
T3 DYZ 2  … (3.51)
 0 0 1 0
 
 X yz 0 0 1
3-18
Parallel to ZX plane: y coordinates is constant (Yzx)

1 0 0 0
0 1 0 0
T3 D  ZX 1   …(3.52)
0 0 1 0
 
0  Yzx 0 1

1 0 0 0
0 1 0 0 
T3 D  ZX  2   … (3.53)
0 0 1 0 
 
0 Yzx 0 1

However, the above matrices cannot be applied to non-parallel mirror axis or

plane as shown in Figure 3.4. Mapping or compound matrices of rotation and

translation are required. The non-parallel mirror axis or plane will be discussed

mapping matrix and compound matrix.

Figure 3.4 Non-parallel mirror axis or plane

Example 3.2

A triangle with A (1,1), B (1,3) and C (2,2) has been subjected to the following

transformation. Answer the following questions.

3-19
a) Write homogenous representation of the triangle.

b) Write the composite transformation matrices when mirror is applied to the

triangle using axis x = 0 and the calculated the vertices after the mirroring

process is carried out

c) Write the composite transformation matrices when mirror is applied to the

triangle using axis x = -2 and the calculated the vertices after the

mirroring process is carried out

Solution

a. The homogenous representation of the triangle is

1 1 1
P 
triangle  1 3 1
2 2 1

b. Mirror axis x = 0 is similar to mirror axis at Y principle axis, therefore the

mirror matrik will be

  1 0 0
M 2 D Y   0 1 0
 0 0 1

Therefore, the vertices after being mirrored are

3-20
 x1 ' y1 ' 1
x '
 2 y2 ' 1  
 Ptrianlg e M 2 DY 
 x3 ' y3 ' 1
1 1 1  1 0 0
 1 3 1  0 1 0
2 2 1  0 0 1
  1 1 1
   1 3 1
 2 2 1

Therefore A’ (-1, 1), B’ (-1, 3), and C’(-2, 2). Figure 3.5a illustrates graphically

the mirroring process.

c. When mirror axis x = -2, the mirror must be converted to x = 0 by translation

x = 2 before the mirroring process. After the mirroring process, it will be

converted to its original coordinate by translation x = -2, therefore the mirror

matrik will be

 x1 ' y1 ' 1
x '
 2  
y 2 ' 1  Ptrianlg e 1 M 2 D Y 2 
 x3 ' y 3 ' 1
1 1 1 1 0 0  1 0 0  1 0 0
 1 3 1 0 1 0  0 1 0  0 1 0
2 2 1 2 0 1  0 0 1  2 0 1
  5 1 1
   5 3 1
 6 2 1

Therefore A” (-5, 1), B”(-5, 3), and C”(-6, 2). Figure 3.5b illustrates graphically

the mirroring process.

3-21
(a)

(b)

Figure 3.5 Example 3.2

3.2.4 Scaling

Scaling is carried out when we need to make certain entity bigger or smaller. The

scaling process is referred to one origin vertex for both 2D and 3D scaling. Figure 3.6

illustrates the concept of scaling graphically. As a result of the scaling, the final

coordinate is proportional to the scale that is applied, and this causes Eq 3.54 to 3.56

can be used calculating the final coordinates.

3-22
Figure 3.6 Scaling concept

x’ = Sx x … (3.54)

y’ = Sy y … (3.55)

z’ = Sz z … (3.56)

Based on these equations, the scaling matrices will be as the following:

S X 0 0
S2 D   0 SY 0 … (3.57)
 0 0 1

S X 0 0 0
0 SY 0 0
S3 D  … (3.58)
0 0 SZ 0
 
0 0 0 1

Matrices in Eq 3.57 and 3.58 indicate the scaling can be done on individual axis.

However, more commonly, the scale for all the axis is equal and therefore both

matrices can be transformed to the following matrices.

3-23
C 0 0
S2 D   0 C 0 … (3.59)
 0 0 1

C 0 0 0
 0 C 0 0
S3 D   … (3.60)
 0 0 C 0
 
 0 0 0 1

Therefore, since the origin of the scaling must be at (0, 0) or (0, 0, 0) for 2D and

3D respectively, translation before and after applying the scaling must be carried out

if the reference vertex for scaling is not at (0, 0) or (0, 0, 0).

Example 3.3

A cube (1 x 1 x 1) as shown in Figure 3.7a is transformed into the solid as shown in

Figure 3.7b. Establish the transformation matrices for this transformation. The scaling

matrix transformation based on reference point of (0, 0, 0) is as in the following and

calculates the vertices after being scaled.

Solution

Figure 3.7 Example 3.3

Solution

3-24
The homogenous representation of the cube is

0 0 0 1
1 0 0 1

1 1 0 1
 
0 1 0 1
M   
0 0 1 1
 
1 0 0 1
1 1 1 1
 
0 1 1 1

To create the shape as in Figure 3.7b, the cube must be firstly scaled by 4 along the Y

axis and then, followed with the translation by x = 4. Therefore, the transformation

will be

comp  S T 
1 0 0 0  1 0 0 0
0 4 0 0 0 1 0 0

0 0 1 0 0 0 1 0
  
0 0 0 1 4 0 0 1
1 0 0 0
0 4 0 0

0 0 1 0
 
4 0 0 1

The vertices after being transformed will

3-25
M '  M Tcomp 
0 0 0 1
1 0 0 1

1 1 0 1 1 0 0 0
 
0 1 0 1 0 4 0 0

0 0 1 1 0 0 1 0
  
1 0 0 1 4 0 0 1
1 1 0 1
 
0 1 1 1
4 0 0 1
5 0 0 1

5 4 0 1
 
4 4 0 1

4 0 1 1
 
5 0 0 1
5 4 0 1
 
4 4 1 1

3.2.5 Shearing

Shearing is a process to translate entity along certain axis and the amount of

translation increases linearly based on the height of point above the reference axis.

Figure 3.8 Shearing

If the shearing is carried out along the X axis, any point on X principle axis will

not be translated. The point above the X principle be translated linearly by a product

of a constant  and y coordinate. Therefore, the new x coordinates can be calculated

3-26
using equation 3.61, whilst there is no change in y coordinate. This is graphically

illustrated in Figure 3.8a.

X axis: x '  x  y … (3.61)

y'  y … (3.62)

Figure 3.8b illustrates the similar shearing process along the Y axis. Hence, the

transformation of coordinates can be calculated using equation 3.63 and 3.64.

Y axis: x'  x … (3.63)

y '  x  y … (3.64)

Therefore, the 2D shear transformation matrices are as follows:

Shearing along X axis.

 1 0 0
Sh2 DX   1 0 … (3.65)
 0 0 1

Shearing along the Y axis.

1  0
Sh2 DY  0 1 0 … (3.66)
0 0 1

In 3D, the shearing process can be done along the x axis, y axis, or z axis. If the

shearing is carried out along the plane XY, translation will be carried out along the X

and Y axis and at the same time, z coordinate will be maintained. Therefore, the

following equation will calculate the translated coordinate

Plane XY x'  x  z … (3.67)

3-27
y '  x  z … (3.68)

z'  z … (3.69)

The shearing matrix will be as in equation 3.70

1 0 0 0
0 1 0 0
S3 DXY  … (3.70)
  1 0
 
0 0 0 1

In similar manner, the shearing matrires along plane XZ and YZ will be as


the following

1 0 0 0
 1  0
Plane XZ: S3 DXZ  … (3.71)
0 0 1 0
 
0 0 0 1

Where:  is constant for translation along X axis

is constant for translation along Z axis

1   0
0 1 0 0
Plane YZ: S3 DYZ  … (3.72)
0 0 1 0
 
0 0 0 1

Where:  is constant for translation along Y axis

is constant for translation along Z axis

Example 3.4

Profile A to L forms a letter M as shown in Figure 3.x. The intention is to draw an

italic M, which vertical line is slanted by 15o. Based on shearing transformation

matrix, calculate all the respective points that form the italic letter M.

3-28
Figure 3.9 Profile M

Solution

Firstly, letter M profile must be represented as its homogenous representation

0 0 1
0 40 1

10 40 1
 
20 30 1
30 40 1
 
M   
40 40 1
40 0 1
 
30 0 1
30 25 1
 
20 15 1
 
10 25 1
10 0 1

Then calculate the shearing factor

x'  x  y sin( 15o )


y'  y

Therefore,  = sin (15o) and the shearing matrix is

 1 0 0
Sh2 DX  sin( 15 ) 1 0
 o

 0 0 1
3-29
The italic M vertices are

 1 0 0
M *  M sin( 15 ) 1 0
 o

 0 0 1
 0 0 1
10.4 40 1
 
20.4 40 1
 
 27.8 30 1
40.4 40 1
 
 50.4 40 1
40 0 1
 
 30 0 1
36.5 25 1
 
23.9 15 1
 
16.5 25 1
 10 0 1

3.2.5 Mapping

The application o global and local coordinate systems are been used during

modelling. The need of the local coordinate system is due to the need of drawing

entities on different plane. When the entities are drawn using the local coordinate

system, the coordinates of the vertices will be referred to the local coordinate system.

These entities must maintain the relationship with the global coordinate system and

mapping process will maintain the relationship between two coordinate system.

Figure 3.10 shows the two coordinate systems and point P can be described by

both of the coordinate system. Since currently P is described by principle coordinate

system, mapping matrix will calculate the coordinate of point P when is the referred

to second coordinate system.

3-30
Figure 3.10 Mapping concept

Normally the new coordinate will be rotated and translated, therefore the

mapping matrix comprises of both transformation as shown in the following

equations:

 a11 a21 0
2D Mapping M 2D  a12 a22 0 … (3.73)
 x y 1

 a11 a21 a31 0


a a22 a32 0
3D Mapping M 3D   12 … (3.74)
a13 a23 a33 0
 
 x y z 1

For 2D matrix, a11 – a22 and 3D matrix a11 – a33 are the rotational matrix, while

the last row of both matrices is the translation matrix. Therefore, it can be furthered

expanded to the following matrices.

 cos sin  0
2D Mapping M 2D   sin  cos 0 … (3.75)
 x y 1

3D Mapping

3-31
1 0 0 0
0 cos sin  0
R3 D  X  …(3.76)
 0  sin  cos 0
 
x y z 1

cos  0  sin  0
 0 1 0 0
R3 DY  …(3.77)
 sin  0 cos  0
 
 x y z 1

cos sin  0 0
 sin  cos 0 0
R3 D  Z  …(3.78)
 0 0 1 0
 
 x y z 1

Parameters

There are two parameters that need to follow convention; amount of translation in

every axis and angle for rotation. In order to make the convention, we have to

understand the foundation. Figure 3.10 shows that point P needs to be mapped to the

new coordinate system (X’Y’)

Referring to the principal coordinate system (XY), origin of the mapped

coordinate system is (3, 2). Currently P is (x, y) when it is referred to the principal

coordinate system and we need to calculate the coordinate of P when is mapped to

X’Y’ coordinate system. Similar situation occurs on the origin of both coordinate

systems, both origins should be (0, 0). To make the X’Y’ coordinate system to be (0,

0), the coordinate should be translated by Dx = -3 and Dy = -2. Therefore, the amount

of the translation needed will be the negative value of the origin of mapped (X’Y’)

coordinate system.

3-32
The foundation of the translation is that it should be inverse to the amount of

translation of the mapped cs. Similar for angle of rotation, it should be negative to

conventional Right Hand Rule and as a result for the case in Figure 3.10, the rotation

angle should be -30o. Please take note that Right hand rule is used to set the positive

or negative values of the angle.

The previous mapping is based on the conventional coordinate system, means

that the axis of x, y, and z is based on right hand rule. However, the mapping may

occur and the coordinate system is not following the conventional one. Mapping the

default coordinate system of the computer graphic system to the conventional

coordinate system is not following the conventional coordinate system.

Figure 3.11 shows the default position of the conventional and computer

graphic system coordinate system. The origin of conventional coordinate system will

be positioned at the bottom left of the screen, whilst the origin of the graphic screen

coordinate system is at the top left of the screen. Visually, we can say that only the y

axis is been rotated by 180o.

Figure 3.11 Mapping of the default CS graphic system to common cs


3-33
Since matrices in equation 3.73 to 3.78 require all the axis of the rotated at the

same angle, these matrices should be modified to cater the need of not having all the

axis to be rotated at the same angle. Therefore, the matrices can be expanded to

individual rotation on each axis on each column as stated in equation 3.79 for 2D and

3.80 for 3D.

 nx n y 0 
2D Mapping M 2D   ox oy 0 … (3.79)
x y 1

 nx n y nz 0
o o y oz 0
3D Mapping M 3D  x … (3.80)
 px p y pz 0
 
x y z 1

The first column is the transformation needed for x coordinate, the second and

the third column are the transformation needed for y and z coordinates respectively.

Referring back to the problem in Figure 3.11 and assuming the translation matrix has

been solved, point P is the point using the graphic screen coordinate system and point

P’ is the mapped point P using the principle coordinate system. The relationship

between them is as follows:

x' = x

y’ = -y

Based on the above relationship of

x'  nx x  ny y , nx = 1 and ny = 0 to fullfil x’ = x

y '  ox x  oy y ox = 0 and oy = -1 to fullfil y’ = -y

Therefore, the mapping matrix will be


3-34
1 0 0
M 2D   0  1 0

x y 1

Similarly, the mapping matrix can be derived from the rotational matrix,

where angle of rotation 0o and 180o are used for x and y axis respectively.

nx = cos x = cos 0o = 1 ox = -sin y = -sin 180o = 0

ox = sin x = sin 0o = 0 ox = cos y = cos 180o = -1

As a result, the same mapping matrix is formed

Example 3.5

Figure 3.12 shows a square is mirrored using axis 2. Answer the following questions

based on the information given

Figure 3.12 Problem of example 3.5

i. Write the homogeneous representation of the square

ii. Calculate the coordinates of the mirror square using the compound

transformation of rotation and translation.

iii. Calculate the coordinates of the mirror square using the mapping transformation

matrix

3-35
Solution

i. The homogenous representation of the square

20 20 1
30 20 1
[K ]  
30 10 1
 
20 10 1

ii. Mirror using the translation and rotational matrix

Figure 3.13: Method 1

To get all the coordinates of the square after being mirrored, the current CS have to go

through the following transformation.

a) The coordinate system must move to point (10, 5). This causes the point (10,

5) turns to (0,0) as shown in Figure 3.13a.

1 0 0

T1   0 1 0
 5  10 1

3-36
b) Rotate the coordinate system by -40o and this causes the mirror axis and x axis

of the coordinate system to be coincided as shown in Figure 3.13b.

 cos( 40o ) sin( 40o ) 0


 
R1   sin( 40o ) cos( 40o ) 0
 0 0 1

c) Mirror the square using x axis as the mirror axis as shown in Figure 3.13c.

1 0 0
M  0  1 0
0 0 1

d) Rotate the coordinate system by 400 as shown in Figure 3.13d.

 cos( 40o ) sin( 40o ) 0


 
R2   sin( 40o ) cos( 40o ) 0
 0 0 1

e) Translate back the coordinate system to its original position as shown in

Figure 3.13e.

1 0 0
T2  0 1 0
5 10 1

Therefore the compound matrix is

   T R M R T 


comp 1 1 2 2

iii. Method using the mapping matrix

3-37
Figure 3.14 Method 2

a) Mapping the square based on the X’Y’ coordinate system as shown in Figure

3.14a.

In mapping transformation matrix, two parameters, angle and translation, are required.

= -40O

Dx1 = -11.18cos (23.4o) = -10.26

Dy1 = -11.18 sin (23.4o) = -4.44

Therefore, the mapping transformation matrix is

 cos( 40 o ) sin( 40 o ) 0


 
Mp1   sin( 40 o ) cos( 40 o ) 0
  10.26  4.44 1

b) Mirror the square based on X’ axis as the mirror axis as shown in Figure 3.xxb.

1 0 0
M  0  1 0
0 0 1

3-38
c) Mapping back the square after the mirror using the original coordinate system

as shown in Figure 3.xxc.

= 40O

Dx2 = 5

Dy2 = 10

 cos( 40o ) sin( 40o ) 0


 
Mp2   sin( 40o ) cos( 40o ) 0
 5 10 1

Therefore the compound matrix is

   Mp M Mp 


comp 1 2

*Compound matrix for b) and c) is

 0.714 0.985 0
 
comp   0.985  0.714 0

 5.716 6.812 1

Example 3.6

By default every window created has its own Coordinate System (CS) as shown in

Figure 3.15a and the position is set by the raster position such as (10,10) means 10

raster in X and 10 raster in Y direction. However, in practice the CS is set as in Figure

3.15b and according to units either mm or inches.

If one raster is equal to 0.01mm and the size of the window is 1000 raster vertical and

2000 raster horizontal.

3-39
Develop the transformation required to calculate the position of the entities in raster

based CS (Figure 3.15a) but for visualization purposes, it seems to refer to Normal

CAD window CS (Figure 3.15b). The entities are comprises four lines to draw a2 if a

2 mm square with the bottom left corner will be at (1, 1). The position of the Normal

CAD window CS is at (2000, 0) of raster based CS.

Y
default window, raster based window setting.
Normal CAD window, unit (mm/ inch) based window setting

Figure 3.15 Example 3.6

Solution

The vertices of the square in mm are (1, 1), (3, 1), (3, 3), and (1, 3).

Therefore, in raster unit, the vertices are (10, 10), (30, 10), (30, 30), and (10, 30) and

its homogenous representation will be

10 10 1
30 10 1
[K ]  
30 30 1
 
10 30 1

The next step is to apply the mapping matrix. Since the position of CAD package CS

is at (0, 2000) of the raster CS, therefore x = 0 and y = 2000. Therefore, the

mapping matrix is

3-40
1 0 0
M 2D   0  1 0

0 2000 1

The transformed vertices will be

10 10 1
30 1 0
1 
0
0  1 0
10
K '   
30 30 1
  0 2000 1
10 30 1 
10 1990 1
30 1990 1

30 1970 1
 
10 1970 1

Therefore, to draw a 2 mm square, the square comprise of (10, 1990), (30, 1990), (30,

1970), and (10, 1970) vertices must be drawn on the raster-based screen.

3.3 COMPOUND TRANSFORMATION

More often, multiple transformations are applied. The combination of these matrices

is called compound transformation, such as the following:

    .  ... 
comp 1 2 n … (3.81)

As a result, the coordinates of vertices will be

P'  Pcomp 

The main question arises whether the compound transformation should be order

or it does not matter. Figure 3.16 shows the application of translation and rotation

matrix. Figure 3.16a shows the translation is applied first and then follow with the

3-41
rotation, whilst Figure 3.16b shows the rotation is applied first and then follow with

the translation. As a result, the mapped shape is not on the same position, which

means that

1 2   2 1  … (3.82)

Figure 3.16 Application of transformation matrices

Therefore, to create the compound transformation, it must be in sequence.

3.5 PROJECTION USING TRANSFORMATION

Most common, we will draw solid object in 3D. During manipulation during

modeling or for documentation purposes, the need to project the model from different

view is required. In changing the view point, transformation is applied to model. The

orthographic and axometric projections will be discussed in the following section.

3.5.1 Orthographic Projection

Orthographic drawing is created when the object is projected on the basic three planes

that are perpendicular to each other. The view point is assumed to be at infinity

distance and this projection ray to be parallel to each other, therefore the projection is
3-42
one of the parallel perspective projections. As the projection ray is parallel to each

other, it causes the projection is having the true length of the object. Figure 3.17

illustrates the concept of the parallel perspective.

Figure 3.17 Concept of orthographic projection

Furthermore, the plane for the orthographic projection is normal to the view ray.

The basic of orthographic projection is when the object is projected to the three basic

planes; XY, YZ, and ZX plane. The transformation matrices of orthographic

projection on all the planes are as follows:

1 0 0 0
0 1 0 0
Plane XY OXY  … (3.83)
0 0 0 0
 
0 0 0 1

0 0 0 0
0 1 0 0
Plane YZ OYZ   … (3.84)
0 0 1 0
 
0 0 0 1

3-43
1 0 0 0
0 0 0 0
Plane ZX OZX  … (3.85)
0 0 1 0
 
0 0 0 1

However, in engineering drawing, additional views, such as auxiliary and

sectional views, is basically using orthographic projection. In order to create these

additional views, mapping of the coordinate system is required before the projection

transformation matrix is applied to create the views. Figure 3.18 shows the application

of mapping transformation matrix before application of projection transformation

matrix.

Figure 3.18 Application mapping transformation to create auxiliary view projection

Example 3.7

Figure 3.19a is a 3D part. Using the 3D part, develop the orthographic drawing. The

bottom left vertex of the orthographic will be at (0, 0) of the 2D environment. The

distance between the views is set to 10 mm as shown in Figure 3.19b.

The task is to develop the transformation matrices that is able to transform the vertices

of 3D part into vertices that can be used to develop the orthographic drawing.

3-44
l

(a) (b)

Figure 3.19 Example 3.7

Solution

There are 10 vertices of the part and the vertices are (0, 0, 0), (30, 0, 0), (30, 0, 30), (0,

0, 30), (0, 30, 0), (30, 30, 0), (30, 30, 15), (15, 30, 30), (0, 30, 30), and (30, 15, 30)

and hence the homogenous representation will be

0 0 0 1
30 0 0 1

30 0 30 1
 
0 0 30 1
0 30 0 1
M    
30 30 0 1
30 30 15 1
 
15 30 30 1
0 30 30 1
 
30 15 30 1

FRONT VIEW

3-45
To create the front view, the part needs to project onto XY plane and by taking only

the x and y coordinate, the front view can be formed.

0 0 0 1
30 0 0 1

30 0 30 1
 
0 0 30 1 1 0 0 0
0 1 0 1 0 0
 
M*  
30 0

1 0 0 0 0
30 30 0
30  
30 15 1 0 0 0 1
 
15 30 30 1
0 30 30 1
 
30 15 30 1
0 0 0 1
30 0 0 1

30 0 0 1
 
0 0 0 1
0 30 0 1
 
30 30 0 1
30 30 0 1
 
15 30 0 1
0 30 0 1
 
30 15 0 1

TOP VIEW

To create the top view, rotation is carried along the X axis by 90o. The rotation causes

the plane ZX to be mapped onto plane XY. Then, 3D part is projected onto XY plane.

Finally, translation with x = 0, y = 70, and z = 0

3-46
0 0 0 1
30 0 0 1

30 0 30 1
 
0 0 30 1 1 0 0 0 1 0 0 0 1 0 0 0
0 
1 0 cos 90o 0 0 1 0 0 0 1 0 0
 
o
30 0 sin 90
M*   
30 30 0 1 0  sin 90o cos 90o 0  0 0 0 0  0 0 1 0
30    
30 15 1 0 0 0 1  0 0 0 1 0 70 0 1
 
15 30 30 1
0 30 30 1
 
30 15 30 1
0 70 0 1
30 70 0 1

30 40 0 1
 
0 40 0 1
0 70 0 1
 
30 70 0 1
30 55 0 1
 
15 40 0 1
0 40 0 1
 
30 40 0 1

SIDE VIEW

To create the side view, the part must be rotated by -90o along Y axis prior applying

the projection of the 3D part onto the XY plane. Finally, translation by x = 70 is

done to position the side view.

3-47
0 0 0 1
30 0 0 1

30 0 30 1
 
0 0 30 1 cos( 90o ) 0  sin( 90o ) 0 1 0 0 0  1 0 0 0
 
0 1  1 0 0  0 1 0 0
 
M*  
30 0

0
1  sin( 90o )
1 0 0  0
30 30 0 0 cos( 90o ) 0  0 0 0 0  0 0 1 0
30    
30 15 1  0 0 0 1 0 0 0 1 70 0 0 1
 
15 30 30 1
0 30 30 1
 
30 15 30 1
70 0 0 1
70 0 0 1

40 0 0 1
 
40 0 0 1
70 30 0 1
 
70 30 0 1
55 30 0 1
 
40 30 0 1
40 30 0 1
 
40 15 0 1

Table 3.3 shows the orthographic projection of each vertex on each view

Vertex Front Top Side

(0, 0, 0) (0, 0) (0, 70) (70, 0)

(30, 0, 0) (30, 0) (30, 70) (70, 0)

(30, 0, 30) (30, 0) (30, 40) (40, 0)

(0, 0, 30) (0, 0) (0, 40) (40, 0)

(0, 30, 0) (0, 30) (0, 70) (70, 30)

(30, 30, 0) (30, 30) (30, 70) (70, 30)

(30, 30, 15) (30, 30) (30, 55) (55, 30)

(15, 30, 30) (15, 30) (15, 40) (40, 30)

3-48
(0, 30, 30) (0, 30) (0, 40) (40, 30)

(30, 15, 30) (30, 15) (30, 40) (40, 15)

3.5.2 Axometric Projection

Axometric project will display the model in 3D on 2D projected plane. It is also one

of the parallel perspective projections. Unlike the orthographic projection, it projects

the true length of the object, the axometric projection may project a shorten projection

of the objects. To create the axometric, the view point must be at angle a on plane

XY and angle b from plane XY as shown in Figure 3.20.

Figure 3.20 Angle a and b to create axometric projection

Based on view point, to create the axometric projection on graphic screen, it

requires three transformation matrices, which are as follows:

i) Rotate the model at angle a on Y axis,

ii) Rotate the model at angle b on X axis,


3-49
iii) Project the model to plane XY

Therefore the compound transformation matrix axometric projection will be as

the following:

A  R3D Y R3D  X OZX 


cos  0  sin  0 1 0 0 0 1 0 0 0
 0 1 0  
0 0 cos  sin  0 0 1 0 0 …(3.86)
A  
 sin  0 cos  0 0  sin  cos  0  0 0 0 0
   
 0 0 0 1 0 0 0 1  0 0 0 1

Based on the angle a and b, the axometric projections can be further classified

as isometric, dimetric or trimetric projection and their properties are as follows:

Isometric projection: when all the axes have been shorten at specific scale.

Dimetric projection: two of the axes have been shorten at the same scale.

Trimetric: when all the axes have been shorten at different scale.

In the following, it will discuss the manipulation of angle a and b to create these

projections.

Isometric Projection

Figure 3.21 shows a cube has been projected into isometric projection. To create an

equal angle  between axes and horizontal line on the right and left sides, the model

must rotate by 45o about Y axis (angle a). However, angle b from the plane XY will

determine the angle  Both angle b and  are governed by h and w, and the equations

for angle b and  are as follows:

3-50
Figure 3.21 Basic isometric projection

h
  sin 1  
 w

h
  tan 1  
 w

In the case of isometric projection for engineering drawing, the w is longer by

3 to the h. Based on the above equations, angle  should be 30o, and angle b is

35.26o. In all, for isometric projection, angle a is 45o, angle b is 35.26o, and angle 

is 30o. Figure 3.22 show the possible isometric projections and the angle of a, b, and

.

3-51
Figure 3.22 Possible isometric projection with angle a, b, and 

Example 3.8

Calculate the vertices of box with 4 unit x 4 unit x 2 unit when the box is projected

using isometric projection.

Solution

The homogeneous representation of the box is

0 0 0 1
0 0 2 1

4 0 0 1
 
4 0 2 1
K   
4 4 0 1
 
4 4 2 1
0 4 0 1
 
0 4 2 1

To generate the isometric projection,  is 45o, and  is 35.26o. Therefore the

transformation matrix will be

A  R3DY R3D X OZX 

3-52
0.71 0.41 0 0
 0 0.82 0 0
0 
0.71  0.41 0 0
 
 0 0 0 1

Therefore, the vertices of the isometric projection are

0 0 0 1
0 0 2 1

4 0 0 1 0.71 0.41 0 0
 
1  0 0
 
K 
*
4
4 0
4
2
0
0.82
1 0.71  0.41
0
0 0
  
4 4 2 1  0 0 0 1
0 4 0 1
 
0 4 2 1

 0 0 0 1
1.42  0.82 0 1

 2.83 1.63 0 1
 
 
K 
* 4.24 0.82
 2.83 4.9
0
0
1
1
 
4.24 4.08 0 1
 0 3.27 0 1
 
1.42 2.45 2 1

Figure 3.24 shows the isometric projection of the box,

Figure 3.24 Isometric Projection of the box

3-53
Length along X axis:

Line from (0, 0, 0) and (4, 0, 0) will be transformed to (0, 0) and (2.83, 1.63),

therefore true length 4 will become 3.27.

Length along Y axis:

Line from (0, 0, 0) and (0, 4, 0) will be transformed to (0, 0) and (0, 3.27),

therefore true length 4 will become 3.27.

Length along Z axis

Line from (0, 0, 0) and (0, 0, 2) will be transformed to (0, 0) and (1.42, -0.82),

therefore true length 2 will become 1.64

Dimetric Projection

Isometric projection will make the axes to be shorten at the same scale. Howeer, when

two of the axes have been shorten at different scale from the other axis, it projects into

a projection that is called as dimetric. More frequent, the x axis will be scaled

differently and this causes the projection is not symmetric. Therefore, the rotation

angle a should be larger than 45o. Figure 3.25 show the possible dimetric projections

and the angle of a, b, and .

3-54
Figure 3.25 Possible dimetric projection with angle a, b, and 

Dimetric projection will display the model is more realistic manner than

isometric projection.

Example 3.9

Calculate the transformed vertices of the box in example 3.8

i)  is set to 50o, 60o, 70o, 80o and  is 24o.

3-55
ii)  is 70o, and  is set to 40o, 30o, 20o, 10o

Solution (a)

Based on equation 3.86, by varying the  and set  = 24o, the resultant vertices are

shown in Table 3.4.

Table 3.4 Vertices for various with  = 24o

Vertices = 50o  = 60o  = 70o  = 80o

(0, 0, 0) (0,0) (0, 0) (0, 0) (0, 0)

(0, 0, 2) (1.532, -0.499) (1.732, -0.388) (1.879, -0.266) (1.97, -0.135)

(4, 0, 0) (2.571, 1.190) (2, 1.346) (1.386, 1.46) (0.695, 1.530)

(4, 0, 2) (4.103, 0.691) (3.732, 0,957) (3.247, 1.194) (2.664, 1.395)

(4, 4, 0) (2.571, 4.876) (2, 5.031) (1.368, 5.146) (0.695, 5.216)

(4, 4, 2) (4.103, 4.377) (3.732, 4.643) (3.247, 4.880) (2.664, 5.081)

(0, 4, 0) (0, 3.686) (0, 3.686) (0, 3.686) (0, 3.686)

(0, 4, 2) (1.532, 3.187) (1.732, 3.297) (1.879, 3.420) (1.97, 3.551)

The dimetric projections based on the various angle  are shown in Figure 3.26.

3-56
Figure 3.26 The dimetric projections of various 

Solution (b)

Similarly, equation 3.86 is used, by setting  = 70o and varying the , the resultant

vertices are shown in Table 3.5. Figure 3.27 shows each dimetric projection.

Table 3.5 Vertices for various with  = 70o

Vertices = 40o  = 30o  = 20o  = 10o

(0, 0, 0) (0,0) (0, 0) (0, 0) (0, 0)

(0, 0, 2) (1.879, -0.422) (1.879, -0.327) (1.879, -0.233) (1.879, -0.113)

(4, 0, 0) (1.368, 2.319) (1.368, 1.798) (1.368, 1.227) (1.368, 0.622)

(4, 0, 2) (3.247, 1.897) (3.247, 1.471) (3.247, 1.003) (3.247, 0.509)

(4, 4, 0) (1.368, 5.467) (1.368, 5.311) (1.368, 5.008) (1.368, 4.567)

3-57
(4, 4, 2) (3.247, 5.045) (3.247, 4.983) (3.247, 4.784) (3.247, 4.454)

(0, 4, 0) (0, 3.148) (0, 3.513) (0, 3.781) (0, 3.945)

(0, 4, 2) (1.879, 2.726) (1.879, 3.186) (1.879, 3.558) (1.879, 3.832)

Figure 3.27 The dimetric projections of various 

3.6 APPLICATION OF TRANSFORMATION

In addition the application of transformation on the management of CAD entities,

transformation can also have other applications. Two of the applications are animation

and modeling. Section 3.6.1 will discuss the application of transformation in

animation and Section 3.6.2 will discuss the application on modeling purposes.

3.6.1 Animation

Animation is a process displaying a movement that is created by a series of picture or

frame. Since animation is directly related to movement, transformation matrix can be

3-58
applied to create the animation. In the following it demonstrates the movement of the

a car according the specified path as shown in Figure 3.28. The vehicle will brake

until it stops before turning to the right and then the vehicle takes the corners at the

same time accelerates. Finally the vehicle will continue to accelerate to reach the

desire velocity and the vehicle will travel at the constant velocity.

Figure 3.28 Animation of vehicle according to specified path

Based on the travelling of the vehicle, the path can be divided into four sections.

The sections are straight vertical path during braking, quarter circle path during

turning to the right, straight path during accelerating after taking the corner, and

finally straight path during travelling at the constant velocity. The initial homogenous

representation of the path will be the vertices at the starting point for each path and

the application of the transformation matrices will be based on the path and the

position of the vehicle based on the time using dynamic of motion. Example 3.10 will

demonstrate further to calculate the vertices for the first and the second path.

Example 3.10

The first path in Figure 3.28 is 75 m which the vehicle will brake to stop from initial

velocity of 10 m/s. The vehicle will then accelerate to reach 3 m/s at the end of path 2

3-59
based the path generated by radius of the quarter circle of 4.5 m. Then, the vehicle

will accelerate to 10 m/s within 30 m and finally travel constantly at 10 m/s for the

rest of the journey which in the example for another 50 m.

Solution

Assume the vehicle is represented as a single point. Therefore the homogenous

representation of the vehicle will be

V   x y 1

First path from A and B

The initial position of the vehicle will be

V   0
p1 0 1

The time taken for the vehicle to stop from initial velocity of 20 m/s will be based on

the

v  u  at
at  v  u

s  ut  0.5at 2
s  t (u  0.5at )

s  t max (u  0.5(v  u ))
s
t max 
0.5(u  v)

When sy = 75 m, uy = 10 m/s, and vy = 0, t = 15 sec.

If the position of the vehicle is calculated based on every second, s(t) for t = 0 to 15

sec will be

3-60
(v  u )
ay 
t max
s x (t )  u x t  0.5a x t 2
s y (t )  u y t  0.5a y t 2

Therefore, the translation the vehicle will be

[V p*1 ]  [V ][T ]
 1 0 0
 
 [0 0 1] 0 1 0
 S x (t ) S y (t ) 1
 

When t = 0 to 15 is inserted to the equation, the translation of the vehicle will be in

Table 3.6

Table 3.6 Position of the vehicle at time t

Time (sec) Distance s(t) Time (sec) Distance s(t) m

0 (0, 0) 8 (0, 58.67)

1 (0, 9.67) 9 (0, 63)

2 (0, 18.67) 10 (0, 66.67)

3 (0, 27) 11 (0, 69.67)

4 (0, 34.67) 12 (0, 72)

5 (0, 41.67) 13 (0, 73.67)

6 (0, 48) 14 (0, 74.67)

3-61
7 (0, 53.67) 15 (0, 75)

Second path from B to C

For the second path, the starting point is at the point where the vehicle stops which is

(0, 75) and the time at point B will be set to 0.

Similar, approach as path is used here except the motion will be in angular.


tmax 
0.5(o  1 )

where = /2, o = 0 and


V 3
1    0.67 rad / s
r 4.5

Hence, the time taken to the vehicle to complete path 2 is


tmax  = 4.71 sec
0.5(o   )

Therefore, (t) will be

 (t )  ot  0.5t 2

The rotation transformation will be (negative angle due to the clockwise direction)

 cos( (t )) sin(  (t )) 0
R2 D   sin(  (t )) cos( (t )) 0
 0 0 1

The initial position of the vehicle for Path 2 is

V   0
p2 75 1

3-62
The center of rotation will be at (4.5, 75). Since the center of rotation is not the origin,

the

 1 0 0  cos( (t )) sin(  (t )) 0  1 0 0
V 
*
p2

 0 75 1 0 1    
0  sin(  (t )) cos( (t )) 0  0 1 0
 4.5  75 1  0 0 1 4.5 75 1

By inserting the time, the position of the vehicle at the specified is listed in Table 3.7.

Table 3.7 Position of the vehicle at the specified time (Path 2)

Time (s) 0 1 2 3 4 4.71

Position (0, 75) (0.01, 75.32 ) (0.18, 76.26) (0.88, 77.68) (2.59, 79.07) (4.50, 79.50)

Path 3

Similar approach as in calculating the position of vehicle for Path 2, the initial known

variables will be

Distance travel s = 30 m

Initial velocity u = 3 m/s

Final velocity v = 10 m/s

 
Homogeneous representation of the vehicle: V p 3  4.5 79.5 1

Based on these variables, time taken to travel will be 4.62 sec (tmax)

Therefore, the position of the vehicle with respect to time will be in Table 3.8

Table 3.8 Position of the vehicle at the specified time (Path 3)

Time (s) 0 1 2 3 4 4.62

3-63
Position (4.5, 79.5) (8.26, 79.5 ) (13.53, 79.5) (20.33, 79.5) (28.63, 79.5) (34.5, 79.50)

Path 4

The known variables for Path 4

Distance travel s = 50 m

Initial velocity u = 10 m/s

Final velocity v = 10 m/s

 
Homogeneous representation of the vehicle: V p 3  3 4.5 79.5 1

Based on these variables, time taken to travel will be 5 sec (tmax)

Therefore, the position of the vehicle with respect to time will be in Table 3.9

Table 3.9 Position of the vehicle at the specified time (Path 4)

Time (s) 0 1 2 3 4 4.62

Position (34.5, 79.5) (44.5, 79.5 ) (54.5, 79.5) (64.5, 79.5) (74.5, 79.5) (80.7, 79.5)

Figure 3.29 shows the vertices on the path.

3-64
Figure 3.29 Vertices of the path

3.6.2 Modeling purposes

For the purposes of modelling, it is easier to model the part separately. This is because

it is common to have one reference point on the part and all the dimension will be

referred to this reference. Therefore, it will be easier, the origin of axis (0, 0, 0) is

regarded as the reference point. After the part is drawn, then transformation matrices

will be applied to the part to position the part on the intended place.

Figure 3.29 shows application of the transformation to model robotic arm. The

robotic comprises Arm 1, Arm 2, and Gripper. To ease the modelling process, each

part will be modelled separately using the origin (0, 0) as the reference point as shown

in Figure 3.29a. When the robotic arm is assembled, it should be assembled as shown

in Figure 3.29b. Therefore, the transformation matrices are used to assemble the

robotic arms.

Figure 3.29 Application of transformation on robotic modelling

To model Arm 1, Arm 1 will be rotated by 45o

3-65
 cos(45o ) sin( 45o ) 0
V  *
arm1

 Varm1  sin( 45o ) cos(45O ) 0

 0 0 1

To model Arm 2, the arm must be rotated by 20o counter clock wise direction and

followed with translation to the other end of arm1.

 cos( 20o ) sin( 20o ) 0  1 0 0


V  *
arm2
 o o 
 Varm2  sin( 20 ) cos( 20 ) 0  0 1 0
 0 0 1  L1cos( 45o ) L1sin( 45o ) 1

To model the gripper, the gripper must be rotated 30o clock wise direction and

followed with translation to the other end of Arm 2.

 cos( 30 o ) sin( 30 o ) 0  1 0 0


V *
gripper   V gripper 

 sin( 30 ) cos( 30 ) 0 
o o 
0 1 0
 0 0 1  L1cos( 45o )  L 2 cos( 20 o ) L1sin( 45o )  L 2 sin( 20 o ) 1

Example 3.11

The arms are modelled using API function that is able to create a cube of 1 x 1 x 1.

Therefore, the task is to model the upper and lower arms to be at intended position

shown in Figure 3.30 from the basic cube of 1 x 1 x 1. The size of the lower arm is 2 x

2 x 20 and upper arm is 2 x 2 x 5.

3-66
Figure 3.30 Simplified robotic arm

Solution

The steps to model the lower and upper arm are as the following

Step 1: Scaling to lower and upper (Figure 3.31a)

Since the arm is built from a cube 1 x 1 x 1, scaling of the cube accordingly will

create the lower and upper arm.

The scaling of lower arm

2 0 0 0
0 2 0 0
L 
1*
arm  Larm 
0 0 20 0
 
0 0 0 1

The scaling of the upper arm

2 0 0 0
0 0
U 
1*
arm  U arm 
0
2
0
0
5 0
 
0 0 0 1

Step 2: Translate the upper arm at the end of the lower arm (Figure 3.31b)

1 0 0 0
0 0
U   U 
2*
arm
1*
arm

0
1 0
0 1 0
 
0 0 20 1

Step 3: Rotate lower and upper arm along –ve Y axis by 60o (Figure 3.3c)

The transformation for the lower arm.

3-67
cos(30o ) 0  sin( 60o ) 0
 
L   L 
3* 1*  0
 sin( 30o )
1 0 0
0
arm arm
0 cos(30o )
 
 0 0 0 1

The transformation for the upper arm

 1 0 0 0 cos(30o ) 0  sin( 30o ) 0  1 0 0 0


  
0  0 0
U   U 
3*
arm
2*
arm


0 1 0
0  sin( 30o )
1 0 0 
 
0 1 0
0
0 0 1 0 cos(30o ) 0 0 0 1
   
 20 cos(60 ) 0  20 sin( 60o ) 1  0 1 20 cos(60 )
o o
0 0 0 20 sin( 60o ) 1

Step 4: Rotate upper arm along +ve Y axis by 10o (Figure 3.3d)

The center rotation is at the end of the lower arm which is (20 cos(60o), 20 sin(60o)).

Therefore, translation must be applied before and after the rotation matrix.

 1 0 0 0 cos(10o ) 0  sin( 10o ) 0  1 0 0 0


  
0  0 0
U   U 
4* 3* 

0 1 0
0  sin( 10o )
1 0 0 

0 1 0
0  0
arm arm
0 0 1 0 cos(10o ) 0 0 1
   
  20 cos( 60o ) 0  20 sin( 60o ) 1  0 0 0 1 20 cos(60 )
o
0 20 sin( 60o ) 1

Step 5: Rotate the lower and upper arm by 15o along +ve Z axis (Figure 3.31e)

The transformation for the lower arm.

cos(15o ) sin( 15o ) 0 0


 
L   
o
3*  sin( 15 ) cos(15o ) 0 0
5*
 Larm
arm
 0 0 1 0
 
 0 0 0 1

The transformation for the upper arm.

 1 0 0 0 cos(15o ) sin( 15o ) 0 0  1 0 0 0


  
0  sin( 15o ) cos(15o ) 0
U   U 
5* 4*  0 1 0
0  0
0 0  0 1 0
 0  0
arm arm
0 0 1 0 1 0 0 1
   
  20 cos( 60o ) 0  20 sin( 60o ) 1  0 0 0 1  20 cos( 60o ) 0 20 sin( 60o ) 1

3-68
Figure 3.31 Steps to model the robotic arm

 Note: there are other possible compounded transformation to generate similar

position of the arms.

3.6.3 Kinematic of the open loop mechanism

The transformation is also applicable to the kinematic study of the mechanism

especially the open loop mechanism. The main interest in the kinematic study is the

position of the arm. The movement of the arm depends on the joint types. Figure 3.32

shows the types of joint available can be used to build a mechanism.

3-69
Figure 3.32 Types of joints

The prismatic joint will only allow the translation, whilst the revolutional joint will

only allow the linkage at the center of the joint. Cylindrical joint will allow translation

and revolution. The translation will be along the axis of the cylindrical joint and the

revolution will be rotated at the center of the cylinder. Finally spherical joint will

allow rotational movement in all direction X, Y, Z direction.

Figure 3.33 shows one example of robotic arms. The arms comprises all

revolutional joints except at the gripper which is prismatic. Even with the

combination of revolutional joints of various axes will develop a complex movement.

Figure 3.33 Sample of robotic arm

3-70
Example 3.12

Figure 3.34 shows one robotic arms. Develop the matrices that will calculate the

position of point O based on angle , , and  and the length of each arms L1, L2, and

L3.

Figure 3.34 Robotic arm with three revolutional joints

Solution

To calculate the position of O, it relies on the position of C, B, and A. Therefore,

position of A must be calculated first, then follows with the calculating the position of

B and follow with position C.

Assuming all the linkages are positioned horizontally along the X axis, therefore, the

initial homogenous representation of linkages are

Linkage 1: L   L1
1 0 1

Linkage 2: L   L2
2 0 1

Linkage 3: L   L3
3 0 1

Calculating position B

3-71
 cos  sin  0
B x By 
1  L1 0 1 sin  cos  0
 0 0 1

Calculating position B

 cos(   ) sin(   ) 0  1 0 0
C x Cy  
1  L 2 0 1 sin(   ) cos(   ) 0  0 1 0

 0 0 1  Bx By 1

Therefore, position O

 cos(  ) sin(  ) 0  1 0 0
O x Oy  
1  L3 0 1 sin(  ) cos(  ) 0  0 1 0

 0 0 1 C x Cy 1

Therefore, the generic equation for open loop mechanism will be

 1 0 0
x'
i y '
i  
1  Li 0 1   required   0
 1 0
 xi 1 yi 1 1

3-72

You might also like