YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

1

Viewing TransformationTong-Yee Lee

Page 2: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

2

Changes of Coordinate System

World coordinate system

Camera (eye) coordinate system

Page 3: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

3

Default Camera Position and Orientation

The default camera is with eye at the origin (0,0,0) and theaxis of the pyramid aligned with the z-axis. The eye is lookingdown the negative z-axis.

Page 4: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

4

Page 5: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

5

Page 6: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

6

Page 7: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

7

Page 8: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

8

Page 9: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

9

Page 10: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

10

Page 11: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

11

Page 12: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

12

Page 13: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

13

Page 14: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

14

Page 15: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

15

Page 16: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

16

In this equation, a is world coordinate, B will converta to b (in another coordinate system)

Page 17: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

17

Why B is orthonormal?

0

0000

000

231322122111

332313222212

11211121

vvvv

vvuu

In above equation, 0 is due to vi.vj=0 i!=j

1

0000

001

131312121111

331313221212

11111111

vvvv

vvuu

Page 18: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

18

b1=Bw->1aw

aw=Bw->1Tb1=B-

w->1b1

b2=Bw->2aw

aw=Bw->2Tb2=B-

w->2b2

B-w->1b1=B-

w->2b2

Bw->1B-w->1b1= Bw->1B-

w->2b2

b1= Bw->1B-w->2 b2= Bw->1B2->w b2

Page 19: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

19

Page 20: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

20

Consider a special case as v1=(1,0,0), v2=(0,1,0) and v3(0,0,1)

Page 21: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

21

a is coordinate in (v1,v2,v3) system (usually is world coordinate)b is coordinate in (u1,u2,u3) systemB is easily remembered by carefully checking BThe first row: u1 projects on three axes v1,v2,v3The second row: u2 projects on three axes v1,v2,v3The third row: u3 projects on three axes v1,v2,v3How about B’ for c is coordinate in (w1,w2,w3) for b converted toc? (i.e. c=B’b)

332313

322212

312111

uwuwuw

uwuwuw

uwuwuw

BThis is same as previousmatrix composition by way oftransforming to world coordinate

Page 22: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

22

Page 23: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

23

Page 24: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

24

Page 25: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

25

Page 26: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

26

Page 27: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

27

Page 28: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

28

X axis vectorY axis vectorZ axis vector

Page 29: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

29

Page 30: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

30

Page 31: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

31

Page 32: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

32

Intuitive Camera Specification

Page 33: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

33

Not easy for user to pick upexact up vector!!So, we compute v automaticallyfrom up vector.

Page 34: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

34

n

a

b

nb’

b

Page 35: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

35

n

a

b

Another way ………………..(1) a = b’ x n(2) b = n x a

Page 36: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

36

v1=(1,0,0), v2=(0,1,0) and v3(0,0,1)

1

0

0

0

1

).,,(),,(

1000

z

y

x

zyx

zzyx

yzyx

xzyx

eye

eye

eye

V

neyeveyeueyeddd

dnnn

dvvv

duuu

V

Page 37: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

37

Page 38: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

38

1

0

0

0

1

).,,(),,(

1000

z

y

x

zyx

zzyx

yzyx

xzyx

eye

eye

eye

V

neyeveyeueyeddd

dnnn

dvvv

duuu

V

Note that matrix storage order is column majorin OpenGL

Page 39: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

39

Treat yourself (viewer) as a airplane heading to –ZcNote that: as a viewer is moving, the object is moving inopposite direction on the viewing plane!!

u (i.e., x) axis n (i.e.,z) axis v (i.e., y) axis

Page 40: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

40

vectorsunitallarevuvuNote

vuv

vuu

,,,:

)cos()sin(

)sin()cos(

This is z-like rotation

Page 41: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

41

u’

u

n

n’ n

v

n’v’

vectorsunitallareununNote

unu

unn

,,,:

)cos()sin(

)sin()cos(

This is y-like rotation

This is x-like rotation

Page 42: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

42

How about pitch() and yaw()?Same stories as roll().7.3.1. Implementing pitch() and yaw().void Camera :: pitch (float angle){ // pitch the camera through angle degrees around Ufloat cs = cos(3.14159265/180 * angle);float sn = sin(3.14159265/180 * angle);Vector3 t(v); // remember old vv.set(cs*t.x + sn*n.x, cs*t.y + sn*n.y, cs*t.z + sn*n.z);

n.set(-sn*t.x + cs*n.x, -sn*t.y + cs*n.y, -sn*t.z + cs*n.z);setModelViewMatrix();

}void Camera :: yaw (float angle){ // yaw the camera through angle degrees around Vfloat cs = cos(3.14159265/180 * angle);float sn = sin(3.14159265/180 * angle);Vector3 t(n); // remember old vn.set(cs*t.x + sn*u.x, cs*t.y + sn*u.y, cs*t.z + sn*u.z);

u.set(-sn*t.x + cs*u.x, -sn*t.y + cs*u.y, -sn*t.z + cs*u.z);setModelViewMatrix();

}

Page 43: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

43

How about slide()Sliding a camera means to move it along one of its own axes-that is in the u,v,n direction-without rotating it.

Along n means forward or backwardAlong u is left and rightAlong v is up and down

Assume slide(delU, delV, delN)

Page 44: 1 Viewing Transformation Tong-Yee Lee. 2 Changes of Coordinate System World coordinate system Camera (eye) coordinate system.

44

Flythrough a Scene!!!


Related Documents