Can I do these with poly2tri ?

115 views
Skip to first unread message

Civil

unread,
May 3, 2014, 2:32:39 PM5/3/14
to poly...@googlegroups.com
Hello :
I'd like to know if poly2tri could perfrom the next requirements : 
- Add forced edges (That is, a hard line that can't be crossed by any triangle edge)
- Any way to keep an 'id' or something similar ?
- Any way to do spatial search ? That is: is there any point near x,y location ?
- Any way to do dynamic insertions - deletions ?

Maybe the triangle data has infomation that I could use to get what I want ?
( Is there any document explain how the data is stored & organized  ? )
(  What spatial approach poly2tri uses ? BSP ? Quadtree? )




Thanks,


obi

unread,
May 4, 2014, 7:44:19 AM5/4/14
to poly...@googlegroups.com
I'm sorry poly2tri isn't that powerful it just a simple polygon triangulator.

All it works with is really just a bunch of points and some forced edges(constraints) and do a triangulation.
poly2tri assume that the points/edges form a simple polygon with possible holes and internal points and just keep the triangles that is considered inside.

You could always extend the point class and add your own id if you want to keep track of points after the triangulation.

In the default library there are no support for spatial searches or dynamic retriangulations. It was something I had on a to do list back when we released poly2tri.
But I started working on other things and now that poly2tri has been translated to so many languages any changes and additions will most likely not propagate to the other languages.

I guess the spatial search you might want to do is to find a triangle given a coordinate, there is an algorithm that can do this in O(log(n)).
I think I implemented an easy algorithm that is O(sqrt(n)) to traverse the triangulation to find a triangle, might have the code(Java) somewhere if interested.

If you just want to find a point close to a x,y position I suggest you use a k-d tree.
Reply all
Reply to author
Forward
0 new messages