Write a program that draws a triangle in the center of the screen. The triangle should have an apex at (0.5, 0.75)
in normalized device coordinates, and an apex angle of 120
degrees. The height of the triangle should be 0.5
times the height of the screen.
First, we can shoot a ray h from the apex perpendicular to the base of the triangle. This h vector divides the top corner of the triange into two 60-degree parts.
If we take the dot product of the height vector h and the vector from apex to the triangle bottom vertex, we get a value equal to the cosine of 60 degrees.
Think what happens to the value of the dot product when the fragment fits into a triangle and when it doesn't.