modeling transformation
DESCRIPTION
Modeling Transformation. Overview. 2D Transformation Basic 2D transformations Matrix representation Matrix Composition 3D Transformation Basic 3D transformations Same as 2D Transformation Hierarchies Scene graphs Ray casting. Modeling Transformation. - PowerPoint PPT PresentationTRANSCRIPT
Modeling Transformation
Overview
2D Transformation Basic 2D transformations Matrix representation Matrix Composition
3D Transformation Basic 3D transformations Same as 2D
Transformation Hierarchies Scene graphs Ray casting
Modeling Transformation
Specify transformations for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene
Ref] Hearn & Baker
2D Modeling Transformations
2D Modeling Transformations
Basic 2D Transformations
Translation x’ = x + tx y’ = y + ty
Scale x’ = x * sx y’ = y * sy
Shear x’ = x + hx * y y’ = y + hy * x
Rotation x’ = x * cos - y * sin y’ = x * sin + y * cos
Matrix Representation
Represent 2D transformation by a matrix
Multiply matrix by column vector Apply transformation to point
dc
ba
y
x
dc
ba
y
x
'
'
dycxy
byaxx
'
'
Matrix Representation
Transformations combined by multiplication
Matrices are a convenient and efficient way to represent a sequence of transformations
y
x
lk
ji
hg
fe
dc
ba
y
x
'
'
2 x 2 Matrices
What types of transformations can be represented with a 2 x 2 matrix? 2D Identity
2D Scale around (0, 0)
y
x
y
x
10
01
'
'
yy
xx
'
'
y
x
sy
sx
y
x
0
0
'
'
ysyy
xsxx
'
'
2 x 2 Matrices
What types of transformations can be represented with a 2x 2 matrix? 2D Rotate around (0, 0)
2D Shear
y
x
y
x
cossin
sincos
'
'
yxy
yxx
cossin'
sincos'
y
x
shy
shx
y
x
1
1
'
'
yxshyy
yshxxx
'
'
shx = 2
2 x 2 Matrices
What types of transformations can be represented with a 2x 2 matrix? 2D Mirror (=Reflection) over Y axis
2D Mirror over (0, 0)
y
x
y
x
10
01
'
'
yy
xx
'
'
y
x
y
x
10
01
'
'
yy
xx
'
'
2 x 2 Matrices
What types of transformations can be represented with a 2x 2 matrix? 2D Translation ?
tyyy
txxx
'
'NO!
Only linear 2D transformation can be presented with a 2 x 2 matrix
Linear Transformations
Linear transformations are combinations of … Scale Rotation Shear Mirror (=Reflection)
Properties of linear transformations Satisfies: Origin maps to origin Lines map to lines Parallel line remain parallel Ratios are preserved Closed under composition
y
x
dc
ba
y
x
'
'
)()()( 221221 pppp 11 TsTsssT
2D Translation
2D Translation represented by a 3 x 3 matrix Point represented with homogeneous coordinate
tyyy
txxx
'
'
1100
10
01
1
'
'
y
x
ty
tx
y
x
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
Basic 2D Transformations
Basic 2D Transformations as 3 x 3 matrices
Affine Transformations
Affine Transformations are combinations of … Linear transformation Translation
Properties of affine transformations Origin does not necessarily map to origin Lines map to lines Parallel line remain parallel Ratios are preserved Closed under composition
w
y
x
fed
cba
w
y
x
100
'
'
Transformation : Rigid-Body / Euclidean Transforms
Rigid Body Transformation (=rigid motion) A transform made up of only translation and rotation Preserve the shape of the objects that they act on
• Preserves distances
• Preserves angles
TranslationRotation
Rigid / Euclidean
Identity
Transformation : Similitudes / Similarity Transforms
Similarity Transformations Preserves angles Translation, Rotation,
Isotropic scaling
TranslationRotation
Rigid / Euclidean
Similitudes
Isotropic ScalingIdentity
Transformation : Linear Transformations
TranslationRotation
Rigid / EuclideanLinear
Similitudes
Isotropic ScalingIdentity
Scaling
Shear
Reflection
Translation is not linear
Transformation : Affine Transformations
preserves parallel lines
TranslationRotation
Rigid / EuclideanLinear
Similitudes
Isotropic Scaling
Scaling
Shear
ReflectionIdentity
Affine
Transformation : Projective Transformations
preserves lines
TranslationRotation
Rigid / EuclideanLinear
Affine
Projective
Similitudes
Isotropic Scaling
Scaling
Shear
Reflection
Perspective
Identity
Projective Transformations
Projective Transformations … Affine transformation Projective warps
Properties of projective transformations Origin does not necessarily map to origin Lines map to lines Parallel line do not necessarily remain parallel Ratios are not preserved (but “cross-ratios” are) Closed under composition
w
y
x
ihg
fed
cba
w
y
x
'
'
Cross-ratio
Given any four points A, B, C, and D, taken in order, define their cross ratio as
Cross Ratio (ABCD) =
DBDACBCA
cross ratio (ABCD) = cross ratio (A'B'C'D')
Matrix Composition
Transformations can be combined by matrix multiplication
Matrix Composition
Matrices are a convenient and efficient way to represent a sequence of transformations General purpose representations Hardware matrix multiply Efficiency with premultiplication
p
p
)('
)))((('
SRTp
SRTp
Matrix Composition
Be aware: order of transformations matter Matrix multiplication is not commutative
p SRTp'“Global” “Local”
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
Translate then Scale: p' = S ( T p ) = ST p
(0,0)
(1,1)(4,2)
(3,1)
(8,4)
(6,2)
(0,0)
(1,1)(2,2)
(0,0)
(5,3)
(3,1)Scale(2,2) Translate(3,1)
Translate(3,1) Scale(2,2)
Matrix Composition
Rotate by around arbitrary point (a, b) M = T(a, b)* R() * T(-a, -b)
1. Translate (a, b) to the origin
2. do the rotation about origin
3. translate back
Scale by sx, sy around arbitrary point (a, b) M = T(a, b)* S(sx, sy) * T(-a, -b)
1. Translate (a, b) to the origin
2. do the scale about origin
3. translate back
Transformation Game
Overview
2D Transformation Basic 2D transformations Matrix representation Matrix Composition
3D Transformation Basic 3D transformations Same as 2D
Transformation Hierarchies Scene graphs Ray casting
3D Transformations
Same idea as 2D transformations Homogeneous coordinates: (x, y, z, w) 4 x 4 transformation matrices
w
z
y
x
ponm
lkji
hgfe
dcba
w
z
y
x
'
'
'
Basic 3D transformations
Basic 3D transformations
Non-commutative Composition : Order of Rotations
Order of Rotation Affects Final Position X-axis Z-axis
Z-axis X-axis
Matrix Composition : Rotations in space
Rotation about an Arbitrary Axis Rotate about some arbitrary a through angle
1. Rotate about the z axis through an angle – The axis a lies in the yz plane
2. Rotate about the x axis through an angle – The axis a coincident with the z axis
3. Rotate about the a axis through – Same as a rotation about the now coincident z axis
4. Reverse the second rotation about the x axis
5. Reverse the first rotation about the z axis– Returning the axis a to its original position
PRP '
PRRP '
PRRRP 'PRRRRP
1'
PRRRRRP 11 ' y
z
x
a
Transformation Hierarchies
Scene may have hierarchy of coordinate systems Each level stores matrix representing transformation from
parent’s coordinate system
Transformation Example 1
Well-suited for humanoid characters
Transformation Example 1
Ref] Princeton University
Transformation Example 2
An object may appear in a scene multiple times
Transformation Example 2
Summary
Coordinate systems World coordinates Modeling coordinates
Representations of 3D modeling transformations 4 x 4 Matrices
• Scale, rotate, translate, shear, projections, etc.
• Not arbitrary warps
Composition of 3D transformations Matrix multiplication (order matters) Transformation hierarchies