











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Homogeneous Coordinates
A way of representing data
Representing n−d space by n+1 dimensions
for example,
16bit word for an integer between −32768 and 32767
How to represent a number > 32767?
a position [ 60000, y, z ]
homogeneous coordindates:
[ 30000, y/2, z/2, 1/2 ]
Homogeneous Coordinates (cont’d)
− distinguish between a vector and a point
− modify the position of the origin of the coordinate system
there is no room in the 3x3 matrix to specify translation!
3x
x 1
1x3 1x
linear transformation (^) translation
perspective transformation
overall scaling
(rotation, scaling, reflection, shearing, ...)
− there is no unique homegeneous coordinate representation! −
h
h = 0?
View Volume
back clip plane
front clip plane
view plane window
(View Frustum)
front clip plane back clip plane
view plane
COP (^) h
Perspective Projection
− foreshortening
− line width is not preserved, so are angles
− irreversible
What happens if we move COP to infinitely far away?
Expressed in Homogeneous Coordindates
X/w Y/w Z/w w/w
xs ys zs 1
xs =
d zv
xv ys^ =^
d zv
yv
X xv Y yv Z zv w 1
0 0 1/d 0
where M =
X x v Y yv Z zv w zv/d
that is, =
after perspective divide
xv/w yv/w d 1
0 0 1/d 0
For parallel projection:
For perspective projection:
x s = x v ys = y v zs = 0 (with projection plan at z=0)
P’ = M proj Mview P
An overall transformatin from World to Screen space can be expressed as:
model−view maxtrix
projection matrix
perspective division
viewport transformation
Vertices
Stages of Vertex Transformation
view coordinates
clip coordinates
normalized device coordinates
window coordinates
Clipping
Point Clipping
xmin < x < xmax ymin < y < ymax
(xmin, ymin)
(xmax,ymax)
Otherwise, do not draw the point
Line Clipping
Brute Force Line Clipping
Compute intersections of line with every window boundary −> expensive
clip window
A
C
B D
E
Code(P0)&Code(P1) = 0
Code(P0) = Code(P1) = 0
Cohen−Sutherland Algorithm (cont’d)
Algorithm:
− Test for trivial reject or accept (exit?)
− If ( code(P0)!=0 and code(P1)=0 )
One point is inside and the other is outside. The line must be shortened. One or two intersections must be computed. else if ( code(P0)&code(P1)=0 )
Both endpoints are outside. Intersect with one of the sides of the window, and check the code of the resulting point
p 1 = −dx, q 1 = x1 − xmin p 2 = dx, q 2 = x max − x 1 p 3 = −dy, q 3 = y1 − ymin p 4 = dy, q 4 = y max − y 1
Liang−Barsky Line Clipping (cont’d)
pk = 0
q k < 0 the line is completely outside the boundary
the line is parallel to one of the clipping boundaries
q1< p 1=
q 2> p 4>
pk > 0
q k > 0 the line is inside the parallel clipping boundary
the line proceeds from the inside to the outside
Sutherland−Hodgeman Polygon Clipping
− clip the polygon to each of the window boundaries in succession − edge and vertex defintions of the polygon are updated accordingly
Polygon Clipping
The output of a polygon clipper should be a sequence of vertices that defines the clipped polygon boundaries
Concave case:
clipped
tessellation