Thanks much! It seems so obvious now that you pointed it out... anyways, thanks again!
On Wed, 9 Feb 2011, Tyler Leavitt wrote:
You replied in private. (why ?)At the moment, no, this isn't allowed =) I had thought of that, and then with all the difficulty I've had without taking this into account, I'd figured one step at a time.
Anyway, I reply back to the list.
suppose you have 4 points a,b,c,d with polygon edges ab, bc, cd. They have diagonals ac, bd. They form triangles abc and bcd that intersect. The intersection is bce where e is the single point at the intersection of ac and bd.
e is a + p*(c-a) where p is some number between 0 and 1, which is the fraction of the travel from a that you have to do to reach e, when going in a straight line towards c.
e is also b + q*(d-b).
e = a + p*(c-a) = b + q*(d-b).
I don't quite remember how to continue the reasoning from there.
However I found this out http://en.wikipedia.org/wiki/Line_intersection which I can translate to :
e = (det(a,c)*(b-d) - det(b,d)*(a-c)) / det(a-c,b-d)
after that, it's easy, as the area of the bce triangle is det(b-e,c-e)/2, as you'd do for any triangle. This part can be computed using this abstraction : http://gridflow.ca/help/%23polygon_area-help.html
With your example, you have to do the above calculation 5 times on different combinations of points, to get 5 different inner points and 5 different areas. Then you combine the inner points to get the areas of 5 more triangle. Area #1, in the middle, is not a triangle, but you can compute its area with [#polygon_area] anyway.
_______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC