To compute all the red pixels, the naive algorithm is to just test each pixel (on screen) for whether it is inside the triangle or not. A slight optimization on this is to use the bounding box of the triangle and test only pixels in that box (like we did for circles in assignment 2). However, in case of triangles, we can have a triangle covering very few pixels and yet its bounding box might be the entire screen.

point in triangle test animation

To compute all the red pixels, the naive algorithm is to just test each pixel (on screen) for whether it is inside the triangle or not. A slight optimization on this is to use the bounding box of the triangle and test only pixels in that box (like we did for circles in assignment 2). However, in case of triangles, we can have a triangle covering very few pixels and yet its bounding box might be the entire screen.