Initialization
Keep track of the numbers of the vertices on the left and on the right:
int left_edge_end = bottom_index;
int right_edge_end= bottom_index;
This is the first row of a tile:
int bottom_row = ceil(v[bottom_index].y);
These are used to store the candidates for the top row of a tile:
int left_top_row = bottom_row;
int right_top_row = bottom_row;
Keep track of the intersections of left and right edges of a tile with horizontal integer lines:
float left_pos, right_pos, left_step, right_step;
Number of remaining vertices:
A couple of auxilary variables: int edge_start; int row;