Professional Documents
Culture Documents
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
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
3. Translation and Rotation:
homogeneous coordinates
• Each of the above transformations with the exception
of translation can be represented as a row vector X,
Y and a 2 X 2 matrix. All the transformations above
can be represented as a product of a 1 X 3 row vector
and an appropriate 3 X 3 matrix.
• The conversion of a two-dimensional co-ordinate pair
(X, Y) into a 3-dimensional vector can be achieved
by representing the point as [X Y 1]. After
multiplying this vector by a 3 X 3 matrix, another
homogeneous row vector is obtained [X1 Y1 1].
• The first two terms in this vector are the co-ordinate
pair which is the transform of (X, Y). This three-
dimensional representation of a two- dimensional
plane is called homogeneous coordinates and the
transformation using the homogeneous co-ordinates
is called homogeneous transformation. The matrix
representations of the four basic transformations are
given below.
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 s x , y y s y
Sx x s x 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
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
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
Directional Scaling
x
S2
R 1 S S1 , S 2 R
S2 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
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
a x2 x1 | V | y u a, b, c
b y2 y1 | V |
c z2 z1 | V |
x
a 2 b2 c 2 1
z
Rotating u to coincide with z 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 T1 R x 1 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 T1 R x 1 R y1 R z R y R x T
M R
q s ia jb kc s , v s : real v a, b, c : imaginary
Addition: q1 q2 s1 s2 , v1 v 2
1
2
s, v , qq 1 q 1q 1, 0
2 2 1
q s v v, q
q
Rotate a point position p x, y, z about the unit vector u.
y
Quarternion representation:
u
Rotation: q cos , u sin
2 2
x Position: P 0, p , p x, y , z
z
Rotation of P is carried out with the quarternion operation:
P qPq 1 0, s 2p v p v 2 s v p v v p
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 SP
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 S x x f
T S T1
0 Sy 0 1 S y y f
xf , yf , z f 0 0 Sz 1 S z z f
0 0 0 1
z x
3. 3D affine transformations
Other 3D affine transformations
MATRIX NOTATION
(review)