My lab partner is Dan Nelson.
In this project, we create a polygon structure and some supporting functions in order to work with polygons in our graphic system. Also, we implement the scanline fill algorithm for polygons and Barycentric coordinate algorithm to fill 3-point polygons.
Explanations of Algorithms
Scanline fill algorithm
The basic concept of the algorithm is simple: For each scanline, we intersect it with all the edges of the polygon. Then we sort the edges left to right and fill between the edge pairs
The following picture demonstrates how scanline fill algorithm works visually. In the picture, the three red, yellow and white polygons are consecutively filled.
Barycentric fill algorithm
This fill algorithm is designed specifically for polygons that are made up of 3 points. The algorithm is based on a mathematical characteristic of triangles which determine whether a point is inside the triangle or not. The concept is simple but it is extremely useful in the interpolation based on the three corners of the triangle. Also, in 3D graphics, 3D surfaces are made up of triangles so this fill algorithm will become handy.
Filling with transparency
We implement an extension to do scanline fill with some degree of transparency. The concept is based on alpha blending the current object with the given background.
Required picture 1
Required picture 2
Required picture 3
Look at the axels!
We learned a lot about how fill algorithms work, which is an essential part of a graphic system.