+ All Categories
Home > Documents > Transformations I

Transformations I

Date post: 31-Dec-2015
Category:
Upload: zaviera-nunez
View: 27 times
Download: 0 times
Share this document with a friend
Description:
Transformations I. CS5600 Computer Graphics by Rich Riesenfeld 27 February 2002. Lecture Set 5. Transformations and Matrices. Transformations are functions Matrices are functions representations Matrices represent linear transf’s. What is a 2D Linear Transf ?. - PowerPoint PPT Presentation
Popular Tags:
133
Transformations I CS5600Computer Graphics by Rich Riesenfeld 27 February 2002 Lecture Set 5
Transcript
Page 1: Transformations I

Transformations I

CS5600Computer Graphicsby

Rich Riesenfeld

27 February 2002Lect

ure

Set

5

Page 2: Transformations I

CS5600 2

Transformations and Matrices

• Transformations are functions

• Matrices are functions representations

• Matrices represent linear transf’s

• s'TransfLinear 2Matrices22 Dx

Page 3: Transformations I

CS5600 3

What is a 2D Linear Transf ?

Recall from Linear Algebra:

. and vectorsand ascalar for

,)()()(:

yx

yTxaTyxaTDefinition

Page 4: Transformations I

CS5600 4

Example: Scale in x

),2(),2(),(2

:say 2,by in x, Scale

11001010 yxyxyyxx

Page 5: Transformations I

CS5600 5

Example: Scale in x by 2

What is the graphical view?

Page 6: Transformations I

CS5600 6

), 00( yx ), 002( yx

), 11( yx ), 112( yx

Scale in x by 2y

x

Page 7: Transformations I

CS5600 7

x

y

), 002( yx

), 112( yx

yyxx 1010 ,22

yyxx 1010 ,22

Page 8: Transformations I

CS5600 8

y

), 00( yx

), 11( yx

yyxx 1010 ),(2

yyxx 1010 ),(

yyxx 1010 ),(2

x

Page 9: Transformations I

CS5600 9

y

yyxx 1010 ),(2

yyxx 1010 ),(

yyxx 1010 ),(2 y

x

Page 10: Transformations I

CS5600 10

Summary on Scale

• “Scale then add,” is same as

• “Add then scale”

Page 11: Transformations I

CS5600 11

Matrix Representation

y

x

y

x 2

10

02

Scale in x by 2:

Page 12: Transformations I

CS5600 12

Matrix Representation

y

x

y

x

220

01

Scale in y by 2:

Page 13: Transformations I

CS5600 13

Matrix Representation

y

x

y

x

y

x2

2

2

20

02

Overall Scale by 2:

Page 14: Transformations I

CS5600 14

Matrix RepresentationShowing Same

)(

22

)(

)(2

10

02

10

10

10

10

10

10

yy

xx

yy

xx

yy

xx

Page 15: Transformations I

CS5600 15

What about Rotation?

Is it linear?

Page 16: Transformations I

CS5600 16

Rotate by

x

y

)0,1(

)1,0(

Page 17: Transformations I

CS5600 17

sin

Rotate by : 1st Quadrant

x

y

)0,1(

)sin,(cos

cos

Page 18: Transformations I

CS5600 18

Rotate by : 1st Quadrant

)sin,(cos)0,1(

Page 19: Transformations I

CS5600 19

Rotate by : 2nd Quadrant

x

y

)1,0(

)0,1(

Page 20: Transformations I

CS5600 20

Rotate by : 2nd Quadrant

x

y

cos

sin

)1,0(

Page 21: Transformations I

CS5600 21

Rotate by : 2nd Quadrant

)cos,sin()1,0(

Page 22: Transformations I

CS5600 22

Summary of Rotation by

)sin,(cos)0,1(

)cos,sin()1,0(

Page 23: Transformations I

CS5600 23

Summary (Column Form)

cos

sin

1

0

sin

cos

0

1

Page 24: Transformations I

CS5600 24

Using Matrix Notation

sin

cos

0

1

cossin

sin-cos

cos

sin-

1

0

cossin

sin-cos

(Note that unit vectors simply copy columns)

Page 25: Transformations I

CS5600 25

General Rotation by Matrix

cossin

ysin-cos

cossin

sin-cos

yx

x

y

x

Page 26: Transformations I

CS5600 26

Who had linear algebra?

Who understand matrices?

Page 27: Transformations I

CS5600 27

What do the off diagonal elements do?

Page 28: Transformations I

CS5600 28

Off Diagonal Elements

ybx

x

y

x

b 1

01

y

ayx

y

xa

10

1

Page 29: Transformations I

CS5600 29

Example 1

y

yx

x

y

xyxT

4.0

14.0

01),(

)1,0(

)0,1(

)1,1(

)0,0(

S

x

Page 30: Transformations I

CS5600 30

Example 1

x

y

yx

x

yxT

4.0

),(

S

)1,0(

)0,1(

)1,1(

)0,0(

Page 31: Transformations I

CS5600 31

Example 1

y

)1,0(

)4.0,1(

)0,0(

T(S)

yx

x

yxT

4.0

),()4.1,1(

x

Page 32: Transformations I

CS5600 32

Example 2

y

y

yx

y

xyxT

6.0

10

6.01),(

S

x

)1,0(

)0,1(

)1,1(

)0,0(

Page 33: Transformations I

CS5600 33

Example 2

x

y

y

yx

yxT

6.0

),(

S

)1,0(

)0,1(

)1,1(

)0,0(

Page 34: Transformations I

CS5600 34

Example 2

x

y

)1,0(

)0,1()0,0(

T(S)

)1,6.0(

y

yxyxT

6.0 ),(

)1,6.1(

Page 35: Transformations I

CS5600 35

Summary

Shear in x:

Shear in y:

y

ayx

y

xaShx 10

1

ybx

x

y

x

bShy 1

01

Page 36: Transformations I

CS5600 36

Double Shear

ab)(10

1

1

01

1

1

b

aa

b

1

1 ab)(

1

01

10

1

b

a

b

a

Page 37: Transformations I

CS5600 37

Sample Points: unit inverses

0

11

1

01

bb

1

0

10

1

1

aa

Page 38: Transformations I

CS5600 38

Geometric View of Shear in x

)0,1(

)1,( a )1,0(

)0,1(

)1,1(

Page 39: Transformations I

Another Geometric View of Shear in x

x39x x

yy

Page 40: Transformations I

Another Geometric View of Shear in x

40

x

y

Page 41: Transformations I

CS5600 41

Geometric View of Shear in y

)1,0(

)0,0(

),1( b

)1,0(

)0,1()0,0(

)1,1(

Page 42: Transformations I

Another Geometric View of Shear in y

h h42

x

y

x

y

Page 43: Transformations I

Another Geometric View of Shear in y

43

x

y

Page 44: Transformations I

CS5600 44

“Lazy 1”

100

010

01 0

11

y

x

y

x

Page 45: Transformations I

CS5600 45

Translation in x

1

y

x

10 10

010

01

yxdx

xd

Page 46: Transformations I

CS5600 46

Translation in x

1

y

x

10

0

10

10

01

ydy

x

d y

Page 47: Transformations I

CS5600 47

Homogeneous Coordinates

100

010

01 0

11

y

x

y

x

Page 48: Transformations I

CS5600 48

Homogeneous Coordinates

0for ,

y

xy

x

1

y

x

Page 49: Transformations I

CS5600 49

Homogeneous Coordinates

Homogeneous term effects overall scaling

0,For

y

xy

x

y

x

y

x

1100

010

01

11

0

Page 50: Transformations I

Homogeneous CoordinatesAn infinite number of points correspond to (x,y,1).

They constitute the whole line (tx,ty,t).

x

w

y

w = 1

(tx,ty,t)

(x,y,1)

Page 51: Transformations I

CS5600 51

We’ve got Affine Transformations

Linear + Translation

Page 52: Transformations I

CS5600 52

Compound Transformations

• Build up compound transformations by concatenating elementary ones

• Use for complicated motion

• Use for complicated modeling

Page 53: Transformations I

CS5600 53

Elementary Transformations

• Scale

• Rotate

• Translate

• Shear

• (Reflect)

)(R)(),( dT ydT x

Rf yRf x,

)(),( dSh ydShx

)(),( S yS x

Page 54: Transformations I

CS5600 54

Refection about y-axis

0

1

0

1

10

01

Page 55: Transformations I

CS5600 55

Reflection about y-axis

x

y

),( yx),( yx

)0,1()0,1(

Page 56: Transformations I

CS5600 56

Reflection about x-axis

1

0

1

0

1-0

01

Page 57: Transformations I

CS5600 57

Reflection about x-axis

x

y

)1,0( ),( yx

),( yx )1,0(

Page 58: Transformations I

Is Reflection “Elementary?”

• Can we effect reflection in an elementary way?

• (More elementary means scale, shear, rotation, translation.)

58

Page 59: Transformations I

CS5600 59

Reflection is Scale (-1)

Page 60: Transformations I

CS5600 60

Example:Move clock hands

x

),( ba

y

Page 61: Transformations I

CS5600 61

Example:Move clock hands

),( ba

x

y

Page 62: Transformations I

CS5600 62

Example:Move clock hands

),( ba

x

y

Page 63: Transformations I

CS5600 63

Example:Move clock hands

y

),( ba

x

Page 64: Transformations I

CS5600 64

Clock Transformations

• Translate to Origin

• Move hand with rotation

• Move hand back to clock

• Do other hand

Page 65: Transformations I

CS5600 65

Clock Transformations

15

),(12),(

),()(),(

)(

twhere

baTtRbaTT

baTtRbaTT

b

s

Page 66: Transformations I

CS5600 66

Clock Transformations

1

y

x

1

10

01

11

10

01

0000

0)cos()sin(

0)sin()cos(

00

b

a

tt

tt

b

a

Page 67: Transformations I

CS5600 67

Map [a,b] [0,1]

0[ ]

x

a b

x

1

Page 68: Transformations I

CS5600 68

Map [a,b] [0,1]

• Translate to Origin

• Map x to translated interval

axx

ababaaba ,0,,

Page 69: Transformations I

CS5600 69

Map [a,b] [0,1]

• Normalize the interval

• Map x to normalized interval

abaxx

1,0,1

,0

abaaab

ab

Page 70: Transformations I

CS5600 70

Map [a,b] [0,1])( aT x

abS x1

1100

010

01

y

xa

1

yab

ax

100

010

001

ab

Page 71: Transformations I

CS5600 71

Just Look at

10

01

ab

1 RThis is a homogeneous form for 1D

)( aT x

abS x1

10

1 a

1

x

1

ab

ax

Page 72: Transformations I

CS5600 72

Map [a,b] [-1,1]

0[ ]

-1 +1x

a bx

2

ba

Page 73: Transformations I

CS5600 73

Map [a,b] [-1,1]

• Translate center of interval to origin

• Normalize interval to [-1,1]

2

baxx

22 2

1 bax

bax

ab

Page 74: Transformations I

CS5600 74

Map [a,b] [-1,1]

• Substitute x =a (analogous for x =b) :

12

)(2

2

22

22

22

ab

ab

baa

ab

baa

ab

x

Page 75: Transformations I

CS5600 75

Now Map [a,b] [c,d]

• First map [a,b] to [0,1]

– (We already did this)

• Then map [0,1] to [c,d]

Page 76: Transformations I

CS5600 76

Now Map [a,b] [c,d]

• Scale [0,1] by (d-c)

• Then translate by c

• That is, in 1D homogeneous form:

1)(

110

0

10

1 cxcdxcdc

Page 77: Transformations I

CS5600 77

All Together: [a,b] [c,d]

110

1

10

01

10

0

10

1 xaab

cdc

110

1

10

010

1 xaab

cdc

Page 78: Transformations I

CS5600 78

Now Map Rectangles

),(minmin yx

),(maxmax vu

),(minmin vu

),(maxmax yx

Page 79: Transformations I

CS5600 79

Transformation in x and y

yyvv

xxuu

yx

vu

xx

y

x

y

x

minmax

minmax

minmax

minmax

min

min

min

min

,where

1100

10

01

100

00

00

100

10

01

,

Page 80: Transformations I

This is the Viewport Transformation

• Good for mapping objects from one

coordinate system to another

• This is what we do with windows and

viewports

80

Page 81: Transformations I

CS5600 81

3D Transformations

• Scale

• Rotate

• Translate

• Shear

)(),(),( dT zdT ydT x

)(),(),( dShzdSh ydShx

)(),(),( S zS yS x

)(),(),( RzR yRx

Page 82: Transformations I

CS5600 82

3D Scale in x

1000

0100

0010

000

)(

S x

Page 83: Transformations I

CS5600 83

3D Scale in x

111000

0100

0010

000

z

y

x

z

y

x

S x

Page 84: Transformations I

CS5600 84

3D Scale in y

111000

0100

000

0001

)(z

y

x

z

y

x

S y

Page 85: Transformations I

CS5600 85

3D Scale in z

111000

000

0010

0001

)(z

y

x

z

y

x

S z

Page 86: Transformations I

CS5600 86

Overall 3D Scale

11 1000

0100

0010

0001

)(z

y

x

z

y

x

S

Page 87: Transformations I

CS5600 87

Overall 3D Scale

Same in x,y and z:

z

y

x

z

y

x

z

y

x

11

Page 88: Transformations I

What is a Positive Rotation in 3D ?

• Sit at end of given axis

• Look at Origin

• CC Rotation is in Positive direction

88

Page 89: Transformations I

3D Positive Rotations

x

z

y

Page 90: Transformations I

CS5600 90

3D Rotation about z-axis by

We have already done this:

11000

0100

00cossin

00sincos

)(z

y

x

Rz

Page 91: Transformations I

CS5600 91

3D Rotation about x-axis by

y

z

)0,1,0(

)1,0,0(

Page 92: Transformations I

CS5600 92

3D Rotation about x-axis

11000

0cossin0

0sincos0

0001

)(z

y

x

Rx

Page 93: Transformations I

3D Rotation about y-axis by

x

z

)0,0,1(

)1,0,0(

93

Page 94: Transformations I

CS5600 94

3D Rotation about y-axis

11000

0cos0sin

0010

0sin0cos

)(z

y

x

R y

Page 95: Transformations I

CS5600 95

Elementary Transformations

• Scale

• Rotate

• Translate

• Shear

• (Reflect)

)(),( R yRx)(),( dT ydT x

)(),( S yS x

Rf yRf x,

)(),( dSh ydShx

Page 96: Transformations I

CS5600 96

Consider an arbitrary 3D rotation

• What is its inverse?

• What is its transpose?

• Can we constructively elucidate this

relationship?

Page 97: Transformations I

Want to rotate by about arbitrary axis a

a

)(: Ra

x

z

y

97

Page 98: Transformations I

CS5600 98

First rotate about by

)(: Rzz

a Now in the

(y-z)-plane

x

z

y

Page 99: Transformations I

CS5600 99

Then rotate about by

x

z

y

)(: Rx x

Rotate in the

(y-z)-plane

a

Page 100: Transformations I

Now perform rotation about -

x

z

y

)(: Raxisz za Now aligned

with z-axis

100

Page 101: Transformations I

Now perform rotation about -

x

z

y

)(: Raxisz zaNow aligned

with z-axis

101

Page 102: Transformations I

CS5600 102

Then rotate about by )(: Rx x

Rotate again in the (y-z)-plane

x

z

y

a

Page 103: Transformations I

CS5600 103

Then rotate about by )(: Rz z

Now to original position of a

a

x

z

y

Page 104: Transformations I

We effected a rotation by about arbitrary axis a

a

)(: Ra

x

z

y

104

Page 105: Transformations I

We effected a rotation by about arbitrary axis a )(: Ra

105

)()()( RRR z xa)( Rz

)()( RRx z

Page 106: Transformations I

CS5600 106

Rotation about an arbitrary axis

• Rotation about a-axis can be effected by a composition of 5 elementary rotations

• We show arbitrary rotation as succession of 5 rotations about principal axes

Page 107: Transformations I

CS5600 107

)( Ra

1000

0)cos()sin(0

0)sin()cos(00001

10000100

00)cos()sin(

00)sin()cos(

)(

Ra

1000010000cossin00sincos

1000

0cossin0

0sincos00001

1000010000cossin00sincos

)( Rz

In matrix terms, )( Rz

)( Rx

)( Rx

)( Rz

Page 108: Transformations I

CS5600 108

1000

0)cos()sin(0

0)sin()cos(00001

10000100

00)cos()sin(

00)sin()cos(

)(

Ra

,)()(1 RaRa

1000010000cossin00sincos

1000

0cossin0

0sincos00001

1000010000cossin00sincos

)( Rz

Similarly, so,

Page 109: Transformations I

CS5600 109

Recall, tAtBtAB

RtMtRtA

tttt RRMt

RMR .

Consequently, for , RMtRA

because,

RMR tt

Page 110: Transformations I

CS5600 110

RStMtStRt

RSMtStR

It follows directly that,

Page 111: Transformations I

CS5600 111

)()(1 RtaRa

)( Rtz

1000

0)cos()sin(0

0)sin()cos(00001

10000100

00)cos()sin(

00)sin()cos(

)(

Ra

1000010000cossin00sincos

1000

0cossin0

0sincos00001

1000010000cossin00sincos

Page 112: Transformations I

CS5600 112

)()( 1 RtaRa

Constructively, we have shown,

This will be useful later

Page 113: Transformations I

CS5600 113

3D Translation in x

111000

0100

0010

001

)(z

yd xx

z

y

xd x

d xT x

Page 114: Transformations I

CS5600 114

3D Translation in y

111000

0100

010

0001

)(zd yy

x

z

y

x

d yd yT y

Page 115: Transformations I

CS5600 115

3D Translation in z

111000

100

0010

0001

)(d zz

y

x

z

y

x

d zd zT z

Page 116: Transformations I

CS5600 116

3D Shear in x -direction

111000

0100

0010

001

)(z

y

ayx

z

y

xa

aShx

Page 117: Transformations I

CS5600 117

3D Shear in x -direction

111000

0100

0010

001

)(z

y

bzx

z

y

xb

bShx

Page 118: Transformations I

CS5600 118

3D Shears:clamp a principal plane, shear in other 2 DoFs

x

z

y

Page 119: Transformations I

x

z

y

111000

0100

0010

001

)(z

y

ayx

z

y

xa

aShx

x

z

y

Page 120: Transformations I

CS5600 120

3D Shear in y -direction

111000

0100

010

0001

)(z

czy

x

z

y

x

ccShy

Page 121: Transformations I

CS5600 121

3D Shear in y -direction

111000

0100

001

0001

)(z

ydx

x

z

y

x

ddShy

Page 122: Transformations I

x

z

y

x

z

y

111000

0100

001

0001

)(z

ydx

x

z

y

x

ddShy

Page 123: Transformations I

CS5600 123

3D Shear in z -direction

111000

010

0010

0001

)(zex

y

x

z

y

x

eeShz

Page 124: Transformations I

CS5600 124

3D Shear in z

111000

010

0010

0001

)(zex

y

x

z

y

x

eeShz

Page 125: Transformations I

CS5600 125

3D Shear in z

111000

010

0010

0001

)(zfy

y

x

z

y

x

ffShz

Page 126: Transformations I

CS5600 126

What is “Perspective?”

• A mechanism for portraying 3D in 2D

• “True Perspective” corresponds to

projection onto a plane

• “True Perspective” corresponds to an

ideal camera image

Page 127: Transformations I

Many Kinds of Perspective Used

• Mechanical Engineering

• Cartography

• Art

Page 128: Transformations I

CS5600 128

Perspective in Art

• Naïve (wrong)

• Egyptian

• Cubist (unrealistic)

• Esher

– Impossible (exploits local property)

– Hyperpolic (non-planar)

– etc

Page 129: Transformations I

CS5600 129

“True” Perspective in 2D

y

x

(x,y)

p

h

Page 130: Transformations I

CS5600 130

“True” Perspective in 2D

pxpyh

pxy

ph

Page 131: Transformations I

CS5600 131

“True” Perspective in 2D

px

py

px

px

px

py

px

px

p

pxpx

y

x

y

x

11

This is right answer for screen projection

Page 132: Transformations I

CS5600 132

“True” Perspective in 2D

11101

010

001

yp

x

y

x

p

Page 133: Transformations I

End Transformations I

Lect

ure

Set

5

133


Recommended