# Algorithm Singularity computer graphics

• A variable yprev is used to keep track of the previous intersection of the edge. Whenever an intersection is found, not only is a new pair of (x,y) stored as in the yx algorithm, but the y coordinate is stored to indicate the previous intersection by storing it in yprev. Initially its value is set to 0.
• Go to the next edge of the polygon. If these are no more edges to be processed, exit.
• Compute it’s intersection with the scan lines. If it has no intersections at all (or a very large no. of intersections, the way you look at it) it can be considered horizontal. Go to step 2
• Compute the difference dy=y2-y1, where y2 is the y coordinate of the beginning vertex of the edge and y1 the y coordinate of the ending vertex. If dy>o go to step5, else go to step6.
• If dy>0, the first intersection generated must have y= yprev.+1 compute all other intersections of the edge. The y coordinate of the last intersection is stored in yprev. . Go to step 2 to findout whether any edges are still there.
• If dy < o, the first intersection generated will have y= yprev. itself generate all intersections for the edge. The y coordinate of the last intersection is preserved in yprev. = ylast -1. Go to step2.