viewing transformations cs5600 computer graphics by rich riesenfeld 5 march 2002 lecture set 11
Post on 20-Dec-2015
216 Views
Preview:
TRANSCRIPT
Viewing Transformations
CS5600 Computer Graphicsby
Rich Riesenfeld
5 March 2002Lect
ure
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)
CS5600 3
Illustration: Old Style, Simple Transformation Sequence for
3D Viewing
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
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)
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
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
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(
CS5600 9x
z
y
x
z
y
Translate Origin by T1
(6,8,0)
x
z
y
CS5600 10
Simple Viewing Transformation Example
1000
5.7100
8010
6001
1T
CS5600 11x
z
y
ex
ez
ey
Build LH Coord with T 2
(6,8,0)
x
z
y
CS5600 12
1000
0010
0100
0001
2T
Build LH Coord with T 2
CS5600 13x
z
y
exezey
Rotate about y with T 3
(6,8,0)
6
8
10
x
z
y
CS5600 14
1000
08.06.
0010
06.08.
3T
Simple Viewing Transformation Example
106)sin(
108)cos(
,
where
CS5600 15
Rotate about x-axis with
x
z
y
ex
ez
ey
7.5
T 4
10
x
y
z
CS5600 16
Look at the (3-4-5) Right Triangle
7.5
10
12.5
53)sin(
54)cos(
(4)
(5)(3)
CS5600 17
Simple Viewing Transformation Examle
1000
08.6.0
06.8.0
0001
4T
53)sin(
54)cos(
,
where
CS5600 18
View on 10x10 screen, 20 away10
1020
30
CS5600 19
Map to canonical frustum
4520
20
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.
CS5600 21
1000
5.126.64.48.
06.196.72.
002.16.1
1234 TTTTN
Simple Viewing Transformation Example
CS5600 22
Clipping not needed, so project
1000
0000
0010
0001
icorthographP
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
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
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)
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
CS5600 27
• Substitute x =a:
12
)(2
2
22
22
22
ab
ab
baa
ab
baa
ab
x
Recall mapping [a,b] [-1,1]
CS5600 28
• Substitute x =b:
12
2
2
22
22
22
ab
ab
bab
ab
bab
ab
x
Recall mapping [a,b] [-1,1]
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).
CS5600 30
Map to the (1K x 1K) screen
1000
0100
005110
000511
xyS
Proper scale factor for mapping:
[-1,1] to (-511,+511)
CS5600 31
Combine Screen Transformation
1000
0100
51105110
51100511
xyT
xySV
CS5600 32
For General Screen: ……
1000
0100
2
10
2
10
2
100
2
1
yn
yn
xn
xn
V
)(y
nx
n
CS5600 33
Transformation to Std Clipping Frustum
CS5600 34
Transforming to Std Frustumyx,
z
),,( baa
yxz ,
CS5600 35
Transforming to Std Frustumyx,
z
),,( baa
yxz ,),,( bbb
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
CS5600 37
Transforming to Std Frustum
1000
0100
000
000
a
ba
b
11
b
b
b
b
a
a
Determining Rotation Matrix
CS5600 39
e3
e2
e1
d1
d 2
d 3
Frame rotation, ed ii :M
CS5600 40
e3
e2
e1
d1
d 2
d 3
Inverse problem easy, ed ii :1M
CS5600 41
In matrix representation of ,
Columns are simply images of
ddddddddd
zzz
yxy
xxx
321
321
321
1
M
s'ei
1M
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
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
CS5600 44
Rotation matrix M
• Row i is simply
• Simply write M down!
ddddddddd
zyx
zxx
zyx
333
222
111
M
d i
Thus,
CS5600 45
e3
e2
e1
d1
d 2
d 3
Frame Rotation: ed ii
46
47
48
49
50
51
52
The End of
Viewing Transformations
Lect
ure
Set
11
53
top related