CS-184: Computer Graphics
Lecture #8: Projection
- Prof. James O’Brien
University of California, Berkeley
V2016-F-08-1.0
1
2
Today
- Windowing and Viewing Transformations
- Windows and viewports
- Orthographic projection
- Perspective projection
CS-184: Computer Graphics Lecture #8: Projection Prof. James - - PowerPoint PPT Presentation
1 CS-184: Computer Graphics Lecture #8: Projection Prof. James OBrien University of California, Berkeley V2016-F-08-1.0 2 Today Windowing and Viewing Transformations Windows and viewports Orthographic projection
University of California, Berkeley
V2016-F-08-1.0
2
3
[0,0] [1024,768] [60,350] [690,705] [0,0] [1024,768]
4
From Shirley textbook.
5
6
nx-0.5,ny-0.5
7
0,0 1,1
8
From Shirley textbook.
+1,+1
9
x y y (1,1) (-1,-1) x (nx-0.5, -0.5) (-0.5, ny-0.5) x y (1,-1) (-1,1) (nx/2,-ny/2) (-nx/2,ny/2) y x reflect-y translate scale
From Shirley textbook. (Image coordinates are up-side-down.)
nx 2 0 nx1 2
2 ny1 2
−
Remove minus for up-side-up
10
11
12
13
14
Orthographic Perspective
15
16
17
Orthographic Perspective
Note how different things can be seen Parallel lines “meet” at infinity
18
19
20
From Shirley textbook.
21
22
[1,1,1] [-1,-1,-1]
23
[1,1,1] [-1,-1,-1]
24
View vector Up vector Right = view X up Origin Center near,top,right far,bottom,left *Assume up is perpendicular to view.
25
26
27
28
29
30
31
Image from D. Forsyth
32
Image from D. Forsyth
33
34
35
36
u v n
37
View Up Distance to image plane i Y
Top t Bottom b Near n Far f Center
38
Y
39
Y
40
Y
41
! ! ! ! ! ! " # $ $ $ $ $ $ % & − + 1 1 1 i f i f i
42
! ! ! ! ! ! " # $ $ $ $ $ $ % & − + 1 1 1 i f i f i
43
From Shirley textbook.
! ! ! ! ! ! " # $ $ $ $ $ $ % & − + 1 1 1 i f i f i
44
“Eye” plane Top Near Far S
e h
i z
t a l l i n e s View vector
45
46
47
48
49
50
51
52
−∞
53
−∞
54
55
56
57
58
59
w y x
60
w y x
w y w x
61
z y y z x x w y w x
y x
62
y x
63
64
. .
From Correction of Geometric Perceptual Distortions in Pictures, Zorin and Barr SIGGRAPH 1995
65 From WIRED Magazine
66 The Ambassadors by Hans Holbein the Younger
67 The Ambassadors by Hans Holbein the Younger
68
69
! ! ! ! " # $ $ $ $ % & = ! ! ! ! " # $ $ $ $ % &
w z y x w z y x
W W W W I I I I M
! ! ! ! " # $ $ $ $ % & = ! ! ! ! " # $ $ $ $ % &
− w z y x w z y x
I I I I W W W W
1
M
70
Depends on screen details, YMMV General idea should translate...
71
72 42
P1 P2 P3 P4 S1 = P1/h1 S2 = P2/h2 S3 = P3/h3 S4 = P4/h4
73 42
P1 P2 P3 P4 S1 = P1/h1 S2 = P2/h2 S3 = P3/h3 S4 = P4/h4 X = X i Sibi Q = X i Piai
Si Pi bi ai
74 42
P1 P2 P3 P4 S1 = P1/h1 S2 = P2/h2 S3 = P3/h3 S4 = P4/h4 X = X i Sibi Q = X i Piai X = Q/h = @X i Piai 1 A / B @ X j hjaj 1 C A
X i Sibi = @X i Piai 1 A / B @ X j hjaj 1 C A
75 42
P1 P2 P3 P4 S1 = P1/h1 S2 = P2/h2 S3 = P3/h3 S4 = P4/h4 X = X i Sibi Q = X i Piai
X i Pibi/hi = @X i Piai 1 A / B @ X j hjaj 1 C A
76 42
P1 P2 P3 P4 S1 = P1/h1 S2 = P2/h2 S3 = P3/h3 S4 = P4/h4 X = X i Sibi Q = X i Piai
X i Pibi/hi = @X i Piai 1 A / B @ X j hjaj 1 C A
77 42
Independent of given vertex locations.
bi/hi = ai/ B @ X j hjaj 1 C A ∀i
78 42
bi/hi = ai/ B @ X j hjaj 1 C A ∀i B @ X j hjaj 1 C A bi/hi − ai = 0 ∀i ai
79
B @ X j hjaj 1 C A bi/hi − ai = 0 ∀i ai X i ai = X i bi = 1
Not invertible so add some extra constraints. Linear equations in the .
80
a1 = h2bi/(b1h2 + h1b2) a1 = h2h3b1/(h2h3b1 + h1h3b2 + h1h2b3)