LECTURE2
LECTURE2
2D Transformation
CAD/CAM
What is transformation?
- The geometrical changes of an object from a current state to modified state.
Why the transformation is needed?
- To manipulate the initially created object and to display the modified object without having
to redraw it.
By Layth Fadhil
12
CAD/CAM
Matrices.
By Layth Fadhil
13
CAD/CAM
Pre-multiplication Vs Post-
multiplication
If [A]=[B]
𝒂 𝒃 𝒆 𝒇
[ ].[ ] 1. Pre-multiply by [C]
𝒄 𝒅 𝒈 𝒉 [C].[A]=[C].[B]
𝒂𝒆 + 𝒃𝒈 𝒂𝒇 + 𝒃𝒉
=[ ] 2. post-multiply by [C]
𝒄𝒆 + 𝒅𝒈 𝒄𝒇 + 𝒅𝒉 [A].[C]=[B].[C]
𝒄 𝒅
[𝒂 𝒃]. [ ] = [𝒂𝒄 + 𝒃𝒆 𝒂𝒅 + 𝒃𝒇]
𝒆 𝒇 We will use Row vector to represent the
point, so post-multiplication matrix is the
choice. Which mean Transformation matrix
𝟏 𝟑 𝟒 appears after the point, the sequence is from
What about this? [ ] [ ] =?
𝟐 𝟓 𝟔 left to right, and the solution is form right to
left.
[p]=[𝒙 𝒚 𝟏] and [p'] = [p]. [T]
By Layth Fadhil
14
CAD/CAM
Points representation, Homogeneous coordinate system.
Each point in the space has three coordinates (X, Y and Z). these points will be represented as a row
vector in a homogeneous coordinate system. Since we are dealing with 2D-objects, 3rd-coordinate
assumed to be constant relative to X and Y.
Ex: point (5,3) = point (15,9,3) = point (10, 6, 2) or any point of (X, Y) = (XZ, YZ, Z). We are going
to give the value of (1) to the 3rd coordinates to facilitate matrix product.
❖ Points will be represented as row vectors. Examples:
Point (4,7) = [𝟒 𝟕 𝟏]
𝟎 𝟎 𝟏
Triangle (0,0), (3,0) and (3,5) =[𝟑 𝟎 𝟏]
𝟑 𝟓 𝟏
Rectangle (1,1), (1,-1), (-1,-1) and (-1,1) =
[ ]????
By Layth Fadhil
15
CAD/CAM
1) Translation:
A translation moves all points in an object along the same straight-line path to new positions.
We can write components as:
Translation matrix
p'x = px + ty
p'y = py + ty [𝒑′ ] = [𝐩]. [𝐓]
𝟏 𝟎 𝟎
= [𝒙 𝒚 𝟏] [ 𝟎 𝟏 𝟎] [𝑿 + 𝒕𝒙 𝒚 + 𝒕𝒚 𝟏]
𝒕𝒙 𝒕𝒚 𝟏
Note:
If X-direction is left then tx +ev, and if X-direction is right then tx -ev.
If Y-direction is up then ty +ev, and if Y-direction is down the ty -ev.
By Layth Fadhil
16
CAD/CAM
2) Rotation:
A rotation repositions all points in an object along a circular path in the plane centered at the
pivot point by an angle θ. If the rotation is clockwise CW the angle is negative (-θ), if the rotation
is counter clockwise C.CW the angle is positive (+θ).
Example: find the transformed point, P’, caused by rotating P= (5, 1) about the origin through
an angle of 90 CCW.
𝒄𝒐𝒔𝟗𝟎 𝒔𝒊𝒏𝟗𝟎 𝟎
𝒑̀ = [𝒑]. [𝑹] = [𝟓 𝟏 𝟏] [−𝒔𝒊𝒏𝟗𝟎 𝒄𝒐𝒔𝟗𝟎 𝟎] = [−𝟏 𝟓 𝟏]
𝟎 𝟎 𝟏
By Layth Fadhil
17
CAD/CAM
3) Scaling:
Scaling changes the size of an object and involves two scale factors, Sx and Sy for the x- and y-
coordinates respectively. Scales are about the origin.
p'x = sx • px 𝒔𝒙 𝟎 𝟎
p'y = sy • py Scaling matrix [ 𝟎 𝒔𝒚 𝟎]
𝟎 𝟎 𝟏
If the scale factors <1 ➔ the If the scale factors >1 ➔ the If Sx Sy ➔ differential
points will be moved closer to points will be moved away from scaling.
the origin ➔ the object will be the origin ➔ the object will be Change in size and shape
smaller. larger. EX: square → rectangle
EX: P(2, 5), Sx = Sy = 0.5. EX: P(2, 5), Sx = Sy = 2. Circle → ellips
By Layth Fadhil
18
CAD/CAM
4) Mirroring:
Mirroring is reflecting the objects about a reference such as a line or a point. The dimensions of the
object will be the same, but the coordinates directions will be changed. Mirroring matrices can be
categorized as follow:
x=x x= -x
y= -y y=y
𝟏 𝟎 𝟎 −𝟏 𝟎 𝟎
[ 𝑴 𝒙 ] = [𝟎 −𝟏 𝟎] [ 𝑴𝒙 ] = [ 𝟎 𝟏 𝟎]
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
By Layth Fadhil
19
CAD/CAM
c- About Origin a- About line X=Y
x=-x x=y
y=-y y=x
−𝟏 𝟎 𝟎 𝟎 𝟏 𝟎
[ 𝑴𝒙 ] = [ 𝟎 −𝟏 𝟎] [ 𝑴𝒙 ] = [ 𝟏 𝟎 𝟎]
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
By Layth Fadhil
20
CAD/CAM
Composite Transformation
When multiple transformation applied to a set of points, then it’s called a composite transformation,
such as rotating, scaling or mirroring about a point other than original point.
❖ Rotate about an arbitrary point – Translate the point of rotation to origin, Rotate,
Translate to the original position.
❖ Scale about an arbitrary point – Translate the point of rotation to origin, Scale, Translate
to the original position.
❖ Change coordinate systems – Translate, Rotate, Scale.
Does the order of operations matter? See Fig below.
By Layth Fadhil
21
CAD/CAM
{..Exercises..}
1. Perform 60° rotation of a point P(2, 5) about a pivot point (1,2). Find P’. [Ans (-1,4)]
2. Rotate the rectangle (0,0), (2,0), (2,2) and (0,2) shown below 30° CCW about it’s centroid.
3. Reflect a square (2x2) whose center at the origin about:
a) X-axis
b) Y-axis,
c) Line y= 5 and
d) Line y=x+3
4. A triangle with vertices (2,2), (4,2) and (2,5) is to be reflected about the line y=x+8.
Determine the coordinate of the reflected triangle.
5. Scale a unit circle by Sx=0.5 and Sy=0.75
By Layth Fadhil
22