CS488
Polygon Clipping and Circles
Luc RENAMBOT
1
CS488 Polygon Clipping and Circles Luc R ENAMBOT 1 Previous - - PowerPoint PPT Presentation
CS488 Polygon Clipping and Circles Luc R ENAMBOT 1 Previous Lectures Frame buffers Drawing a line (Midpoint Line Algorithm) Polygon Filling (Edge-table algorithm) Line Clipping (Cohen-Sutherland algorithm) Polygon Clipping
Luc RENAMBOT
1
2
3
3
3
4
start a) b) d) c)
Right clip boundary Left clip boundary Top clip boundary Bottom clip boundary Clipping rectangle
6
window: add the second inside vertex point
the intersection point as a vertex
window: add nothing
save the intersection and inside points as vertices
7
1 2 3 4
V = Vn, V1, V2, ... Vn given an edge from vertex s to vertex p assume s has already been dealt with
intersection of edge sp with the clip edge)
intersection of edge sp with the clip edge) and then p
8
sequence 9
The new vertex sequence is then checked against the Ymin edge and so on through the Xmax edge and the Xmin edge
Clipping on Ymax edge 1 2 3’ 3 4 5’ 5 6 7’ 8 9’
Xmin Xmax Ymin
7
Ymax
9
10
11
12
13
(x,y) (y,x) (x,-y) (-x,-y) (-y,-x) (-y,x) (-x,y) (y,-x)
from x=0 (y-axis) to x = y = R/sqrt(2) (45 degrees clockwise from the y-axis.)
equation and
14
15
function evaluated at the midpoint d = F(Xp + 1,Yp - 0.5)
and see where the midpoint falls in relation to the circle.
pick SOUTHEAST pixel
16
17
Previous Current
18
19
20
21
22
X = 0; Y = radius; d = 1 - radius; draw8Points(X, Y); while(Y > X) if (d< 0) add 2 * X + 3 to d add 1 to X else add 2 * (X-Y) + 5 to d add 1 to X subtract 1 from Y draw8Points(X, Y);
23
The full algorithm is given (in C) in the white book as figure 3.16 on p.86.
24
24
24
multiplication to compute the new value of the decision variable. The book shows a more complicated algorithm which does this multiplication only once
handled in a similar manner, except that 1/4 of the ellipse must be dealt with at a time and that 1/4 must be broken into 2 parts based on where the slope of the tangent to the ellipse is -1 (in first quadrant)
25
26
the contents of the frame buffer. Now we are going to go up a level of abstraction and look at how geometric transformations are used to alter the view of a 2D model: how we can translate, scale, and rotate the model, and how transformations affect what the viewport 'sees' →Geometric Transformations
which reviews matrices and vectors, before coming to next
should prepare you for the coming of matrices
27