For some time now I've set myself a goal I've yet to reach. For the first time I feel I've found a proper place to ask for help.(adsbygoogle = window.adsbygoogle || []).push({});

I'm trying to devise a closed formula for the area of overlap of 2 arbitrary triangles from the known 6 vertexes' values. Naturally, inside the plane. In attempting to do so I thought it appropriate first to come up with one for the special case of 2 right-angle, axis aligned triangles. By axis aligned I mean that both catheti are parallel either to the abscissa or the ordinate.

Having solved this I would then attempt to come up with something for 2 arbitrary triangles. Actually, I see that as the easy part.

http://img213.imageshack.us/img213/7233/triunghi7li.gif [Broken]

The way I propose to solve it is based on a supposed solution for the special case. As you can see in the graphic, I treat the area of arbitrary triangles as being made up of the areas of 5 right-angle, axis aligned triangles. This is proven to work for any arbitrary triangle, and I've tested it. The area determinant of the original arbitrary triangle is equivalent to the sum of the area determinants of triangles green, blue, yellow, cyan minus the area determinant of the hollow, red outlined triangle. As you can see, all 5 are right-angle, axis aligned triangles.

The area of overlap between 2 arbitrary triangles would mean adding up 16 areas of overlap between 4 and 4 triangles and subtracting 8 areas of overlap between 4 and 1 and 1 and 4 triangles.

On the special case. So far, I've thought of a bounding box. It's a rectangle, axis aligned. The segment common to both triangle's projections on the abscissa constitutes the boxes horizontal bound. Analogue for the vertical bound.

Whatever area of overlap there may be between the 2 right-angle triangles, it can only manifest inside this bounding box, if at all. Upon this known fact I've attempted various developments and embellishments towards said goal, by trial and error. But mostly error.

Among the knowns or easily findable are the bounding box's area, the intersection points between the catheti and the respectively perpendicular sides of the bounding box, the intersection points between the hypothenuses and the bounding box's sides, the amount of area either of the 2 triangles has inside the bounding box, etc.

Though calculating the intersection points would result in divisions by 0 [edit]for colinear triangles (of area = 0)[/edit] I find this is perfectly normal and appropriate, no reason to consider a solution based on these as inadequate because of the fringe cases (it's akin to calculating the intersection of 2 lines, the coordinates formulas are not invalidated because they yield div by 0 in the case of parallel lines). Hypothenuses intersection calculation, however, is an entirely different matter and though I may be wrong I can not view as no adequate any solution based on this.

I can also tell bereft of outside intervention which one of the three vertexes of either of the 2 triangles is its right-angled tip, its vertical side's tip, or the horizontal side's tip.

Also, the length of the segment common to any 2 segments, the endpoints of that segment, etc. All these using abs() so as not to introduce break/decision points in the process, especially the part concerned with creating the bounding box, thereby keeping a closed formula within the realm of feasibility.

I would very much appreciate any help or insight you endeavour to contribute on the problem. I've sprung this conundrum on many innocent people over the time, to no avail. I've asked on lots of math/computer/science forums unsuccessfully as well. For all I know, it may very well be impossible to solve. Nevertheless, each time I ask, it is with renewed hope. And this time I really think I'll find some pertinent help.

Regards.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Right angle triangles area of overlap calculation.

**Physics Forums | Science Articles, Homework Help, Discussion**