jehee lee seoul national...

33
Transformations Jehee Lee Seoul National University

Upload: others

Post on 17-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Transformations

Jehee LeeSeoul National University

Page 2: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Transformations

• Linear transformations

• Rigid transformations

• Affine transformations

• Projective transformations

T

Global reference frame

Local moving frame

Page 3: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Linear Transformations

• A linear transformation T is a mapping between vector spaces– T maps vectors to vectors– linear combination is invariant under T

• In 3-space, T can be represented by a 3x3 matrix

)()()()( 11000

NN

N

iii TcTcTccT vvvv +++=å

=

!

major) (Row major)(Column )(

3331

1333

´´

´´

==

NvvMvT

Page 4: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Linear Transformations

• 2D rotation

• 2D scaling

÷÷ø

öççè

æ÷÷ø

öççè

æ -=÷÷

ø

öççè

梢

yx

yx

qqqq

cossinsincos

÷÷ø

öççè

æ÷÷ø

öççè

æ=÷÷ø

öççè

梢

yx

ss

yx

y

x

00

( )yx,( )yx ¢¢,

Page 5: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Linear Transformations

• 2D shear– Along X-axis

– Along Y-axis

÷÷ø

öççè

æ +=÷÷ø

öççè

æ÷÷ø

öççè

æ=÷÷

ø

öççè

梢

ydyx

yxd

yx

101

÷÷ø

öççè

æ+

=÷÷ø

öççè

æ÷÷ø

öççè

æ=÷÷

ø

öççè

梢

dxyx

yx

dyx

101

Page 6: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Linear Transformations

• 2D reflection– Along X-axis

– Along Y-axis

÷÷ø

öççè

æ-

=÷÷ø

öççè

æ÷÷ø

öççè

æ-

=÷÷ø

öççè

梢

yx

yx

yx

1001

÷÷ø

öççè

æ-=÷÷

ø

öççè

æ÷÷ø

öççè

æ-=÷÷

ø

öççè

梢

yx

yx

yx

1001

Page 7: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Properties of Linear Transformations

• Any linear transformation between 3D spaces can be represented by a 3x3 matrix

• Any linear transformation between 3D spaces can be represented as a combination of rotation, shear, and scaling

• Rotation can be represented as a combination of scaling and shear– Is this combination unique ?

Page 8: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Properties of Linear Transformations

• Rotation can be computed as two-pass shear transformations

Page 9: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Changing Bases

• Linear transformations as a change of bases

( )yx, ( )yx ¢¢,

0v

1v¢1v

0v¢

( ) ( ) ÷÷ø

öççè

æ=÷÷ø

öççè

梢

¢¢

+=¢¢+¢¢

yx

yx

yxyx

1010

1010

vvvv

vvvv

Page 10: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Changing Bases

• Linear transformations as a change of bases( )yx, ( )yx ¢¢,

0v

1v¢1v

0v¢

11001

11000

vvvvvv¢+¢=

¢+¢=bbaa ( ) ( )

÷÷ø

öççè

æ=

÷÷ø

öççè

æ÷÷ø

öççè

æ=÷÷

ø

öççè

梢

÷÷ø

öççè

æ÷÷ø

öççè

梢=÷÷

ø

öççè

梢

¢¢

yx

T

yx

baba

yx

yx

baba

yx

11

00

11

001010 vvvv

Page 11: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Affine Transformations

• An affine transformation T is a mapping between affine spaces– T maps vectors to vectors, and points to points– T is a linear transformation on vectors– affine combination is invariant under T

• In 3-space,T can be represented by a 3x3 matrix together with a 3x1 translation vector

)()()()( 11000

NN

N

iii TcTcTccT pppp +++=å

=

!

131333)( ´´´ += TpMpT

Page 12: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Properties of Affine Transformations

• Any affine transformation between 3D spaces can be represented by a 4x4 matrix

• Any affine transformation between 3D spaces can be represented as a combination of a linear transformation followed by translation

÷÷ø

öççè

æ÷÷ø

öççè

æ= ´´´

110)( 131333 pTMpT

Page 13: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Properties of Affine Transformations

• An affine transf. maps lines to lines

• An affine transf. maps parallel lines to parallel lines

• An affine transf. preserves ratios of distance along a line

• An affine transf. does not preserve absolute distances and angles

Page 14: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Affine Transformations

• 2D rotation

• 2D scaling

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ -=÷÷÷

ø

ö

ççç

è

梢

11000cossin0sincos

1yx

yx

qqqq( )yx,( )yx ¢¢,

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ=

÷÷÷

ø

ö

ççç

è

梢

11000000

1yx

ss

yx

y

x

Page 15: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Affine Transformations

• 2D shear

• 2D translation

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ=

÷÷÷

ø

ö

ççç

è

梢

110001001

1yxd

yx

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ=÷÷÷

ø

ö

ççç

è

梢

11001001

1yx

tt

yx

y

x

Page 16: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Affine Transformations

• 2D transformation for vectors– Translation is simply ignored

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ=÷÷÷

ø

ö

ççç

è

梢

01001001

0yx

tt

yx

y

x

Page 17: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Examples of Affine Transformations

• 3D rotation

÷÷÷÷÷

ø

ö

ççççç

è

æ

÷÷÷÷÷

ø

ö

ççççç

è

æ-

=

÷÷÷÷÷

ø

ö

ççççç

è

æ

¢¢¢

110000cossin00sincos00001

1zyx

zyx

qqqq÷÷

÷÷÷

ø

ö

ççççç

è

æ

÷÷÷÷÷

ø

ö

ççççç

è

æ -

=

÷÷÷÷÷

ø

ö

ççççç

è

æ

¢¢¢

11000010000cossin00sincos

1zyx

zyx

qqqq

÷÷÷÷÷

ø

ö

ççççç

è

æ

÷÷÷÷÷

ø

ö

ççççç

è

æ

-=

÷÷÷÷÷

ø

ö

ççççç

è

æ

¢¢¢

110000cos0sin00100sin0cos

1zyx

zyx

qq

qq

How can we rotate about an arbitrary line ?

Page 18: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Pivot-Point Rotation• Rotation with respect to a pivot point (x,y)

÷÷÷

ø

ö

ççç

è

æ--+--

=

÷÷÷

ø

ö

ççç

è

æ--

×÷÷÷

ø

ö

ççç

è

æ -×÷÷÷

ø

ö

ççç

è

æ=

--××

100sin)cos1(cossinsin)cos1(sincos

1001001

1000cossin0sincos

1001001

),()(),(

qqqqqqqq

qqqq

q

xyyx

yx

yx

yxTRyxT

Page 19: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Fixed-Point Scaling• Scaling with respect to a fixed point (x,y)

÷÷÷

ø

ö

ççç

è

æ×-×-

=

÷÷÷

ø

ö

ççç

è

æ--

×÷÷÷

ø

ö

ççç

è

æ×÷÷÷

ø

ö

ççç

è

æ=

--××

100)1(0)1(0

1001001

1000000

1001001

),(),(),(

yssxss

yx

ss

yx

yxTssSyxT

yy

xx

y

x

yx

Page 20: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Scaling Direction

• Scaling along an arbitrary axis

)(),()(1 qq RssSR yx ××-

)(1 q-R),( yx ssS)(qR

Page 21: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composite Transformations

• Composite 2D Translation

),(

),(),(

2121

2211

yyxx

yxyx

ttttttttT

++=

×=

TTT

÷÷÷

ø

ö

ççç

è

æ++

=÷÷÷

ø

ö

ççç

è

æ×÷÷÷

ø

ö

ççç

è

æ

1001001

1001001

1001001

21

21

1

1

2

2

yy

xx

y

x

y

x

tttt

tt

tt

Page 22: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composite Transformations

• Composite 2D Scaling

),(

),(),(

2121

2211

yyxx

yxyx

ssssssssT

SSS

=

×=

÷÷÷

ø

ö

ççç

è

æ×

×=

÷÷÷

ø

ö

ççç

è

æ×÷÷÷

ø

ö

ççç

è

æ

1000000

1000000

1000000

21

21

1

1

2

2

yy

xx

y

x

y

x

ssss

ss

ss

Page 23: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composite Transformations

• Composite 2D Rotation

)()()(

12

12

qqqq

+=×=

RRRT

÷÷÷

ø

ö

ççç

è

æ+++-+

=÷÷÷

ø

ö

ççç

è

æ -×÷÷÷

ø

ö

ççç

è

æ -

1000)cos()sin(0)sin()cos(

1000cossin0sincos

1000cossin0sincos

1212

1212

11

11

22

22

qqqqqqqq

qqqq

qqqq

Page 24: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composing Transformations

• Suppose we want,

• We have to compose two transformations

)90( °-R )3,(xT

Page 25: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composing Transformations

• Matrix multiplication is not commutative

)3,()90()90()3,( xx TRRT °-¹°-×

Translationfollowed by

rotation

Translationfollowed by

rotation

Page 26: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Composing Transformations

– R-to-L : interpret operations w.r.t. fixed coordinates

– L-to-R : interpret operations w.r.t local coordinates

pRTp )90()3,( °-×= xT

)90( °-R )3,(xT

)90( °-R)3,(xT

(Column major convention)

Page 27: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Review of Affine Frames

• A frame is defined as a set of vectors {vi | i=1, …, N} and a point o– Set of vectors {vi} are bases of the associate vector

space– o is an origin of the frame– N is the dimension of the affine space– Any point p can be written as

– Any vector v can be written as

NNccc vvvop ++++= !2211

NNccc vvvv +++= !2211

Page 28: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Changing Frames

• Affine transformations as a change of frame

( )yx,

0v

1v

( ) ( )÷÷÷

ø

ö

ççç

è

æ=

÷÷÷

ø

ö

ççç

è

梢

¢¢¢

++=¢+¢¢+¢¢

111010

1010

yx

yx

yxyx

ovvovv

ovvovv

0v¢1v¢

o

Page 29: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Changing Frames

• Affine transformations as a change of frame

ovvovvvvvv

¢+¢+¢=

¢+¢=

¢+¢=

100

11001

11000

ccbbaa ( ) ( )

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

æ=

÷÷÷

ø

ö

ççç

è

梢

÷÷÷

ø

ö

ççç

è

æ

÷÷÷

ø

ö

ççç

è

梢=

÷÷÷

ø

ö

ççç

è

梢

¢¢

11001

11001

111

000

111

000

1010

yx

cbacba

yx

yx

cbacba

yx

ovvovv

( )yx,

0v

1v0v¢

1v¢

o

Page 30: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Rigid Transformations

• A rigid transformation T is a mapping between affine spaces– T maps vectors to vectors, and points to points– T preserves distances between all points– T preserves cross product for all vectors (to avoid

reflection)• In 3-spaces, T can be represented as

1det and

where,)( 131333

===

+= ´´´

RIRRRRTpRp

TT

T

Page 31: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Rigid Body Transformations

• Rigid body transformations allow only rotation and translation

• Rotation matrices form SO(3)– Special orthogonal group

IRRRR == TT

1det =R

(Distance preserving)

(No reflection)

Page 32: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Summary

• Linear transformations– 3x3 matrix– Rotation + scaling + shear

• Rigid transformations– SO(3) for rotation– 3D vector for translation

• Affine transformation– 3x3 matrix + 3D vector or 4x4 homogenous matrix– Linear transformation + translation

• Projective transformation– 4x4 matrix– Affine transformation + perspective projection

Page 33: Jehee Lee Seoul National Universitymrl.snu.ac.kr/courses/CourseAnimation/ComputerAnimationLecture… · Linear Transformations • A linear transformation T is a mapping between vector

Questions

• What is the composition of linear/affine/rigid transformations ?

• What is the linear (or affine) combination of linear (or affine) transformations ?

• What is the linear (or affine) combination of rigid transformations ?