Triangle - Rectangle Intersection in 2D
- by Kevin Boyd
I had previously asked this for 3D but now I changed my strategy and would like to do the intersection in 2D.
The Rectangle is axis aligned and will always be in a fixed position, and has a constant shape and size, basically I want to clip the red areas of the triangles that extend outside the bounds of the rectangle
The triangles could be in any position, shape or size, I my code I have a loop where I check the triangles one by one however I am still clueless about the math.
I have identified 5 cases of triangle rectangle intersection as shown here.
How do I find the intersection points of the triangle and the rectangle?