When I look at polyfill algorithm tutorials/articles or examples, nothing mentioned about how to handle horizontal lines. Does anyone have any idea how horizontal lines should be handled?
For instance, consider the following image:
For intersection I wrote if the line on the scan line count it as 1 point, even I count as 2 point or no point, wont help. Any idea how should I handle the horizontal line?
Alright, if we take a look at next point and previous point of the intersection of both end of horizontal line, if those point are in same side, means I can count them in or out, doesn't effect the whole calculation.
But if they are are opposite side, I have to count them in and count one side extra.
What do I mean?
Take InterS1 and InterS2 as an example, so when I get this I have count that horizontal line as 3 points:
point1 = InterS1 point2 = InterS2 point3 = InterS2
Why I need to do that?
- When next point and previous point are in different direction, is letting us know that our intersection line crossing outside and passing through inside of shape.
- Also because line can be created when there is start point and end point, so I need to have even number to draw lines.
So now I have no idea base on what I need to add the extra point to one side.
Do I make sense?