CSCE 441 Computer Graphics 3-D Viewing
description
Transcript of CSCE 441 Computer Graphics 3-D Viewing
![Page 1: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/1.jpg)
Jinxiang Chai
CSCE 441 Computer Graphics3-D Viewing
1
![Page 2: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/2.jpg)
Outline
3D Viewing
Required readings: HB 10-1 to 10-10
Compile and run the codes in page 388
- opengl three-dimensional viewing program example
2
![Page 3: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/3.jpg)
Taking Pictures Using A Real Camera
Steps:
- Identify interesting objects
- Rotate and translate the camera to a desired camera viewpoint
- Adjust camera settings such as focal length
- Choose desired resolution and aspect ratio, etc.
- Take a snapshot
![Page 4: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/4.jpg)
Taking Pictures Using A Real Camera
Steps:
- Identify interesting objects
- Rotate and translate the camera to a desired camera viewpoint
- Adjust camera settings such as focal length
- Choose desired resolution and aspect ratio, etc.
- Take a snapshot
Graphics does the same thing for rendering an image for 3D geometric objects
![Page 5: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/5.jpg)
Image space
3D Geometry Pipeline
5
Normalized
projection space
View spaceWorld spaceObject space
Aspect ratio &
resolution
Focal length
Rotate and translate the
camera
11
z
y
x
MCPVd
v
u
![Page 6: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/6.jpg)
3D Geometry Pipeline
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
6
Model space
(Object space)
![Page 7: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/7.jpg)
3D Geometry Pipeline
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
7
World space
(Object space)
![Page 8: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/8.jpg)
3D Geometry Pipeline
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
8
Eye space
(View space)
![Page 9: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/9.jpg)
3D Geometry Pipeline
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
9
Normalized projection
space
![Page 10: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/10.jpg)
3D Geometry Pipeline
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
10
Image space, window space, raster
space, screen space, device space
![Page 11: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/11.jpg)
3D Geometry Pipeline
11
Normalized project
space
View spaceWorld spaceObject space
Image space
![Page 12: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/12.jpg)
3D Geometry Pipeline
World spaceObject space
glTranslate*(tx,ty,tz)
11000
100
010
001
1
z
y
x
t
t
t
z
y
x
x
y
x
Translate, scale &rotate
![Page 13: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/13.jpg)
3D Geometry Pipeline
Object space
11000
000
000
000
1
z
y
x
s
s
s
z
y
x
z
y
x
glScale*(sx,sy,sz)
World space
Translate, scale &rotate
![Page 14: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/14.jpg)
3D Geometry Pipeline
Object space
glRotate*),,,( zyx vvv
xy
z),( , zyx vvvr
TRRRRRT zyzyz )()()()()(1
Rotate about r by the angle
World space
Translate, scale &rotate
![Page 15: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/15.jpg)
Image space
3D Geometry Pipeline
15
Screen spaceNormalized project
space
View spaceWorld spaceObject space
![Page 16: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/16.jpg)
Now look at how we would compute the world->eye transformation
3D Geometry Pipeline
View spaceWorld space
![Page 17: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/17.jpg)
Now look at how we would compute the world->eye transformation
3D Geometry Pipeline
View spaceWorld space
Rotate&translate
![Page 18: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/18.jpg)
Camera Coordinate
18
![Page 19: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/19.jpg)
Canonical coordinate system
- usually right handed (looking down –z axis)
- convenient for project and clipping
Camera Coordinate
![Page 20: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/20.jpg)
Mapping from world to eye coordinates
- eye position maps to origin
- right vector maps to x axis
- up vector maps to y axis
- back vector maps to z axis
Camera Coordinate
![Page 21: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/21.jpg)
We have the camera in world coordinates We want to transformation T which takes object from world
to camera
Viewing Transformation
wcw
c pTp ,
![Page 22: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/22.jpg)
We have the camera in world coordinates We want to transformation T which takes object from world
to camera
Trick: find T-1 taking object from camera to world
Viewing Transformation
wcw
c pTp ,
ccw
w pTp 1, )(
![Page 23: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/23.jpg)
We have the camera in world coordinates We want to transformation T which takes object from world
to camera
Trick: find T-1 taking object from camera to world
Viewing Transformation
wcw
c pTp ,
ccw
w pTp 1, )(
plhd
okgc
njfb
miea
TT wccw ,1
,
?
![Page 24: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/24.jpg)
Review: 3D Coordinate Trans.
Transform object description from to
pj
i
i
j
o
o
'kji ijk
1
'
'
'
1000
'
'
'
10
0
0
z
y
x
zkkjkik
ykjjjij
xkijiii
z
y
x
TTT
TTT
TTT
),,( 000 zyx
k
'k
poooop
25
![Page 25: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/25.jpg)
Review: 3D Coordinate Trans.
Transform object description from to
pj
i
0
0
1
i
0
1
0
j
o
o
'kji ijk
1
'
'
'
1000
'''
'''
'''
10
0
0
z
y
x
zkji
ykji
xkji
z
y
x
zzz
yyy
xxx),,( 000 zyx
1
0
0
k
'k
poooop
26
![Page 26: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/26.jpg)
Review: 3D Coordinate Trans.
Transform object description from camera to world
27
),,( zyx uuu),,( zyx nnn),,( zyx vvv
10000
0
0
,1
, znvu
ynvu
xnvu
TTzzz
yyy
xxx
wccw
![Page 27: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/27.jpg)
Trick: find T-1 taking object from camera to world
- eye position maps to origin
- back vector maps to z axis
- up vector maps to y axis
- right vector maps to x axis
Viewing Transformation
10000
0
0
,1
, znvu
ynvu
xnvu
TTzzz
yyy
xxx
wccw
![Page 28: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/28.jpg)
Trick: find T-1 taking object from camera to world
Viewing Transformation
1
0
1
0
0
0
, 1000
1000
pnvu
znvu
ynvu
xnvu
Tzzz
yyy
xxx
cw
100
0
0
, pn
pv
pu
n
v
u
TT
T
T
cw
H&B equation (10-4)
![Page 29: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/29.jpg)
Viewing Trans: gluLookAt
30
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
![Page 30: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/30.jpg)
Mapping from world to eye coordinates
Viewing Trans: gluLookAt
),,( zyxref atatatp
),,(0 zyx eyeeyeeyep
),,( zyx upupupV
How to determine ?
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
nvu
,,
![Page 31: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/31.jpg)
Mapping from world to eye coordinates
Viewing Trans: gluLookAt
),,( zyxref atatatp
),,(0 zyx eyeeyeeyep
),,( zyx upupupV
How to determine ?
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
nvu
,,
![Page 32: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/32.jpg)
Mapping from world to eye coordinates
Viewing Trans: gluLookAt
),,( zyxref atatatp
),,(0 zyx eyeeyeeyep
refppN
0
),,( zyx upupupV
N
Nn
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
![Page 33: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/33.jpg)
Mapping from world to eye coordinates
Viewing Trans: gluLookAt
),,( zyxref atatatp
),,(0 zyx eyeeyeeyep
refppN
0
),,( zyx upupupV
N
Nn
V
nVu
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
![Page 34: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/34.jpg)
Mapping from world to eye coordinates
Viewing Trans: gluLookAt
),,( zyxref atatatp
),,(0 zyx eyeeyeeyep
refppN
0
),,( zyx upupupV
N
Nn
V
nVu
unv
H&B equation (10-1)
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)
![Page 35: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/35.jpg)
Viewing Trans: gluLookAt
Test: gluLookAt( 4.0, 2.0, 1.0, 2.0, 4.0, -3.0, 0, 1.0, 0 )
- What’s the transformation matrix from the world space to the camera reference system?
![Page 36: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/36.jpg)
3D Geometry Pipeline
View spaceWorld space
3D-3D viewing
transformation
![Page 37: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/37.jpg)
Projection
General definition
transform points in n-space to m-space (m<n)
In computer graphics
map 3D coordinates to 2D screen coordinates
![Page 38: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/38.jpg)
Projection
General definition
transform points in n-space to m-space (m<n)
In computer graphics
map 3D coordinates to 2D screen coordinates
How can we project 3d objects to 2d screen space?
![Page 39: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/39.jpg)
How Do We See the World?
Let’s design a camera:
idea 1: put a piece of film in front of camera
Do we get a reasonable picture?
![Page 40: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/40.jpg)
Pin-hole Camera
Add a barrier to block off most of the raysThis reduces blurringThe opening known as the apertureHow does this transform the image?
![Page 41: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/41.jpg)
Camera Obscura
The first camera Known to Aristotle Depth of the room is the focal length Pencil of rays – all rays through a point
![Page 42: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/42.jpg)
Perspective Projection
Maps points onto “view plane” along projectors emanating from “center of projection” (COP)
43
![Page 43: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/43.jpg)
Perspective Projection
Maps points onto “view plane” along projectors emanating from “center of projection” (COP)
44
What’s relationship between 3D points and
projected 2D points?
![Page 44: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/44.jpg)
Consider the projection of a 3D point on the camera plane
3D->2D
45
![Page 45: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/45.jpg)
Consider the projection of a 3D point on the camera plane
3D->2D
46
![Page 46: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/46.jpg)
Consider the projection of a 3D point on the camera plane
3D->2D
47
By similar triangles, we can compute how much the x and y coordinates are scaled
![Page 47: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/47.jpg)
Consider the projection of a 3D point on the camera plane
3D->2D
48
By similar triangles, we can compute how much the x and y coordinates are scaled
z
dxx
d
x
z
x
'
z
dyy
d
y
z
y
'
'
![Page 48: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/48.jpg)
Homogeneous Coordinates
Is this a linear transformation?
![Page 49: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/49.jpg)
Homogeneous Coordinates
Is this a linear transformation?– no—division by z is nonlinear
![Page 50: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/50.jpg)
Homogeneous Coordinates
Is this a linear transformation?
Trick: add one more coordinate:
homogeneous image
coordinates
homogeneous scene
coordinates
– no—division by z is nonlinear
![Page 51: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/51.jpg)
Remember how we said 2D/3D geometric transformations work with the last coordinate always set to one
What happens if the coordinate is not one We divide all coordinates by w:
Homogeneous Point Revisited
52
If w=1, nothing happens
Sometimes, we call this division step the “perspective divide”
![Page 52: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/52.jpg)
Now we can rewrite the perspective projection equation as matrix-vector multiplications
The Perspective Matrix
53
z
dxx
d
x
z
x
'
z
dyy
d
y
z
y
'
'
![Page 53: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/53.jpg)
Now we can rewrite the perspective projection equation as matrix-vector multiplications
The Perspective Matrix
54
z
dxx
d
x
z
x
'
z
dyy
d
y
z
y
'
'
10100
0010
0001
'
'
'
z
y
x
dw
y
x
This becomes a linear transformation!
![Page 54: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/54.jpg)
Now we can rewrite the perspective projection equation as matrix-vector multiplications
The Perspective Matrix
55
After the division by w, we have
z
dxx
d
x
z
x
'
z
dyy
d
y
z
y
'
'
10100
0010
0001
'
'
'
z
y
x
dw
y
x
11
'
'
zdy
zdx
y
x
![Page 55: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/55.jpg)
Perspective Effects
Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)
![Page 56: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/56.jpg)
Perspective Effects
Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)
![Page 57: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/57.jpg)
Perspective Effects
Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)
![Page 58: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/58.jpg)
Perspective projection is an example of projective transformation
- lines maps to lines
- parallel lines do not necessary remain parallel
- ratios are not preserved
Properties of Perspective Proj.
![Page 59: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/59.jpg)
Perspective projection is an example of projective transformation
- lines maps to lines
- parallel lines do not necessary remain parallel
- ratios are not preserved One of advantages of perspective projection is that
size varies inversely proportional to the distance-looks realistic
Properties of Perspective Proj.
![Page 60: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/60.jpg)
What happens to parallel lines they are not parallel to the projection plane?
Vanishing Points
61
![Page 61: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/61.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
Vanishing Points
62
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
p v
![Page 62: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/62.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
After perspective transformation, we have
Vanishing Points
63
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
11
'
'
zdy
zdx
y
x
d
tvp
tvp
dtvp
tvp
y
x
zz
yy
zz
xx
11
'
'
p v
![Page 63: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/63.jpg)
Letting t go to infinity:
Vanishing Points (cont.)
64
d
tvp
tvp
dtvp
tvp
y
x
zz
yy
zz
xx
11
'
'
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
![Page 64: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/64.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
Vanishing Points
65
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
![Page 65: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/65.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
How about the line
Vanishing Points
66
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
01z
y
x
z
y
x
v
v
v
tq
q
q
vtql
![Page 66: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/66.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
How about the line
Vanishing Points
67
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
01z
y
x
z
y
x
v
v
v
tq
q
q
vtql
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
![Page 67: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/67.jpg)
What happens to parallel lines they are not parallel to the projection plane?
The equation of the line:
How about the line
Vanishing Points
68
01z
y
x
z
y
x
v
v
v
tp
p
p
vtpl
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
01z
y
x
z
y
x
v
v
v
tq
q
q
vtql
d
v
v
dv
v
y
x
z
y
z
x
11
'
'
Same vanishing point!
![Page 68: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/68.jpg)
What happens to parallel lines they are not parallel to the projection plane?
Each set of parallel lines intersect at a vanishing point on the PP
Vanishing Points
![Page 69: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/69.jpg)
What happens to parallel lines they are not parallel to the projection plane?
Each set of parallel lines intersect at a vanishing point on the PP
Vanishing Points
![Page 70: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/70.jpg)
Parallel Projection
Center of projection is at infinity
Direction of projection (DOP) same for all points
![Page 71: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/71.jpg)
Orthographic Projection
Direction of projection (DOP) perpendicular to view plane
![Page 72: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/72.jpg)
Orthographic Projection
Direction of projection (DOP) perpendicular to view plane
1000
0000
0010
0001
![Page 73: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/73.jpg)
Properties of Parallel Projection
Not realistic looking Good for exact measurement Are actually affine transformation
- parallel lines remain parallel
- ratios are preserved
- angles are often not preserved Most often used in CAD, architectural drawings,
etc. where taking exact measurement is important
![Page 74: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/74.jpg)
Perspective projection from 3D to 2D
3D->2D
75
10100
0010
0001
'
'
'
z
y
x
dw
y
x
![Page 75: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/75.jpg)
Perspective projection from 3D to 2D
3D->2D
76
10100
0010
0001
'
'
'
z
y
x
dw
y
x
But so far, we have not considered the size of film
plane!
We have also not considered visibility problem
![Page 76: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/76.jpg)
Image space
3D Geometry Pipeline
77
Screen spaceNormalized project
space
View spaceWorld spaceObject space
z = -1z = 1
![Page 77: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/77.jpg)
The center of projection and the portion of projection plane that map to the final image form an infinite pyramid. The sides of pyramid called clipping planes
Additional clipping planes are inserted to restrict the range of depths
Perspective Projection Volume
![Page 78: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/78.jpg)
OpenGL Perspective-Projection
79
Normalized project
space
View space
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
gluPerspective(fovy,aspect,dnear, dfar)
z = -1z = 1
![Page 79: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/79.jpg)
View space
(xwmin,ywmin,Znear)(xwmax,ywmax,znear)
General Perspective-Projection
zfar
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
Six parameters define six clipping planes!
nearnear zd
![Page 80: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/80.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
Left-vertical clipping plane
![Page 81: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/81.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
right-vertical clipping plane
![Page 82: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/82.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
bottom-horizontal clipping plane
![Page 83: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/83.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
top-horizontal clipping plane
![Page 84: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/84.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
near clipping plane
nearnear zd
![Page 85: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/85.jpg)
General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
far clipping plane
farfar zd
![Page 86: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/86.jpg)
Normalized project space (left-
handed)
View space (right-
handed)
B’=(1,1,1)
A’=(-1,-1,-1)
General Perspective-Projection
A maps to A’, B maps to B’Keep the directions of x and y axes!
A
B
![Page 87: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/87.jpg)
B’=(1,1,1)
A’=(-1,-1,-1)
General Perspective-Projection
0100
200
02
0
002
minmax
minmax
minmax
minmax
minmax
minmax
farnear
farnear
farnear
farnear
near
near
zz
zz
zz
zzywyw
ywyw
ywyw
zxwxw
xwxw
xwxw
z
T
H&B equation (10-40)
A
B
![Page 88: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/88.jpg)
OpenGL Symmetric Perspective-Projection Function gluPerspective(fovy,aspect,dnear, dfar)
89
Assume z-axis is the centerline of 3D view frustum!
![Page 89: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/89.jpg)
Image space
3D Geometry Pipeline
90
Normalized project
space
View spaceWorld spaceObject space
![Page 90: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/90.jpg)
Image space-.>Image space
Viewport Transformation
91
glViewport(xmin, ymin, width, height)
(xmin,ymin)
Display window
viewport
![Page 91: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/91.jpg)
Image space-.>Image space
Viewport Transformation
92
glViewport(xmin, ymin, width, height)
(xmin,ymin)
- Besides x and y, each pixel has a depth value z, which is stored in depth buffer.
-Depth values will be used for visibility testing
-The color of the pixel is stored in color buffer
![Page 92: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/92.jpg)
93
Image space
Normalized project
space
B’=(1,1,1)
A’=(-1,-1,-1)
Normalized project space
A’’=(xvmin,yvmin,0)
B’’=(xvmax,yvmax,1)
Viewport Transformation
-1<=z<=1
0<=z<=1
![Page 93: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/93.jpg)
Viewport Transformation
94
Image space
Normalized project
space
B’=(1,1,1)
A’=(-1,-1,-1)
Normalized project space
A’’=(xvmin,yvmin,0)
B’’=(xvmax,yvmax,1)
10002
1
2
100
20
20
200
2minmaxminmax
minmaxminmax
yvyvyvyv
xvxvxvxv
T
H&B equation (10-42)
-1<=z<=1
0<=z<=1
![Page 94: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/94.jpg)
Image space
Summary: 3D Geometry Pipeline
95
Normalized project
space
View spaceWorld spaceObject space
![Page 95: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/95.jpg)
Taking Steps Together
96
11
z
y
x
MCPVd
v
u
Image spaceNormalized project
space
View spaceWorld spaceObject space
![Page 96: CSCE 441 Computer Graphics 3-D Viewing](https://reader031.fdocuments.us/reader031/viewer/2022020921/56815a6a550346895dc7c06e/html5/thumbnails/96.jpg)
OpenGL Codes
97