Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

126
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 1

Transcript of Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Page 1: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Jinxiang Chai

CSCE441: Computer Graphics3D Transformations

1

Page 2: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Outline

2D Coordinate transformation

Composite transformation

3D transformation

Required readings: HB 7-8, 9-1 to 9-9

2

Page 3: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Image space

Coordinate Transform: 3D Geometry Pipeline

3

Normalized project

space

View spaceWorld spaceObject space

Aspect ratio &

resolution

Focal length

Rotate and translate the

camera

Page 4: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation: 3D Modeling/Design

Coordinate transformation from one reference frame to another

4

Page 5: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation: Animation/Robotics

How to model 2D movement of animated characters or robots?

5

Click here

Page 6: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation

Coordinate transformation from one reference frame to another

6

Page 7: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation

Coordinate transformation from one reference frame to another

7

Local reference frame

Page 8: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation

Coordinate transformation from one reference frame to another

8

Local reference frame

Global reference frame

Page 9: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Coordinate Transformation

Coordinate transformation from one reference frame to another

?

9

Local reference frame

Global reference frame

Page 10: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product

v w

10

Page 11: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product: measuring similarity between two vectors

v w

)cos(|||| wvwv

11

Page 12: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product: measuring similarity between two vectors

v w

)cos(|||| wvvw

12

Page 13: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product: measuring similarity between two vectors

v w

1vvUnit vector:

13

Page 14: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product: measuring similarity between two vectors

v w

)cos(|||| wvwv

14

Page 15: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Dot Product: measuring similarity between two vectors

v w

0wv

15

Page 16: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Cross Product: measuring the area determined by two vectors

16

v w

Page 17: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Review – Vector Operations

Cross Product: measuring the area determined by two vectors

sin 2*v w v w u area u

17

v w

u

Page 18: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinates

2D Cartesian coordinate system:

P: (x,y)

i

j

o

18

Page 19: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D Cartesian coordinate system:

P: (x,y)

i

j

o x

y1 ii

1 jj

0 ji

19

Page 20: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D Cartesian coordinate system:

P: (x,y)

i

j

o x

y

1 ii

1 jj

0 ji

20

jyixop

Page 21: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

21

Page 22: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

22

Given the coordinates (x’,y’) in i’j’

- how to compute the coordinates (x,y) in ij?

Page 23: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

23

Given the coordinates (x’,y’) in i’j’

- how to compute the coordinates (x,y) in ij?

0x

0y

Page 24: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

),( 00 yx

24

Given the coordinates (x’,y’) in i’j’

- how to compute the coordinates (x,y) in ij?

1100

cossin

sincos

10

0

y

x

y

x

y

x

Page 25: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

jyixop

ji ij

),( 00 yx

25

Page 26: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

jyixop

jyixpo

ji ij

),( 00 yx

26

Page 27: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

jyixop

jyixpo

jyixoo

00

ji ij

),( 00 yx

27

Page 28: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

poooop

ji ij

),( 00 yx

28

Page 29: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

poooop

jyixop

jyixpo

jyixoo

00

ji ij

),( 00 yx

29

Page 30: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

poooop

ji ij

jyixjyixjyix

00

),( 00 yx

30

Page 31: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

poooop

ji ij

jyixjyixjyix

00

jyixjyyixx

)()( 00

),( 00 yx

31

Page 32: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

poooop

ji ij

jyixjyixjyix

00

jyixjyyixx

)()( 00

y

xji

yy

xxji

0

0),( 00 yx

32

Page 33: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

yy

xxji

0

0

),( 00 yx

33

Page 34: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

yy

xxji

0

0

y

xjiji

yy

xx 1

0

0

),( 00 yx

34

Page 35: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

yy

xxji

0

0

y

xjiji

yy

xx 1

0

0

y

xji

j

i

yy

xxT

T

0

0

),( 00 yx

35

10

01

jjij

jiii

j

iji

T

T

Page 36: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

36

Page 37: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

),( 00 yx

37

110010

0

y

x

yjjij

xjiii

y

xTT

TT

Page 38: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

38

What does this column vector mean?

Page 39: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

39

What does this column vector mean? Vector i’ in the new reference system

ii T

ij T

Page 40: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

40

What does this column vector mean?

Page 41: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

41

What does this column vector mean? Vector j’ in the new reference system

ji T

jj T

Page 42: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

42

What does this column vector mean?

Page 43: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

y

xji

j

i

yy

xxT

T

0

0

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

43

What does this column vector mean? The old origin in the new reference system

Page 44: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation

pj

i

i

j

o

o

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

44

Page 45: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation

pj

i

i

j

o

o

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

?

? ?

?

45

Page 46: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation

pj

i

i

j

o

o

110010

0

y

x

yjjij

xjiii

y

xTT

TT

1

0

0

1

),( 00 yx

46

Page 47: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

?

47

Page 48: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

cos

10

0

y

x

yjjij

xji

y

xTT

T

),( 00 yx

?

48

Page 49: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

sin

cos

10

0

y

x

yjj

xji

y

xT

T

),( 00 yx

49

Page 50: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

sin

cos

10

0

y

x

yjj

xji

y

xT

T

),( 00 yx

?

50

Page 51: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

sin

sincos

10

0

y

x

yjj

x

y

xT

),( 00 yx

51

Page 52: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

sin

sincos

10

0

y

x

yjj

x

y

xT

),( 00 yx

?

52

Page 53: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o

o

1100

cossin

sincos

10

0

y

x

y

x

y

x

),( 00 yx

53

Page 54: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem

i

j

o

P=[x,y]j

i

o ),( 00 yx

54

- set up a transformation that superimposes the x’y’ axes onto the xy axis

1

y

x

Page 55: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem

i

j

o

P=[x,y]j

i

o ),( 00 yx

55

- set up a transformation that superimposes the x’y’ axes onto the xy axis

1100

10

01

0

0

y

x

y

x

Page 56: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem

i

j

o

P=[x,y]

j

io ),( 00 yx

56

- set up a transformation that superimposes the x’y’ axes onto the xy axis

1100

10

01

100

0cossin

0sincos

0

0

y

x

y

x

Page 57: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’)

i

j

o

p

j

io ),( 00 yx

57

1100

10

01

100

0cossin

0sincos

10

0

y

x

y

x

y

x

Page 58: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)?

i

j

o

p

j

io ),( 00 yx

58

1100

10

01

100

0cossin

0sincos

10

0

y

x

y

x

y

x

Page 59: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)? Invert the matrix!

i

j

o

p

j

io ),( 00 yx

59

1100

0cossin

0sincos

100

10

01

1

11

0

0

y

x

y

x

y

x

Page 60: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)? Invert the matrix!

i

j

o

p

j

io ),( 00 yx

60

1100

0cossin

0sincos

100

10

01

1

11

0

0

y

x

y

x

y

x

Page 61: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)? Invert the matrix!

i

j

o

p

j

io ),( 00 yx

61

1100

0cossin

0sincos

100

10

01

1

11

0

0

y

x

y

x

y

x

100

10

01

0

0

y

x

Page 62: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)? Invert the matrix!

i

j

o

p

j

io ),( 00 yx

62

1100

0cossin

0sincos

100

10

01

1

11

0

0

y

x

y

x

y

x

100

10

01

0

0

y

x

Page 63: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

An alternative way to look at the problem This transforms the point from (x,y) to (x’,y’) How to transform the point from (x’,y’) to

(x,y)? Invert the matrix!

i

j

o

p

j

io ),( 00 yx

63

1100

0cossin

0sincos

100

10

01

1

11

0

0

y

x

y

x

y

x

100

10

01

0

0

y

x

100

0cossin

0sincos

Page 64: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Same results!

pj

i

i

j

o

o

1100

cossin

sincos

10

0

y

x

y

x

y

x

),( 00 yx

64

Page 65: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o o

1???

???

???

1

y

x

y

x

30

65

Page 66: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

pj

i

i

j

o o

1100

030cos30sin

030sin30cos

1

y

x

y

x

30

66

Page 67: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

p

j

i

i

j

oo

1???

???

???

1

y

x

y

x

45

67

Page 68: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

p

j

i

i

j

oo

1100

045cos45sin

045sin45cos

1

y

x

y

x

45

68

Page 69: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

p

j

i

i

j

o

)2,4( o

1???

???

???

1

y

x

y

x

45

69

Page 70: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

2D translation&rotation

p

j

i

i

j

o

)2,4( o

1100

245cos45sin

445sin45cos

1

y

x

y

x

45

70

Page 71: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

How to model 2D movement of characters or robots?

71

Click here

Page 72: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

A 2D lamp character

1

2

3

),,( 0yx

3c

2c

1c

0c

A

72

0

Page 73: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

A 2D lamp character – skeleton size3l

A2l

1l

0l

73

Page 74: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

How can we draw the character given the pose ?

1

2

3

),,( 0yx

3c

2c

1c

0c

A

74

),,,,,( 3210 yx

Page 75: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

),,( 0yx

3c2c

0c

A1c

Articulated Character

Local reference frames with a default pose (0,0,0,0,0,0)

Page 76: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the pose?

)1,5(

76

?)?,?,?,,1,5(

300

Page 77: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the pose?

)1,5(

77

)90,0,90,30,1,5(

300

Page 78: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

A 2D lamp character

1

2

3

3c

2c

1c

A

Given , , how to compute the global position of a point A?

),,,,,( 3210 yx

?

),,( 0yx0c

78

Page 79: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s local coordinate ?

1

2

3

3c

2c

1c

A

?

A

),,( 0yx0c

79

Page 80: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s local coordinate ?

1

2

3

3c

2c

1c

A

?

A

1

03

0

l

p

),,( 0yx0c

03221100 )()0,()()0,()()0,()(),( pRlTRlTRlTRyxTp 80

Page 81: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

?

),,( 0yx0c

1

00

l

p

03221100 )()0,()()0,()()0,()(),( pRlTRlTRlTRyxTp

100

010

01

)0,(2

2

l

lT

81

100

0cossin

0sincos

)( 33

33

3

R

Page 82: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

?

),,( 0yx0c

1

00

l

p

03221100 )()0,()()0,()()0,()(),( pRlTRlTRlTRyxTp

100

010

01

)0,(1

1

l

lT

82

100

0cossin

0sincos

)( 22

22

2

R

Page 83: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

?

),,( 0yx0c

1

00

l

p

03221100 )()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp

100

10

001

),0( 00 llT

83

100

0cossin

0sincos

)( 11

11

1

R

Page 84: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

?

03221100 )()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp

),,( 0yx0c

1

00

l

p

100

cossin

sincos

)(),( 00

00

0 y

x

RyxT

84

Page 85: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 2D Transformation

What’s the current coordinate A ?

1

2

3

3c

2c

1c

A

03221100 )()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp

),,( 0yx0c

85

Page 86: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

How to Animate the Character?

A 2D lamp character

1

2

3

),,( 0yx

3c

2c

1c

0c

A

86

Page 87: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

How to Animate the Character?

Keyframe animation

- Manually pose the character by choosing appropriate values for

- Linearly interpolate the inbetween poses.

- Works for any types of articulated characters!

87

),,,,,( 3210 yx

Page 88: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

A 3D point (x,y,z) – x,y, and z coordinates We will still use column vectors to represent

points Homogeneous coordinates of a 3D point

(x,y,z,1) Transformation will be performed using 4x4

matrix

x

y

z

88

Page 89: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Right-handed Coordinate System

x

y

z

;zyx ;xzy yxz

Left hand coordinate system

Not used in this class and

Not in OpenGL 89/94

Page 90: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

Very similar to 2D transformation

Translation transformation

11000

100

010

001

1

z

y

x

t

t

t

z

y

x

x

y

x

Homogenous coordinates

90

Page 91: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

Very similar to 2D transformation

Scaling transformation

11000

000

000

000

1

z

y

x

s

s

s

z

y

x

z

y

x

Homogenous coordinates

91

Page 92: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

3D rotation is done around a rotation axis Fundamental rotations – rotate about x, y, or

z axes Counter-clockwise rotation is referred to as

positive rotation (when you look down negative axis)

x

y

z

+

92

Page 93: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

Rotation about z – similar to 2D rotation

x

y

z

+

11000

0100

00cossin

00sincos

1

z

y

x

z

y

x

zz

yxy

yxx

'

cossin'

sincos'

93

Page 94: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

Rotation about y: z -> y, y -> x, x->z

11000

0cos0sin

0010

0sin0cos

1

z

y

x

z

y

x

yy

xzx

xzz

'

cossin'

sincos'

y

z

x

x

y

z

94

Page 95: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Transformation

Rotation about x (z -> x, y -> z, x->y)

x

y

z

11000

0cossin0

0sincos0

0001

1

z

y

x

z

y

x

xx

zyz

zyy

'

cossin'

sincos'

z

x

y

95

Page 96: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Inverse of 3D Transformations

Invert the transformation In general, X= AX’->x’=A-1X

11000

100

010

001

1

z

y

x

t

t

t

z

y

x

x

y

x

1

'

'

'

1000

100

010

001

1

z

y

x

t

t

t

z

y

x

x

y

x

11000

0100

00cossin

00sincos

1

z

y

x

z

y

x

1

'

'

'

1000

0100

00cossin

00sincos

1

z

y

x

z

y

x

)(zR)( zR

T(tx,ty,tz)T(-tx,-ty,-tz)

Page 97: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotate p about the by the angle

x

y

zr

),,( zyxp

r

97

Page 98: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3-D Rotation General rotations in 3-D require rotating

about an arbitrary axis of rotation

Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra

The general rotation matrix is a combination of coordinate-axis rotations and translations!

98

Page 99: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotate p about the by the angle

x

y

zr

),,( zyxp

r

99

Page 100: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3-D Rotation General rotations in 3-D require rotating about

an arbitrary axis of rotation

Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra

Standard approach: express general rotation as composition of canonical rotations Rotations about x, y, z

100

Page 101: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composing Canonical Rotations Goal: rotate about arbitrary vector r by θ

Idea: we know how to rotate about x,y,zSet up a transformation that superimposes

rotation axis onto one coordinate axisRotate about the coordinate axisTranslate and rotate object back via inverse of

the transformation matrix

101

Page 102: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composing Canonical Rotations Goal: rotate about arbitrary vector r by θ

Idea: we know how to rotate about x,y,zSo, rotate about z by - until r lies in the xz

planeThen rotate about y by -β until r coincides

with +zThen rotate about z by θThen reverse the rotation about y (by β )Then reverse the rotation about z (by )

102

Page 103: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotate p about the by the angle

x

y

zr

),,( zyxp

r

103

Page 104: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Translate so that rotation axis passes through the origin

x

y

zr

TRRRRRT zyzyz )()()()()(1

104

Page 105: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotation by about z-axis

x

y

z

r

TRRRRRT zyzyy )()()()()(1

105

Page 106: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotation by about y-axis

x

y

z

r

xTRRRRRT zyzyy )()()()()(1

106

Page 107: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotation by about z-axis

x

y

z

r

xTRRRRRT zyzyy )()()()()(1

107

Page 108: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotation by about y-axis

x

y

z

r

xTRRRRRT zyzyy )()()()()(1

108

Page 109: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Rotation by about z-axis

x

y

z

r

TRRRRRT zyzyz )()()()()(1

109

Page 110: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Translate the object back to original point

x

y

z

r

TRRRRRT zyzyz )()()()()(1

110

Page 111: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Final transformation matrix for rotating about an arbitrary axis

x

y

z

r

TRRRRRT zyzyz )()()()()(1

111

Page 112: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Final transformation matrix for rotating about an arbitrary axis

x

y

z

r

TRRRRRT zyzyz )()()()()(1

112

Page 113: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Final transformation matrix for rotating about an arbitrary axis

TRRRRRT zyzyz )()()()()(1

1000

0

0

0

333231

232221

131211

rrr

rrr

rrr

Page 114: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Rotation about Arbitrary Axes

Final transformation matrix for rotating about an arbitrary axis

TRRRRRT zyzyz )()()()()(1

A 3 by 3 Rotation matrix—orthogonal matrix

1000

0

0

0

333231

232221

131211

rrr

rrr

rrr

Page 115: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Rotation Matrices

Orthonormal matrix: orthogonal (columns/rows linearly

independent)normalized (columns/rows length of 1)

115

Page 116: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Rotation Matrices

Orthonormal matrix: orthogonal (columns/rows linearly

independent)normalized (columns/rows length of 1)

The inverse of an orthogonal matrix is just its transpose:

116

T

rrr

rrr

rrr

rrr

rrr

rrr

333231

232221

131211

1

333231

232221

131211

Page 117: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Rotation Matrices

Orthonormal matrix: orthogonal (columns/rows linearly

independent)normalized (columns/rows length of 1)

The inverse of an orthogonal matrix is just its transpose:

117

T

rrr

rrr

rrr

rrr

rrr

rrr

333231

232221

131211

1

333231

232221

131211

Page 118: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Rotation Matrices

Orthonormal matrix: orthogonal (columns/rows linearly

independent)normalized (columns/rows length of 1)

The inverse of an orthogonal matrix is just its transpose: e.g.,

T

xx

Tyy

Tzz

RR

RR

RR

)()(

)()(

)()(

1

1

1

123

Page 119: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

),,( 000 zyx

k

'k

124

Page 120: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

2D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

110010

0

y

x

yjjij

xjiii

y

xTT

TT

),( 00 yx

poooop

125

Page 121: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

1

'

'

'

1000

'

'

'

10

0

0

z

y

x

zkkjkik

ykjjjij

xkijiii

z

y

x

TTT

TTT

TTT

),,( 000 zyx

k

'k

poooop

126

Page 122: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Coordinate Transformation

Transform object description from to

pj

i

i

j

o

o

ji ij

1

'

'

'

1000

'

'

'

10

0

0

z

y

x

zkkjkik

ykjjjij

xkijiii

z

y

x

TTT

TTT

TTT

),,( 000 zyx

k

'k

poooop

127

Page 123: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Coordinate Transformation

Transform object description from to

i

i

j

o

ji ij

1

'

'

'

1000

'

'

'

10

0

0

z

y

x

zkkjkik

ykjjjij

xkijiii

z

y

x

TTT

TTT

TTT

k

128

p'i

'j

Page 124: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

3D Coordinate Transformation

Transform object description from toji ij

129

'i

11000

0cos0sin

0010

0sin0cos

1

z

y

x

z

y

x

x

y

z

Page 125: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 3D Transformation

Similarly, we can easily extend composite transformation from 2D to 3D

1

2

3

),,( 0yx

3c

2c

1c

0c

A

130

Page 126: Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Composite 3D Transformation

xRRhTRhTRRRhTRRRzyxTp )()()0,,0()()0,,0()()()()0,,0()()()(),,( 332211110000000

131