53
Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

  • View
    216

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

Viewing Transformations

CS5600 Computer Graphicsby

Rich Riesenfeld

5 March 2002Lect

ure

Set

11

Page 2: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

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 3: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 3

Illustration: Old Style, Simple Transformation Sequence for

3D Viewing

Page 4: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 4

Simple Viewing Transformation Example

Points A B C D E F G H

X -1 1 1 -1 -1 1 1 -1

Y 1 1 -1 -1 1 1 -1 -1

Z -1 -1 -1 -1 1 1 1 1

Page 5: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

Simple Cube Viewed from (6,8,7.5)

x

z

yA=(-1,1,-1)

B=(1,1,-1)C=(1,-1,-1)

D=(-1,-1,-1)

G=(1,-1,1)

E=(-1,1,1)H=(-1,-1,1)

F=(1,1,1)

Page 6: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 6

Topology of Cube

A B C D E F G H

A 0 1 0 1 1 0 0 0

B 1 0 1 0 0 1 0 0

C 0 1 0 1 0 0 1 0

D 1 0 1 0 0 0 0 1

E 1 0 0 0 0 1 0 1

F 0 1 0 0 1 0 1 0

G 0 0 1 0 0 1 0 1

H 0 0 0 1 1 0 1 0

BC

EH

D

FG

A

Page 7: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 7

Topology of Cube

A: B D E

B: A C F

C: B D G

D: A C H

E: A F H

F: B E G

G: C F H

H: D E G

BC

EH

D

FG

A

Page 8: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 8

Simple Example

• Give a Cube with corners

• View from Eye Position (6,8,7.5)

• Look at Origin (0,0,0)

• “Up” is in z-direction

)1,1,1(

Page 9: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 9x

z

y

x

z

y

Translate Origin by T1

(6,8,0)

x

z

y

Page 10: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 10

Simple Viewing Transformation Example

1000

5.7100

8010

6001

1T

Page 11: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 11x

z

y

ex

ez

ey

Build LH Coord with T 2

(6,8,0)

x

z

y

Page 12: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 12

1000

0010

0100

0001

2T

Build LH Coord with T 2

Page 13: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 13x

z

y

exezey

Rotate about y with T 3

(6,8,0)

6

8

10

x

z

y

Page 14: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 14

1000

08.06.

0010

06.08.

3T

Simple Viewing Transformation Example

106)sin(

108)cos(

,

where

Page 15: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 15

Rotate about x-axis with

x

z

y

ex

ez

ey

7.5

T 4

10

x

y

z

Page 16: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 16

Look at the (3-4-5) Right Triangle

7.5

10

12.5

53)sin(

54)cos(

(4)

(5)(3)

Page 17: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 17

Simple Viewing Transformation Examle

1000

08.6.0

06.8.0

0001

4T

53)sin(

54)cos(

,

where

Page 18: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 18

View on 10x10 screen, 20 away10

1020

30

Page 19: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 19

Map to canonical frustum

4520

20

Page 20: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 20

1000

0100

0020

0002

N

Scale x,y by 2 for normalization

Will view a 20”x20” screen from 20” away. Scale to standard viewing frustum.

Page 21: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 21

1000

5.126.64.48.

06.196.72.

002.16.1

1234 TTTTN

Simple Viewing Transformation Example

Page 22: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 22

Clipping not needed, so project

1000

0000

0010

0001

icorthographP

Page 23: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 23

11111111

11111111

11111111

11111111

1000

5.126.64.48.

06.196.72

002.16.1

.

Transformation of Cube

11111111

13.0212.0610.7811.7414.2213.2611.9812.94

3.281.840.08-1.36.0801.36-3.28-1.84-

0.42.8-0.4-2.80.42.8-0.4-2.8

Page 24: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 24

Cube Transformed for Viewing

Pts A B C D E F G H

X 2.8 -0.4 -2.8 0.4 2.8 -0.4 -2.8 0.4

Y -1.84 -3.28 -1.36 .08 1.36 -.08 1.84 3.28

Z 12.94 11.98 13.26 14.22 11.74 10.78 12.06 13.02

Page 25: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

G=(-2.8,1.84)

25

Pt X Y

A 2.8 -1.84

B -0.4 -3.28

C -2.8 -1.36

D 0.4 08

E 2.8 1.36

F -0.4 -.08

G -2.8 1.84

H 0.4 3.28

A: B D E

B: A C F

C: B D G

D: A C H

E: A F H

F: B E G

G: C F H

H: D E G

Transformed Cube

B=(-0.4,-3.28)

C=(-2.8,-1.36)

D=(0.4,.08)

E=(2.8,1.36)

A=(2.8,-1.84)

H=(0.4,3.28)

F=(-0.4,-.08)

Page 26: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 26

Recall mapping [a,b] [-1,1]

• Translate center of interval to origin

• Normalize interval to [-1,1]

2

baxx

22 2

1 bax

bax

ab

Page 27: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 27

• Substitute x =a:

12

)(2

2

22

22

22

ab

ab

baa

ab

baa

ab

x

Recall mapping [a,b] [-1,1]

Page 28: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 28

• Substitute x =b:

12

2

2

22

22

22

ab

ab

bab

ab

bab

ab

x

Recall mapping [a,b] [-1,1]

Page 29: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 29

Map to the (1K x 1K) screen

1000

0100

511010

511001

T Assume screen origin (0,0) at lower left. This translates old (0,0) to center of screen (511,511).

Page 30: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 30

Map to the (1K x 1K) screen

1000

0100

005110

000511

xyS

Proper scale factor for mapping:

[-1,1] to (-511,+511)

Page 31: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 31

Combine Screen Transformation

1000

0100

51105110

51100511

xyT

xySV

Page 32: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 32

For General Screen: ……

1000

0100

2

10

2

10

2

100

2

1

yn

yn

xn

xn

V

)(y

nx

n

Page 33: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 33

Transformation to Std Clipping Frustum

Page 34: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 34

Transforming to Std Frustumyx,

z

),,( baa

yxz ,

Page 35: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 35

Transforming to Std Frustumyx,

z

),,( baa

yxz ,),,( bbb

Page 36: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 36

Transforming to Std Frustum

The right scale matrix to map to canonical form

1000

0100

000

000

tan

1tan

1

1

b

a

a

1000

0100

000

000

cot

cot

1

b

a

a

Page 37: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 37

Transforming to Std Frustum

1000

0100

000

000

a

ba

b

11

b

b

b

b

a

a

Page 38: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

Determining Rotation Matrix

Page 39: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 39

e3

e2

e1

d1

d 2

d 3

Frame rotation, ed ii :M

Page 40: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 40

e3

e2

e1

d1

d 2

d 3

Inverse problem easy, ed ii :1M

Page 41: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 41

In matrix representation of ,

Columns are simply images of

ddddddddd

zzz

yxy

xxx

321

321

321

1

M

s'ei

1M

Page 42: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 42

Rotation matrix M

• columns given by frame’s pre-image

• Column i of is

ddddddddd

zzz

yxy

xxx

321

321

321

1

M

d i

1M

1M

Page 43: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 43

Inverse of rotation matrix M

• Recall, for rotation matrix R,

• So,

1R

tR

d1

ddddddddd

zyx

zxx

zyx

333

222

111

M d 2

d 3

tMMM 111

Page 44: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 44

Rotation matrix M

• Row i is simply

• Simply write M down!

ddddddddd

zyx

zxx

zyx

333

222

111

M

d i

Thus,

Page 45: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

CS5600 45

e3

e2

e1

d1

d 2

d 3

Frame Rotation: ed ii

Page 46: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

46

Page 47: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

47

Page 48: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

48

Page 49: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

49

Page 50: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

50

Page 51: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

51

Page 52: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

52

Page 53: Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11

The End of

Viewing Transformations

Lect

ure

Set

11

53