Modeling Transformation

42
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 Presentation

Transcript of Modeling Transformation

Page 1: Modeling Transformation

Modeling Transformation

Page 2: 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

Page 3: Modeling Transformation

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

Page 4: Modeling Transformation

2D Modeling Transformations

Page 5: Modeling Transformation

2D Modeling Transformations

Page 6: Modeling Transformation

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

Page 7: Modeling Transformation

Matrix Representation

Represent 2D transformation by a matrix

Multiply matrix by column vector Apply transformation to point

dcba

yx

dcba

yx''

dycxybyaxx

''

Page 8: Modeling Transformation

Matrix Representation

Transformations combined by multiplication

Matrices are a convenient and efficient way to represent a sequence of transformations

yx

lkji

hgfe

dcba

yx''

Page 9: Modeling Transformation

2 x 2 Matrices

What types of transformations can be represented with a 2 x 2 matrix? 2D Identity

2D Scale around (0, 0)

yx

yx

1001

''

yyxx

''

yx

sysx

yx

00

''

ysyyxsxx

''

Page 10: Modeling Transformation

2 x 2 Matrices

What types of transformations can be represented with a 2x 2 matrix? 2D Rotate around (0, 0)

2D Shear

yx

yx

cossinsincos

''

yxyyxx

cossin'sincos'

yx

shyshx

yx

11

''

yxshyyyshxxx

''

shx = 2

Page 11: Modeling Transformation

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)

yx

yx

1001

''

yyxx

''

yx

yx

1001

''

yyxx

''

Page 12: Modeling Transformation

2 x 2 Matrices

What types of transformations can be represented with a 2x 2 matrix? 2D Translation ?

tyyytxxx

''

NO!

Only linear 2D transformation can be presented with a 2 x 2 matrix

Page 13: Modeling Transformation

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

yx

dcba

yx

''

)()()( 221221 pppp 11 TsTsssT

Page 14: Modeling Transformation

2D Translation

2D Translation represented by a 3 x 3 matrix Point represented with homogeneous coordinate

tyyytxxx

''

11001001

1''

yx

tytx

yx

Page 15: Modeling Transformation

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

Page 16: Modeling Transformation

Basic 2D Transformations

Basic 2D Transformations as 3 x 3 matrices

Page 17: Modeling Transformation

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

wyx

fedcba

wyx

100''

Page 18: Modeling Transformation

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

Page 19: Modeling Transformation

Transformation : Similitudes / Similarity Transforms

Similarity Transformations Preserves angles Translation, Rotation, Isotropic scaling

TranslationRotation

Rigid / Euclidean

Similitudes

Isotropic ScalingIdentity

Page 20: Modeling Transformation

Transformation : Linear Transformations

TranslationRotation

Rigid / EuclideanLinear

Similitudes

Isotropic ScalingIdentity

Scaling

Shear

Reflection

Translation is not linear

Page 21: Modeling Transformation

Transformation : Affine Transformations

preserves parallel lines

TranslationRotation

Rigid / EuclideanLinear

Similitudes

Isotropic Scaling

Scaling

Shear

ReflectionIdentity

Affine

Page 22: Modeling Transformation

Transformation : Projective Transformations

preserves lines

TranslationRotation

Rigid / EuclideanLinear

Affine

Projective

Similitudes

Isotropic Scaling

Scaling

Shear

Reflection

Perspective

Identity

Page 23: Modeling Transformation

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

wyx

ihgfedcba

wyx

''

Page 24: Modeling Transformation

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')

Page 25: Modeling Transformation

Matrix Composition

Transformations can be combined by matrix multiplication

Page 26: Modeling Transformation

Matrix Composition

Matrices are a convenient and efficient way to represent a sequence of transformations General purpose representations Hardware matrix multiply Efficiency with premultiplication

pp

)(')))((('

SRTpSRTp

Page 27: Modeling Transformation

Matrix Composition

Be aware: order of transformations matter Matrix multiplication is not commutative

p SRTp'“Global” “Local”

Page 28: Modeling Transformation

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)

Page 29: Modeling Transformation

Matrix Composition

Rotate by around arbitrary point (a, b) M = T(a, b)* R() * T(-a, -b)

1. Translate (a, b) to the origin2. do the rotation about origin3. 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 origin2. do the scale about origin3. translate back

Page 31: 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

Page 32: Modeling Transformation

3D Transformations

Same idea as 2D transformations Homogeneous coordinates: (x, y, z, w) 4 x 4 transformation matrices

wzyx

ponmlkjihgfedcba

wzyx

'''

Page 33: Modeling Transformation

Basic 3D transformations

Page 34: Modeling Transformation

Basic 3D transformations

Page 35: Modeling Transformation

Non-commutative Composition : Order of Rotations

Order of Rotation Affects Final Position X-axis Z-axis

Z-axis X-axis

Page 36: Modeling Transformation

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 axis5. 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

Page 37: Modeling Transformation

Transformation Hierarchies

Scene may have hierarchy of coordinate systems Each level stores matrix representing transformation from

parent’s coordinate system

Page 38: Modeling Transformation

Transformation Example 1

Well-suited for humanoid characters

Page 39: Modeling Transformation

Transformation Example 1

Ref] Princeton University

Page 40: Modeling Transformation

Transformation Example 2

An object may appear in a scene multiple times

Page 41: Modeling Transformation

Transformation Example 2

Page 42: Modeling Transformation

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