[PD] Calculating Triangles Inside A Polygon
Hello all, I have an idea for an object that controls parameters based off of the area of triangles inside a polygon (I was thinking volume of different harmonics for a synth, but it could be anything). I don't even know if this is mathematically possible, and I've done enough Googling to where I'm beginning to think that it is not. But perhaps I just don't know how to correctly phrase what I'm searching for... Can anyone shed some light on this? The idea is to drag the vertices of the polygon to change the shape, and consequentially the masses of triangles inside. I've attached a PNG of what I'm trying to describe as far as the triangles made by intersecting lines. If you know what I'm going for but don't want to explain it to me, perhaps you could point me in a direction, or give me the correct term to describe this. I'm still willing to continue devoting lots of time to Googling/research =) Tyler (And in this example with the pentagon there would be 10 different triangles... didn't mean to label the pentagon). attachment: pp.png___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Calculating Triangles Inside A Polygon
On Wed, 9 Feb 2011, Tyler Leavitt wrote: I have an idea for an object that controls parameters based off of the area of triangles inside a polygon (I was thinking volume of different harmonics for a synth, but it could be anything). I don't even know if this is mathematically possible, and I've done enough Googling to where I'm beginning to think that it is not. But perhaps I just don't know how to correctly phrase what I'm searching for... What happens when the polygon is concave ? Is this allowed ? ___ | Mathieu Bouchard tél: +1.514.383.3801 Villeray, Montréal, QC___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Calculating Triangles Inside A Polygon
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 ma...@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 ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list