Search code examples
algorithmmathgeometrycomputational-geometry

calculate intersection area of two triangle


I have been trying to find an algorithm which computes the intersecting area of two triangles but I failed to find any. Can anybody give a clue how to write this algorithm?

I would like something like:

  double getAreaOfIntersection(Vector2 p1,Vector2 p2, Vector2 p3,Vector2 p4,Vector2 p5,Vector2 p6 )

where pX represents the 2 triangles.


Solution

  • You could first compute the polygon which describes the intersection area by a clipping algorithm, e.g.:

    Sutherland-Hodgman algorithm

    Then you would compute the area of the resulting convex polygon, which is rather easy, see, e.g., here:

    Area of a Convex Polygon