4. Geometric Transformation Coordinate Transformation
Object Transformed Coordinate Transformed
Transformations
There are two types of Transformation
5. 2D Transformation
Given a 2D object, transformation is to change the
object’s
Position (translation)
Orientation (rotation)
Size (scaling)
Shapes (shear)
6. 2D Transformations
How many way the object can be transformed?
Three Basic Types of Transformation
• Translation
• Rotation
• Scaling
Another Transformations are
• Reflection
• Shear
x
y
x
y
x
y
7. Translation
Re-position a point along a straight line
Given a point (x, y), and the translation distance (tx, ty)
(x,y)
(x’,y’)
tx
ty
The new point: (x’, y’)
x’ = x + tx
y’ = y + ty
or P’ = P + T
y
x
t
t
T
y
x
P
y
x
P ,
,
y
x
t
y
t
x
y
x
8. Translation
How to translate an object with multiple
vertices?
Translate individual
vertices
9. 2D Rotation
Default rotation center: Origin (0,0)
q
q> 0 : Rotate counter clockwise
q< 0 : Rotate clockwise
q
The rotation point/ Pivot point –
The point at which the object is to be rotate
(Positive Rotation)
(Negative Rotation)
10. Rotation
(x,y)
(x’,y’)
q
(x,y) -> Rotate about the origin by q
(x’, y’)
How to compute (x’, y’) ? f
x = r cos (f) y = r sin (f)
r
x’ = r cos (f q) y = r sin (f q)
11. Rotation
(x,y)
(x’,y’)
q
f
r
x = r cos (f) y = r sin (f)
x’ = r cos (f q) y = r sin (f q)
x’ = r cos (f q)
= r cos(f) cos(q) – r sin(f) sin(q)
= x cos(q)– y sin(q)
y’ = r sin (f q)
= r sin(f) cos(q) + r cos(f)sin(q)
= y cos(q) + x sin(q)
12. Rotation
(x,y)
(x’,y’)
q
f
r
x’ = x cos(q) – y sin(q)
y’ = y cos(q) + x sin(q)
Matrix form?
x’ cos(q) -sin(q) x
y’ sin(q) cos(q) y
=
P/ = R(f). P
13. Rotation
How to rotate an object with multiple
vertices?
Rotate individual
Vertices
q
14. Scaling
Scale: Alter the size of an object by a scaling factor
(Sx, Sy), i.e.
x’ = x . Sx
y’ = y . Sy
(1,1)
(2,2) Sx = 2, Sy = 2
(2,2)
(4,4)
y
x
s
s
y
x
y
x
0
0
'
'
Fixed point – The point that used to control the location of a scaled object
P/ = S. P
15. 2D Scaling
(1,1)
(2,2) Sx = 2, Sy = 2
(2,2)
(4,4)
Not only the object size is changed, it also moved!!
Usually this is an undesirable effect
We will discuss later (soon) how to fix it
16. Put it all together
y
x
t
y
t
x
y
x
Translation:
Rotation:
Scaling:
y
x
s
s
y
x
y
x
0
0
'
'
P=T + P
P=S P
P=R P
y
x
y
x
f
f
f
f
cos
sin
sin
cos
'
'
17. Matrix Representation and
Homogeneous Coordinates
Many graphics applications involve sequences of geometric
transformations. Example
In animation, an object to be translated and rotated at each
increment of the motion.
In design and picture construction applications, translations,
rotations, and scalings are used to fit the picture components
into their proper positions.
Rotation and Scaling matrix are 2 by 2 and point P is multiplied with
matrix R or S
Translation matrix is 2 by 1 and it is add with point P
The multiplicative and translational terms for two-dimensional
geometric transformations into a single Matrix representation by
expanding the 2 by 2 matrix representations to 3 by 3 matrices.
This allows us to express all transformation equations as matrix
multiplications
18. Homogeneous Coordinates
Any 2D transformation can be described uniquely by a 3x3 matrix, if
the Cartesian coordinates (x, y) is represented by the homogeneous
coordinate triple (xh, yh, h),
where
h can be any real value ≠ 0,
for simplicity h=1 is used here
•The term homogeneous coordinates is used in mathematics to refer to the effect of
this representation on Cartesian equations.
•When a Cartesian point (x, y) is converted to a homogeneous representation (xh, yh,
h), equations containing x and y, such as f(x, y) = 0, become homogeneous equations
in the three parameters xh, yh, and h.
•This just means that if each of the three parameters is replaced by any value v times
that parameter, the value v can be factored out of the equations.
,
h h
x y
x y
h h
20. Homogeneous coordinate representation of 2D Rotation
This translation operation can be written in the
abbreviated form
'
( )
P R P
q
1
1
0
0
0
cos
sin
0
sin
cos
1
y
x
y
x
q
q
q
q
Homogeneous Matrix Representation
21. Homogeneous coordinate representation of 2D
Scaling
This scaling operation can be written in the
abbreviated form
1
1
0
0
0
0
0
0
1
y
x
s
s
y
x
y
x
'
( , )
P S sx sy P
Homogeneous Matrix Representation
22. Composite transformation matrix
We can set up a matrix for any sequence of
transformations as a composite transformation matrix
by calculating the matrix product of the individual
transformations.
Forming products of transformation matrices is often
referred to as a concatenation, or composition of
matrices.
23. Composite transformation matrix
Translations
If two successive translation vectors T(tx1, ty1) and T(tx1, ty1)
are applied to a coordinate position P (x, y) , the final
transformed location P/(x/, y/) is calculated as
P
t
t
T
t
t
T
P
P
t
t
T
t
t
T
P
y
x
y
x
y
x
y
x
)}.
,
(
).
,
(
{
}
).
,
(
).{
,
(
1
1
2
2
1
1
2
2
1
0
0
1
0
0
1
1
0
0
1
0
0
1
.
1
0
0
1
0
0
1
2
1
2
1
1
1
2
2
y
y
x
x
y
x
y
x
t
t
t
t
t
t
t
t
24. Composite transformation matrix
Rotation
Two successive rotations applied to point P(x, y) produce
the transformed position
P
R
P
R
R
R
P
R
R
P
R
R
P
).
(
Finally
)
(
)
(
).
(
But
)}.
(
).
(
{
}
).
(
).{
(
1
2
1
2
1
2
1
2
1
2
f
f
f
f
f
f
f
f
f
f
25. Composite transformation matrix
Scaling
Concatenating transformation matrices for two
successive scaling operations produces the following
composite scaling matrix
)
,
,
.
(
)
,
(
).
,
( 2
1
2
1
1
1
2
2 y
y
x
x
y
x
y
x s
s
s
s
S
s
s
S
s
s
S
1
0
0
0
.
0
0
0
.
1
0
0
0
0
0
0
.
1
0
0
0
0
0
0
2
1
2
1
1
1
2
2
y
y
x
x
y
x
y
x
s
s
s
s
s
s
s
s
26. General Two-Dimensional Pivot-Point
Rotation
we can generate a 2D rotation about any other pivot
point (xr, yr) by performing the following sequence of
translate-rotate-translate operations
1. Translate the object so that the pivot-point position is
moved to the coordinate origin.
2. Rotate the object about the coordinate origin.
3. Translate the object so that the pivot point is returned to
its original position.
27. General Two-Dimensional Pivot-Point
Rotation
1 0 1 0 cos sin (1 cos ) sin
cos sin 0
0 1 sin cos 0 0 1 sin cos (1 cos ) sin
0 0 1
0 0 1 0 0 1 0 0 1
r r r r
r r r r
x x x y
y y y x
q q q q
q q
q q q q q q
The composite transformation matrix for this sequence
is obtained with the concatenation:
(xr,yr) (xr,yr) (xr,yr)
(xr,yr)
•Which can be expressed in the form
( , ) ( ) ( , ) ( , , )
r r r r r r
T x y R T x y R x y
q q
28. General Fixed-Point Scaling
Similarly, we can obtain the matrix representation of
General 2D Fixed-Point Scaling.
(xr,yr) (xr,yr) (xr,yr) (xr,yr)
Translate Scale Translate
30. General 2D Scaling Directions
We can scale an object in other directions by rotating the
object to align the desired scaling directions with the
coordinate axes before applying the scaling transformation.
Suppose we want to apply scaling factors with values
specified by parameters s1 and s2 in the directions shown in
the following fig.
q
x
y s2
s1
31. General 2D Scaling Directions
To accomplish the scaling without changing the orientation of the object.
1. We first perform a rotation so that the directions for s1 and s2
coincide with the x and y axes, respectively.
2. Then the scaling transformation S(s1,s2) is applied.
3. An opposite rotation to return points to their original orientations.
1
0
0
0
cos
sin
sin
cos
)
(
0
sin
cos
)
(
sin
cos
)
(
)
,
(
)
( 2
2
2
1
1
2
1
2
2
2
2
1
2
1
1
q
q
q
q
q
q
q
q
q
q s
s
s
s
s
s
s
s
R
s
s
S
R
1
0
0
0
cos
sin
0
sin
cos
1
0
0
0
0
0
0
1
0
0
0
cos
sin
0
sin
cos
2
1
f
f
f
f
f
f
f
f
s
s
32. General 2D Scaling Directions
1
0
0
0
45
cos
2
45
sin
1
sin
cos
)
1
2
(
0
45
sin
45
cos
)
1
2
(
45
sin
2
45
cos
1
0
2
0
2
0
0
0
2
0
2
q
q
1
0
0
0
cos
sin
sin
cos
)
(
0
sin
cos
)
(
sin
cos
2
2
2
1
1
2
1
2
2
2
2
1
q
q
q
q
q
q
q
q
s
s
s
s
s
s
s
s
x
y
(0,0)
(3/2,1/2)
(1/2,3/2) (2,2)
x
y
(0,0) (1,0)
(0,1) (1,1)
Scale
For example, we turn a unit square into a parallelogram by
stretching it along the diagonal from (0,0) to (1,1).
1
0
0
0
2
/
3
2
/
1
0
2
/
1
2
/
3
1
1
.
2
/
3
2
/
1
2
/
1
2
/
3
2
2
1
1
0
.
1
0
0
0
2
/
3
2
/
1
0
2
/
1
2
/
3
1
2
/
3
2
/
1
33. Reflection
A reflection is a transformation that produces a mirror
image of an object.
x-axis y-axis origin
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
1
x
y 1
3
2
1’
3’
2’
x
y
1
3
2
1’
3’ 2
x
y
3
1’
3’ 2
1
2
34. Reflection
1
0
0
0
0
1
0
1
0
Reflection about the diagonal
y = x
Reflections about any line y = mx+c in the xy plane can be
accomplished with a combination of translate-rotate-reflect
transformations.
1. First translate the Line so that it passes through the origin.
2. Rotate the line onto one of the coordinate axes (x or y)
3. Reflect about that axis.
4. Restore the line to its original position with the inverse rotation and
translation transformations.
x
y
35. Shear
A transformation that distorts the shape of an object such
that the transformed shape appears as if the object were
composed of internal layers that had been caused to slide
over each other is called a shear.
Two common shearing transformations are those that shift
coordinate x values and those that shift y values.
An x-direction shear relative to the x axis is produced with
the transformation matrix
The value of shx may any real number
1
0
0
0
1
0
0
1 x
sh
x = x + shx · y, y = y
x
y
x
y
(0,0) (1,0)
(1,1)
(0,1)
(0,0) (1,0)
(3,1)
(2,1)
36. Shear
We can generate x-direction shears relative to other
reference lines with yref= - 1
Now, coordinate positions are transformed as
x = x + shx · (y - yref), y = y
1
0
0
0
1
0
1 ref
x
x y
sh
sh
The following Fig. illustrates the
conversion of a square into a
parallelogram with shy=0.5 and
yref= 1
37. Shear
Similarly an y-direction shear relative to the y axis is produced with
the transformation matrix
x = x, y = shy · x + y
Similarly we can generate y-direction shears relative to the lines
xref= - 1
Now, coordinate positions are transformed as
x = x + shy · (y - yref), y = y
1
0
0
0
1
0
0
1
y
sh
1
0
0
.
1
0
0
1
ref
y
y x
sh
sh
Shearing operations can be expressed as a
sequences of basic transformations. Such
as a series of rotation and scaling matrices
38. Coordinate Transformation
Coordinate transformation is simply reverse to geometric
transformation. Following figures illustrate this
4
2
3
4
Original
Transformed
41. Affine Transformation
Translation, Scaling, Rotation, Shearing are all affine
transformation
Affine transformation – transformed point P’ (x’,y’) is a
linear combination of the original point P (x,y), i.e.
x’ axx axy bx x
y’ = ayx ayy by y
1 0 0 1 1
• Affine transformations have the general properties
that parallel lines are transformed into parallel lines
and finite points map to finite points.
42. Affine Transformation
Another affine transformation is the conversion of coordinate
descriptions from one reference system to another, which can
be described as a combination of translation and rotation
An affine transformation involving only rotation, translation, and
reflection preserves angles and lengths, as well as parallel lines.
For these three transformations, the lengths and angle between
two lines remains the same after the transformation.
43. Composing Transformation
Composing Transformation – the process of applying
several transformation in succession to form one
overall transformation
If we apply transform a point P using M1 matrix first,
and then transform using M2, and then M3, then we
have:
(M3 x (M2 x (M1 x P ))) = M3 x M2 x M1 x P
M
(pre-multiply)
45. 3D matrices
Methods for geometric transformations in three
dimensions are extended from two-dimensional methods
by including considerations for the z coordinate.
A three-dimensional position, expressed in
homogeneous coordinates, is represented as a four-
element column vector. Thus , each geometric
transformation operator is now 4 by 4 matrix.
46. 3D Translation
Y
X
Z
(x, y, z)
(x, y , z )
T(tx, ty, tz)
TP = (x + tx, y + ty, z + tz)
1
0
0
0
1
0
0
0
1
0
0
0
1
z
y
x
t
t
t
1
z
y
x
1
0
0
0
1
0
0
0
1
0
0
0
1
z
y
x
t
t
t
1
z
y
x
Inverse Translation
47. 3D Scaling
SP = (sxx, syy, szz)
1
0
0
0
0
0
0
0
0
0
0
0
0
z
y
x
s
s
s
1
z
y
x
Inversion
48. General scaling
Scaling with respect to a selected fixed position (xf, yf, zf)
can be represented with the following transformation
sequence:
1. Translate the fixed point to the origin.
2. Scale the object relative to the coordinate origin
3. Translate the fixed point back to its original position.
52. General Rotation
Rotating about an axis that is parallel to one of the coordinates
axes.
Step1, Translate the object so that the rotation axis coincides
with the parallel coordinate axis.
Step2, Perform the specified rotation about that axis.
Step3, Translate the object so that rotation axis is moved back
to its original.
A coordinate position P is transformed with the sequence
' 1
( )
x
P T R T P
q
53. General Rotation
When an object is to be rotated about an axis that is not
parallel to one of the coordinate axes, we need to
perform some additional transformations.
1. Translate the object so that the rotation axis passes
through the coordinate origin
2. Rotate the object so that the axis of rotation coincides
with one of the coordinate axes.
3. Perform the specified rotation about that coordinate
axis.
4. Apply inverse rotations to bring the rotation axis back to
its original orientation.
5. Apply the inverse translation to bring the rotation axis
back to its original position.
56. 3D Shear
Shearing transformations can he
used to modify object shapes
the following transformation produces a
z-axis shear
1
0
0
0
0
1
0
0
0
1
0
0
0
1
y
x
sh
sh
1
z
y
x
x
z
y
x
z
y