Docsity

Line Clipping Algorithms: Restricting Graphics Primitives to a Sub-region of the Canvas, Slides of Computer Graphics

Partial preview of the text

Download Line Clipping Algorithms: Restricting Graphics Primitives to a Sub-region of the Canvas and more Slides Computer Graphics in PDF only on Docsity!

Computer

Graphics

Lecture 14

CLIPPING I

All primitives are clipped to the boundaries of this clipping rectangle;

Primitives lying outside the clip rectangle are not drawn.

The default clipping rectangle is the full canvas (the screen); We cannot see any graphics primitives outside the screen

Clipping of lines against rectangles

Line Clipping

Simpler problem

Xmin < X < Xmax And Ymin < Y < Ymax

Clipping

Individual Points

Trivial Reject โ€“

discard a line with both endpoints outside the clipping boundaries

For all other lines โ€“

compute intersections of line with clipping boundaries

If 0 <= u <= 1 then the line does enter the interior of the window at that boundary

otherwise, the line does not enter the interior of the window at that boundary.

Need to consider only endpoints of a line:

If both endpoints lie inside the clip rectangle; it can be trivially accepted.

Solve Simultaneous

Equations

If both endpoints are outside the clip rectangle, we need to perform further calculations to determine whether there are any intersections.

Intersect that line with each of the four clip rectangle edges. if so, the line cuts the clip rectangle and is partially inside.

The Brute Force

Approach