I am working on a small software renderer, and I want to discard invisible triangles from the drawing process. Let's say I have a screen with resolution of 200x100 pixels. The triangle is defined with three 2-dimensional coordinates {x, y} in the screen space.

What is the fastest possible way to get a yes/no answer for the question "Should my triangle be drawn?", I don't need to retrieve intersection coordinates, just a boolean answer.

Note: on the image below all four red triangles need to be drawn even though some of their vertices aren't on the screen.



1 Answer 1


There are three kinds of positional relationship between two plane figures: disjoint, one inside the other, partial intersection. You need to check for partial intersection and one inside the other.

  1. One inside the other. It means one's vertices are all in the other.



enter image description here

In fact, the check can be ended if at least one point is inside the target graph, since it covers the case of partial intersection.

enter image description here

  1. Partial intersection. It means that two graphs have at least two edges that intersect.


enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .