Geometrical
Transformations
Chapter 2
2D Geometrical Transformations
• Consider the red
triangle
- What
transformation would
map the triangle
onto: triangle A,
triangle B, triangle C,
triangle D?
- What single
transformation would
map triangle A onto
triangle C?
TRANSFORMATIONS
• A change in the size, shape, orientation or position
of an object is called a transformation.
• Reflections, rotations, translations and
enlargements are transformations. We can
describe these transformations mathematically
using transformation geometry.
• In transformation geometry figures are changed
(or transformed) in size, shape, orientation or
position according to certain rules.
• The original figure is called the object and the new
figure is called the image
• Translations where every point moves a fixed
distance in each direction
• Reflections or mirror images
• Rotations about a point through a given angle
• Enlargements and reductions about a point with a
given factor
• Stretches with a given invariant line and a given
factor.
• Why are geometric transformations
necessary?
- For positioning geometric objects in 2D and 3D.
- For modeling geometric objects in 2D and 3D
- For viewing geometric objects in 2D and 3D
1. Translations
• A translation moves an object from one place to another.
Every point on the object moves the same distance in the same
direction
y
P
P x
x’= x + Δx
y’= y + Δy
• Translating a point (x, y) means to move it by (Δx, Δy).
• Matrix representation
2. Rotations
• When P(x, y) moves
under a rotation about O
through an angle of to
a new position P’(x’, y’),
then OP = OP’ and POP’
= where positive μ is
measured anticlockwise.
• O is the only point
which does not move
under the rotation.
• Matrix representation
Rotation in angle about a pivot (rotation) point
y (xr, yr)
yr
x
xr x xr x xr cos y yr sin
y
x, y y yr x xr sin y yr cos
P Pr R P Pr
x, y
cos sin
R
xr , yr x sin cos
Fundamental problem of geometric
transformations
• Translation is not a linear transformation of x and y.
• Consequence: we are not allowed to But a sequence of
transformations (translations and rotations) through a
product of matrices 2x2.
• But we can always produce k rotations by computing
the product of k rotation matrices.
- SOLUTION: homogeneous coordinates!
• A triple of real numbers (x, y, t), with t ≠ 0, is a set
of homogeneous coordinates for the point P with
cartesian coordinates (x/t, y/t)
• Thus, the same point has many sets of
homogeneous coordinates. So, (x, y, t) and
(x’, y’, t’) represent the same point if and
only if there is some real scalar α such that
x’ = α x, y’ = α y and t’ = α t
• So, if P has cartesian coordinates (x,y), one
set of homogeneous coordinates for P is
(x,y,1), being this set the most used in
computer graphics
• Set of geometric transformations:
translations and rotations (also called
isometries).
• By using homogeneous coordinates, these
transformations can be represented through
matrices 3x3. This enables the use of
product operator for matrices to evaluate a
sequence of translations and rotations
3. Translation and Rotation:
homogeneous coordinates
4. Scaling
Scaling an object consists of multiplying each of its
point component x and y by a scalar λx and λy,
respectively
x x sx , y y s y
Sx x sx 0 x
y 0
s y y
Sy
P S P
y Scaling about a fixed point x f , y f
x x sx x f 1 sx
x f , yf y y s y y f 1 s y
x
P P S P f 1 - S
Non-uniform scaling
• Non-uniform scaling an object consists of multiplying
each of its point component x and y by a scalar λx
and λy, respectively, with λx ≠ λy.
5. Shearing
• Shearing an object consists of linearly deforming it
along either x-axis or y-axis or both.
6. Matrix 3x3 for 2D
affine transformations
6.1 General Rotation
Move to origin Rotate Move back
xr , yr
1 0 xr cos sin 0 1 0 xr
0 1 yr sin cos 0 0 1 yr
0 0 1 0 0 1 0 0 1
cos sin xr 1 cos yr sin
sin cos yr 1 cos xr sin
0 0 1
6.2 General Scaling
Move to origin Scale Move back
x f , yf
1 0 x f Sx 0 0 1 0 x f S x 0 x f 1 S x
0 1
y f 0 Sy
0 0 1 y f 0 Sy y f 1 S y
0 0 1 0 0 1 0 0 1 0 0 1
6.3 Directional Scaling
x
S2
R 1 S S1 , S 2 R
S1 cos 2 S2 sin 2 S2 S1 cos sin 0
y S 2 S1 cos sin S1 sin 2 S2 cos 2 0
0 0 1
S1
x x
S1 1
S 2 2
45O
y y
3D Geometrical
Transformations
Very similar to 2D. Using 4x4 matrices rather than 3x3 .
Translation x x t x
y
y y t y
z z t z
x, y, z x 1 0 0 tx x
x, y , z y 0
1 0 t y y
z 0 0 1 tz z
z x
1 0 0 0 1 1
1. General 3D Rotation
1. Translate the object such that rotation axis passes
through the origin.
2. Rotate the object such that rotation axis coincides
with one of Cartesian axes.
3. Perform specified rotation about the Cartesian axis.
4. Apply inverse rotation to return rotation axis to
original direction.
5. Apply inverse translation to return rotation axis to
original position.
y y y
P2
P2
P1
P1 P1
x x x
P2
z z z
y y y
P2 P2
P1 P1 P1
P2 x x x
z z z
1 0 0 x1
0 1 0 y1
The vector from P1 to P2 is: T
0 0 1 z1
V P2 P1 x2 x1 , y2 y1 , z2 z1 0 0 0 1
Unit rotation vector: u V | V |a, b, c
a x2 x1 | V | y u a, b, c
b y2 y1 | V |
c z2 z1 | V |
x
a 2 b 2 c 2 1
z
Rotating u to coincide with z axis
First rotate u around x axis to lay in x z plane.
Equivqlent to rotation u 's projection on y z plane around x axis.
cos c b 2 c 2 c d , sin b d .
We obtained a unit vector w a, 0, b 2 c 2 d in x z plane.
y u a, b, c
1 0 0 0
0 c d b d 0 u
R x
0 b d c d 0
x
0 0 0 1
z
Rotate w counterclockwise around y axis.
w is a unit vector whose x component is a, y component is 0,
hence z component is b 2 c 2 d . y u a, b, c
cos d , sin a
d 0 a 0 x
0 1 0 0
R y
a 0 d 0 z
0 0 0 1 w a, 0, d
R T 1 R x1 R y1 R z R y R x T
cos sin 0 0
sin cos 0 0
R z
0 0 1 0
0 0 0 1
R T 1 R x1 R y1 R z R y R x T
M R
a 2 1 cos cos ab 1 cos c sin ac 1 cos b sin
2
ba 1 cos c sin b 1 cos cos bc 1 cos a sin
ca 1 cos b sin cb 1 cos a sin c 2 1 cos cos
2. 3D Scaling
y y
x x S x
y y S y
z x S z
z x z x
Enlarging object also moves it from origin
x S x 0 0 0 x
y 0 Sy 0 0 y
P S P
z 0 0 Sz 0 z
1 0 0 0 1 1
Scaling with respect to a fixed point (not necessarily of object )
y y y
x f , yf , zf x f , yf , zf x f , yf , zf
z x z x z x
y
Sx 0 0 1 Sx x f
1
T S T 0 Sy 0 1 S y y f
x f , y f , z f 0 0 Sz 1 S z z f
0 0 0 1
z x
3D affine transformations
Other 3D affine transformations
MATRIX NOTATION
(review)