Computer Graphics Assignment Solutions
Computer Graphics Assignment Solutions
Solutions
Q1. Complete Algorithm for Polygon Scan Line Region Filling Algorithm:
The Polygon Scan Line algorithm is used to fill polygons by setting pixels between the edges
of the polygon on a scan line-by-scan line basis. Here’s the complete algorithm:
1. Find the Y-min and Y-max of the polygon.
2. Sort edges in increasing order of Y-coordinate.
3. For each scan line from Y-min to Y-max:
a. Find the intersections of the scan line with the polygon edges.
b. Sort these intersections by X-coordinate.
c. Fill pixels between pairs of intersections.
d. Repeat this for every scan line.
2. Liang-Barsky Algorithm:
- Based on parametric equations of the line.
- Efficient and reduces the number of intersection calculations compared to Cohen-
Sutherland.
- Clipping is done using inequalities derived from the parametric equations.
1. Liang-Barsky: Uses the parametric equations of the line and clips based on the
boundaries of the polygon.
2. Nicholl-Lee-Nicholl: Particularly efficient for certain lines, minimizing intersections with
the polygon sides by categorizing the line's position relative to the polygon.