Professional Documents
Culture Documents
Jason Lawrence
CS 4810: Graphics
Modeling Transformations
Specify transformations for objects
Allows definitions of objects in own coordinate systems
Allows use of object definition multiple times in a scene
Overview
2D Transformations
Basic 2D transformations
Matrix representation
Matrix composition
3D Transformations
Basic 3D transformations
Same as 2D
Simple 2D Transformations
Translation
y
P
Simple 2D Transformations
Translation
Simple 2D Transformations
Scale
z
x
Simple 2D Transformation
Rotation
z
x
2D Modeling Transformations
Modeling
Coordinates
y
Scale
Translate
Scale
Rotate
Translate
World Coordinates
Wednesday, October 10, 12
2D Modeling Transformations
Modeling
Coordinates
y
x
Lets look
at this in
detail
World Coordinates
Wednesday, October 10, 12
2D Modeling Transformations
Modeling
Coordinates
y
x
2D Modeling Transformations
Modeling
Coordinates
y
x
Scale .3, .3
Rotate -90
Translate 5, 3
2D Modeling Transformations
Modeling
Coordinates
y
x
Scale .3, .3
Rotate -90
Translate 5, 3
2D Modeling Transformations
Modeling
Coordinates
y
x
Scale .3, .3
Rotate -90
Translate 3, 5
World Coordinates
Wednesday, October 10, 12
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
Transformations
can be combined
(with simple algebra)
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
(x,y)
(x,y)
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
x = x*sx
y = y*sy
Wednesday, October 10, 12
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
(x,y)
x = (x*sx)*cos (y*sy)*sin
y = (x*sx)*sin + (y*sy)*cos
Wednesday, October 10, 12
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
(x,y)
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
x = ((x*sx)*cos (y*sy)*sin) + tx
y = ((x*sx)*sin + (y*sy)*cos) + ty
Wednesday, October 10, 12
Basic 2D Transformations
Translation:
x = x + tx
y = y + ty
Scale:
x = x * sx
y = y * sy
Rotation:
x = x*cos - y*sin
y = x*sin + y*cos
x = ((x*sx)*cos (y*sy)*sin) + tx
y = ((x*sx)*sin + (y*sy)*cos) + ty
Wednesday, October 10, 12
Overview
2D Transformations
Basic 2D transformations
Matrix representation
Matrix composition
3D Transformations
Basic 3D transformations
Same as 2D
Matrix Representation
Represent 2D transformation by a matrix
Matrix Representation
Transformations combined by multiplication
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Scale around (0,0)?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Translation?
2x2 Matrices
What types of transformations can be
represented with a 2x2 matrix?
2D Translation?
NO!
Linear Transformations
Linear transformations are combinations of
Scale, and
Rotation
Linear Transformations
Linear transformations are combinations of
Scale, and
Rotation
Homogeneous Coordinates
Add a 3rd coordinate to every 2D point
(x, y, w) represents a point at location (x/w, y/w)
(x, y, 0) represents a point at infinity
(0, 0, 0) is not allowed
y
2
1
1
2D Translation
2D translation represented by a 3x3 matrix
Point represented with homogeneous coordinates
2D Translation
2D translation represented by a 3x3 matrix
Point represented with homogeneous coordinates
Basic 2D Transformations
Basic 2D transformations as 3x3 matrices
Translate
Scale
Rotate
Affine Transformations
Affine transformations are combinations of
Linear transformations, and
Translations
Projective Transformations
Projective transformations
Affine transformations, and
Projective warps
Overview
2D Transformations
Basic 2D transformations
Matrix representation
Matrix composition
3D Transformations
Basic 3D transformations
Same as 2D
Matrix Composition
Transformations can be combined by
matrix multiplication
p =
T(tx,ty)
R()
S(sx,sy)
Matrix Composition
Matrices are a convenient and efficient way to
represent a sequence of transformations!
General purpose representation
Hardware matrix multiply
Efficiency with pre-multiplication
Matrix multiplication is associative
p = (T * (R * (S*p) ) )
p = (T*R*S) * p
Wednesday, October 10, 12
Matrix Composition
Be aware: order of transformations matters
Matrix multiplication is not commutative
p = T * R * S * p
Global
Local
Matrix Composition
Rotate by around arbitrary point (a,b)
(a,b)
(a,b)
Matrix Composition
Rotate by around arbitrary point (a,b)
M=T(a,b) * R() * T(-a,-b)
The trick:
First, translate (a,b) to the origin.
Next, do the rotation about origin.
Finally, translate back.
(a,b)
(a,b)
Overview
2D Transformations
Basic 2D transformations
Matrix representation
Matrix composition
3D Transformations
Basic 3D transformations
Same as 2D
3D Transformations
Same idea as 2D transformations
Homogeneous coordinates: (x,y,z,w)
4x4 transformation matrices
Basic 3D Transformations
Identity
Scale
Translation
Basic 3D Transformations
Pitch-Roll-Yaw Convention:
Any rotation can be expressed as the combination of a
rotation about the x-, the y-, and the z-axis.
Rotate around Z axis:
Basic 3D Transformations
Pitch-Roll-Yaw Convention:
Any rotation can be expressed as the combination of a
rotation about the x-, the y-, and the z-axis.
Rotate around Z axis:
U
z
T(a,b,c)
x
Ry() Rx()
x
z
U
x
Aligning Transformation
Wednesday, October 10, 12