-
Notifications
You must be signed in to change notification settings - Fork 2
How the convexFillCells algorithm works
Griswald Brooks edited this page Sep 24, 2020
·
9 revisions
This algorithm is confusing, so I looked at the code and tried to figure it out. This is how it does it:
Assumptions:
- The size_x input parameter is a big number so don't worry about it.
- The polygon input parameter are the vertices of the polygon to fill.
- The produced outline is a convex hull
Steps:
- If the polygon parameter has less than 3 elements, return an empty vector.
- Create the outline from the input polygon vertices using the polygonOutlineCells function.

- Sort the outline vector by the x coordinate value, from least to greatest.

- Start from the beginning of the outline vector, for every x value, find the Cell with biggest and smallest y value

- For each x value, push back a Cell into the output vector from the smallest y value to the biggest y value

At the end the output vector should have every cell that was inside the outline, because it went column by column to find the extrema of the y value for that column.