[PD] Calculating Triangles Inside A Polygon

Tyler Leavitt thecryoflove at gmail.com
Thu Feb 10 02:08:59 CET 2011


Thanks much! It seems so obvious now that you pointed it out... anyways,
thanks again!

Tyler

On Wed, Feb 9, 2011 at 3:47 PM, Mathieu Bouchard <matju at artengine.ca> wrote:

> On Wed, 9 Feb 2011, Tyler Leavitt wrote:
>
>  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.
>>
>
> You replied in private. (why ?)
>
> 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_intersectionwhich 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20110209/0e9dfece/attachment-0001.htm>


More information about the Pd-list mailing list