Download - UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk [email protected] ozturk
![Page 1: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/1.jpg)
UBI 516UBI 516 Advanced Computer GraphicsAdvanced Computer Graphics
Three Dimensional ViewingThree Dimensional Viewing
Aydın Öztü[email protected]
http://www.ube.ege.edu.tr/~ozturk
![Page 2: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/2.jpg)
OverviewOverview
• Viewing a 3D scene
• Projections– Parallel and perspective
![Page 3: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/3.jpg)
OverviewOverview
• Depth cueing and hidden surfaces
• Identifying visible lines and surfaces
![Page 4: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/4.jpg)
OverviewOverview
• Surface rendering
![Page 5: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/5.jpg)
OverviewOverview
• Exploded and cutaway views
![Page 6: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/6.jpg)
OverviewOverview
• 3D and stereoscopic viewing
![Page 7: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/7.jpg)
3D Viewing Pipeline3D Viewing Pipeline
ModelingTransformation
ViewingTransformation
ProjectionnTransformation
NormalizationTransformation
and Clipping
ViewportTransformation
MC
WC
VC PC
NC
DC
![Page 8: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/8.jpg)
Viewing CoordinatesViewing Coordinates
• Generating a view of an object in 3D is similar to photographing the object.
• Whatever appears in the viewfinder is projected onto the flat film surface.
• Depending on the position, orientation and aperture size of the camera corresponding views of the scene is obtained.
![Page 9: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/9.jpg)
Specifying The View CoordinatesSpecifying The View Coordinates
• For a particular view of a scene first we establish viewing-coordinate system.
• A view-plane (or projection plane) is set up perpendicular to the viewing z-axis.
• World coordinates are transformed to viewing coordinates, then viewing coordinates are projected onto the view plane.
xw
zw
yw
xv
zv
yv
P0=(x0 , y0 , z0)
![Page 10: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/10.jpg)
Specifying The View CoordinatesSpecifying The View Coordinates
• To establish the viewing reference frame, we first pick a world coordinate position called the view reference point.
• This point is the origin of our viewing coordinate system. If we choose a point on an object we can think of this point as the position where we aim a camera to take a picture of the object.
![Page 11: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/11.jpg)
Specifying The View CoordinatesSpecifying The View Coordinates
• Next, we select the positive direction for the viewing z-axis, and the orientation of the view plane, by specifying the view-plane normal vector, N.
• We choose a world coordinate position P and this point establishes the direction for N.
• OpenGL establishes the direction for N using the point P as a look at point relative to the viewing coordinate origin.
xw
zw
yw
xv
zv
P0
P
N
xv
yv
![Page 12: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/12.jpg)
Specifying The View CoordinatesSpecifying The View Coordinates
• Finally, we choose the up direction for the view by specifying view-up vector V.
• This vector is used to establish the positive direction for the yv axis.
• The vector V is perpendicular to N.• Using N and V, we can compute a
third vector U, perpendicular to both N and V, to define the direction for the xv axis.
xw
zw
yw
xv
zv
yv
P0
P
N
V
![Page 13: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/13.jpg)
Specifying The View CoordinatesSpecifying The View Coordinates
To obtain a series of views of a scene , we can keep the the view reference point fixed and change the direcion of N. This corresponds to generating views as we move around the viewing coordinate origin.
P0
V
N
N
![Page 14: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/14.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
Conversion of object descriptions from world to viewing coordinates is equivalent to transformation that superimpoes the viewing reference frame onto the world frame using the translation and rotation.
xw
yw
zw
xv
yv
zv
![Page 15: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/15.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
First, we translate the view reference point to the origin of the world coordinate system
xw
yw
zw
xv
yv
zv
![Page 16: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/16.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
Second, we apply rotations to align the xv,, yv and zv axes with the world xw, yw and zw axes, respectively.
xw
yw
zw
xv
yv
zv
xv
yv
zv
![Page 17: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/17.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
If the view reference point is specified at word position (x0, y0, z0), this point is translated to the world origin with the translation matrix T.
1000
100
010
001
0
0
0
z
y
x
T
![Page 18: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/18.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
• The rotation sequence requires 3 coordinate-axis transformation depending on the direction of N.
• First we rotate around xw-axis to bring zv into the xw
-zw plane.
1000
00
00
0001
CosSin
SinCosxR
![Page 19: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/19.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
Then, we rotate around the world yw axis to align the zw and zv axes.
1000
00
0010
00
CosSin
SinCos
yR
![Page 20: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/20.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
The final rotation is about the world zw axis to align the yw and yv axes.
1000
0100
00
00
CosSin
SinCos
zR
![Page 21: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/21.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
The complete transformation from world to viewing coordinate transformation matrix is obtaine as the matrix product
TRRRM xyzvcwc ,
![Page 22: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/22.jpg)
Another method for generating the rotation-transformation matrix is to calculate uvn vectors and obtain the composite rotation matrix directly. Given the vectors and , these unit vectors are calculated as
N V
),,(
),,(
),,(
321
321
321
vvv
uuu
nnn
unv
NVNV
u
NN
n
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
![Page 23: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/23.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
This method also automatically adjusts the direction for so that is perpendicular to . The rotation matrix for the viewing transformation is then
Vnv
10 0 0
0
0
0
321
321
321
nnn
vvv
uuu
R
![Page 24: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/24.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
The matrix for translating the viewing origin to the world origin is
1 0 0
100
0 10
0 01
0
0
0
z
y
x
R
![Page 25: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/25.jpg)
Transformation From World To Transformation From World To Viewing CoordinatesViewing Coordinates
The composite matrix for the viewing transformation is then
zyx
zyx
zyx
VCWC
nznynxt
vzvyvxt
uzuyuxt
tnnn
tvvv
tuuu
00003
00002
00001
3321
2321
1321
,
where
10 0 0
Pn
Pv
Pu
M
![Page 26: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/26.jpg)
Transformation From World To Viewing Transformation From World To Viewing Coordinates: Coordinates: An Example For 2d SystemAn Example For 2d System
y
x
x′y′
Θ=300
0 2 4 6
0
2
4
6
2
2
P=(5,5)
P0=(4,3)
![Page 27: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/27.jpg)
y
x
x′y′
Θ=300
2 4 6
0
2
4
6
2 2
P
P0
Translation:
100
310
401
T
Transformation From World To Viewing Transformation From World To Viewing Coordinates: Coordinates: An Example For 2d SystemAn Example For 2d System
![Page 28: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/28.jpg)
Rotation
0
2
4
6
y
xx′
y′
2 4 6
P
P0
100
0866.05.0
05.0866.0
R
Transformation From World To Viewing Transformation From World To Viewing Coordinates: Coordinates: An Example For 2d SystemAn Example For 2d System
![Page 29: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/29.jpg)
New coordinates
100
310
401
100
0866.05.0
05.0866.0
.vcwcM
1
232.1
866.1
1
5
5
100
598.0866.0500.0
964.4500.0866.0
1
'
'
y
x
Transformation From World To Viewing Transformation From World To Viewing Coordinates: Coordinates: An Example For 2d SystemAn Example For 2d System
![Page 30: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/30.jpg)
Alternative Method
xTRx
R
v
n
'
100
0866.0500.0
0500.0866.0
)866.0500.0(
)500.0866.0( y
x
x′y′
Θ=300
0
1
2
3
1
1
P
P01 2 3
nv
Transformation From World To Viewing Transformation From World To Viewing Coordinates: Coordinates: An Example For 2d SystemAn Example For 2d System
![Page 31: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/31.jpg)
ProjectionsProjections
• Once WC description of the objects in a scene are converted to VC we can project the 3D objects onto 2D view-plane.
• Two types of projections:
-Parallel Projection
-Perspective Projection
![Page 32: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/32.jpg)
Classical ViewingsClassical Viewings
• Hand drawings : Determined by a specific relationship between the object and the viewer.
![Page 33: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/33.jpg)
Parallel ProjectionsParallel Projections
Coordinate Positions are transformed to the view plane along parallel lines.
P1
P2 P′2
P′1
View
Plane
![Page 34: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/34.jpg)
Parallel ProjectionsParallel Projections
• Orthographic parallel projection The projection is perpendicular to the view plane.
• Oblique parallel projecion The parallel projection is not perpendicular to the view plane.
![Page 35: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/35.jpg)
Orthographic Parallel ProjectionOrthographic Parallel Projection
The orthographic transformation
11000
0000
0010
0001
1
'
'
'
z
y
x
z
y
x
![Page 36: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/36.jpg)
Orthographic Parallel ProjectionOrthographic Parallel Projection
![Page 37: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/37.jpg)
Oblique Parallel ProjectionOblique Parallel Projection
– The projectors are still ortogonal to the projection plane– But the projection plane can have any orientation with
respect to the object.– It is used extensively in architectural and mechanical design.
![Page 38: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/38.jpg)
Oblique Parallel ProjectionOblique Parallel Projection
• Preserve parallel lines but not angles– Isometric view : Projection plane is placed
symmetrically with respect to the three principal faces that meet at a corner of object.
– Dimetric view : Symmetric with two faces.– Trimetric view : General case.
![Page 39: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/39.jpg)
Oblique Parallel ProjectionOblique Parallel Projection
• Preserve parallel lines but not angles– Isometric view : Projection plane is placed
symmetrically with respect to the three principal faces that meet at a corner of object.
– Dimetric view : Symmetric with two faces.– Trimetric view : General case.
![Page 40: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/40.jpg)
Oblique Parallel ProjectionOblique Parallel Projection
φ
α
(xp, yp)
(x, y, z)
(x, y)
yv
xv
zv
L
)sin(
)cos(
tan
sin
cos
1
1
1
Lzyy
Lzxx
zLz
L
Lyy
Lxx
p
p
p
p
)sin(
)cos(
tan
sin
cos
1
1
1
Lzyy
Lzxx
zLz
L
Lyy
Lxx
p
p
p
p
![Page 41: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/41.jpg)
The oblique transformation
11000
0000
0sin10
0cos01
1
1
1
z
y
x
L
L
z
y
x
p
p
p
Oblique Parallel ProjectionOblique Parallel Projection
![Page 42: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/42.jpg)
Oblique Parallel ProjectionOblique Parallel Projection
![Page 43: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/43.jpg)
Perspective ProjectionsPerspective Projections
• First discovered by Donatello, Brunelleschi, and DaVinci during Renaissance
• Objects closer to viewer look larger• Parallel lines appear to converge to single
point
![Page 44: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/44.jpg)
Perspective ProjectionsPerspective Projections
In perspective projection object positions are transformed to the view plane along lines that converge to a point called the projection reference point (or center of projection)
![Page 45: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/45.jpg)
Perspective ProjectionsPerspective Projections
• In the real world, objects exhibit perspective foreshortening: distant objects appear smaller
• The basic situation:
![Page 46: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/46.jpg)
When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world:
How tall shouldthis bunny be?
Perspective ProjectionsPerspective Projections
![Page 47: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/47.jpg)
The geometry of the situation is that of similar triangles. View from above:
d
P (x, y, z) X
Z(0,0,0)x′ = ?
Perspective ProjectionsPerspective Projections
View plane
(xp, yp)
![Page 48: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/48.jpg)
Desired result for a point [x, y, z, 1]T projected onto the view plane:
dzdz
y
z
ydy
dz
x
z
xdx
z
y
d
y
z
x
d
x
',','
',
'
Perspective ProjectionsPerspective Projections
![Page 49: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/49.jpg)
1100
0100
0010
0001
d
eperspectivM
Perspective ProjectionsPerspective Projections
![Page 50: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/50.jpg)
hyyhxx
dzh
z
y
x
dh
z
y
x
hphp
h
h
h
/,/
/
10100
0100
0010
0001
Perspective ProjectionsPerspective Projections
![Page 51: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/51.jpg)
Projection MatrixProjection Matrix
• We talked about geometric transforms, focusing on modeling transforms– Ex: translation, rotation, scale, gluLookAt()
– These are encapsulated in the OpenGL modelview matrix
• Can also express projection as a matrix– These are encapsulated in the OpenGL
projection matrix
![Page 52: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/52.jpg)
• When a camera used to take a picture, the type of lens used determines how much of the scene is caught on the film.
• In 3D viewing, a rectangular view window in the view plane is used to the same effect. Edges of the view window are parallel to the xv-yv axes and window boundary positions are specified in viewing coordinates.
View VolumesView Volumes
![Page 53: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/53.jpg)
View VolumesView Volumes
zv
window
Front Plane
Back Plane
View volume
Parallel ProjectionParallel Projection Perspective Projection
Front Plane
Back Plane
View volume (frustum)
window
Projection Reference Point
![Page 54: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/54.jpg)
ClippingClipping
• An algorithm for 3D clipping identifies and saves all surface segments within the view volume for display.
• All parts of object that are outside the view volume are discarded.
![Page 55: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/55.jpg)
Clipping LinesClipping Lines
• To clip a line against the view volume, we need to test the relative position of the line using the view volume’s boundary plane equation.
• An end point (x,y,z) of a line segment is outside a boundary plane if
where A, B, C and D are the plane parameters for that boundary.
0 DCzByAx
![Page 56: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/56.jpg)
Clipping Polygon SurfaceClipping Polygon Surface
• To clip a polygon surface, we can clip the individual polygon edges.
• First we test the coordinate extends against each boundary of the view volume to determine whether the object is completely inside or completely outside of that boundary.
• If the object has intersection with the boundary then we apply intersection calculations.
![Page 57: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/57.jpg)
Clipping Polygon SurfaceClipping Polygon Surface
• The projection operation can take place before the view- volume clipping or after clipping.
• All objects within the view volume map to the interior of the specified projection window.
• The last step is to transform the window contents to a 2D view port.
![Page 58: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/58.jpg)
Clipping Polygon SurfaceClipping Polygon Surface
Viev volume
![Page 59: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/59.jpg)
Steps For Normalized View Volumes Steps For Normalized View Volumes
• A scene is constructed by transforming object descriptions from modeling coordinates to wc.
• The world descriptions are converted to viewing coordinates.
• The viewing coordinates are transformed to projection coordinates which effectively converts the view volume into a rectangular parallelepiped.
• The parallelepiped is mapped into the unit cube called normalized projection coordinate system.
• A 3D viewport within the unit cube is constructed.• Normalized projection coordinates are converted to
device coordinates for display.
![Page 60: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/60.jpg)
Normalized View Volumes Normalized View Volumes
x
y
z
(Xwmin, ywmin, zfront)
(Xwmax, ywmax, zback)
(Xvmin, yvmin, zwmin)
(Xvmax, yvmax, zvmax)
Unit Cube
Parallelepiped
View Volume
![Page 61: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/61.jpg)
10002
200
20
20
200
2
)2
,2
,2
(
)2
,2
,2
(
minmax
minmax
minmax
minmax
minmax
minmax
minmaxminmaxminmax
minmaxminmaxminmax
zz
zz
yy
yy
xx
xx
zzyyxx
zzyyxx
TSP
S
T
OrthoOrthogonalgonal Projection Normalization Projection Normalization
![Page 62: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/62.jpg)
Oblique ProjectionOblique Projection Normalization Normalization
• Angles of projection for x axis for y axis
• Shearing matrix H(, )
0
cot
cot
tan
p
p
p
p
z
zyy
zxx
xx
z
1000
0100
0cot10
0cot01
),(
H
![Page 63: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/63.jpg)
Oblique ProjectionOblique Projection Normalization Normalization
1000
0100
0cot10
0cot01
1000
0000
0010
0001
),(orth
HPP
Finished ? No, this is a sheared view volume, so we have to apply orthogonal transformation :
P=Porth STH
![Page 64: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/64.jpg)
PerspPerspectiveective Projection Normalization Projection Normalization
Perspective Normalization is Trickier
![Page 65: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/65.jpg)
Perspective Projection NormalizationPerspective Projection Normalization
Consider N =
After multiplying:
p’ = Np
0100
00
0010
0001
![Page 66: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/66.jpg)
Perspective Projection NormalizationPerspective Projection Normalization
After dividing by w’, p’ -> p’’
![Page 67: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/67.jpg)
Perspective Projection NormalizationPerspective Projection Normalization
Quick Check• If x = z
– x’’ = -1• If x = -z
– x’’ = 1
• If x = z– x’’ = -1
• If x = -z– x’’ = 1
![Page 68: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/68.jpg)
Perspective Projection NormalizationPerspective Projection Normalization
What about z?
• if z = zmax
• if z = zmin
• Solve for and such that zmin -> -1 and zmax ->1• Resulting z’’ is nonlinear, but preserves ordering of
points– If z1 < z2 … z’’1 < z’’2
![Page 69: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/69.jpg)
Perspective Projection NormalizationPerspective Projection Normalization
We did it. Using matrix, N• Perspective viewing frustum transformed to cube• Orthographic rendering of cube produces same
image as perspective rendering of original frustum
![Page 70: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/70.jpg)
OpenGL Projection CommandsOpenGL Projection Commands
![Page 71: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/71.jpg)
OpenGL OpenGL Look-At FunctionLook-At Function
• OpenGL utility function
– VRP: eyePoint (eyex, eyey, eyez)
– VPN: – ( atPoint – eyePoint ) (atx, aty, atz) – (eyex, eyey, eyez)
– VUP: upPoint – eyePoint (upx, upy, upz)
gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);
look-at positioning
![Page 72: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/72.jpg)
Projections in OpenGLProjections in OpenGL
• Angle of view, field of view :– Only objects that fit within
the angle of view of the camera appear in the image
• View volume, view frustum :– Be clipped out of scene– Frustum – truncated
pyramid
![Page 73: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/73.jpg)
Projections in OpenGLProjections in OpenGL
![Page 74: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/74.jpg)
Perspective in OpenGLPerspective in OpenGL
Specification of a frustum
– near, far: positive number !!
zmax = – far
zmin = – near
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glFrustum(xmin, xmax, ymin, ymax, near, far);
![Page 75: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/75.jpg)
Perspective in OpenGLPerspective in OpenGL
Specification using the field of view
– fov: angle between top and
bottom planes– fovy: the angle of view in the
up (y) direction– aspect ratio: width / height
glMatrixMode(GL_PROJECTION);glLoadIdentity( );gluPerspective(fovy, aspect, near, far);
![Page 76: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/76.jpg)
Parallel Parallel Viewing Viewing in OpenGLin OpenGL
Orthographic viewing function
– OpenGL provides only this parallel-viewing function
– near < far !!
no restriction on the sign
zmax = – far
zmin = – near
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glOrtho(xmin, xmax, ymin, ymax, near, far);
![Page 77: UBI 516 Advanced Computer Graphics Three Dimensional Viewing Aydın Öztürk ozturk@ube.ege.edu.tr ozturk](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649e7a5503460f94b7adf9/html5/thumbnails/77.jpg)
Optional Clipping PlanesOptional Clipping Planes
– glClipPlane(id, PlaneParameters);glEnable(id);
// id = GL_CLIP_PLANE0,
GL_CLIP_PLANE1, ...// PlaneParameters = A,B,C and D of the
plane
. . .
glDisable(id);