Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangulate polygons? #18

Closed
bertt opened this issue Aug 6, 2019 · 4 comments
Closed

Triangulate polygons? #18

bertt opened this issue Aug 6, 2019 · 4 comments

Comments

@bertt
Copy link
Contributor

bertt commented Aug 6, 2019

Can this library triangulate polygons (as list of vertex(x,y,z)) too? Or is there a method like primitive.AddPolygon?

If not, is there a recommended library to do triangulation?

@vpenades
Copy link
Owner

vpenades commented Aug 6, 2019

No, the library only supports points, lines and triangles.

If your polygons are convex, you can just iterate over the vertices; the test library already has that code: ToolkitUtils.cs

For non contex polygons, or polygons with holes etc, more exotic algorythms are required. The most commonly used algorythm I know is the ear clipping algorythm, although most implementations you'll find around only work in 2D Space.

Finding a good, general purpose polygon triangulation algorythm that works in 3D Space is quite difficult, I actually expent some time trying to implement it, but it was taking too much time, and I finally considered it to be beyond the scope of the library.

Let me know if you find something useful, I'm interested too!

@bertt
Copy link
Contributor Author

bertt commented Aug 6, 2019

ok thanks for clearing up, I'll try first the convex way.

@bertt bertt closed this as completed Aug 6, 2019
@bertt
Copy link
Contributor Author

bertt commented Aug 6, 2019

update: I think I'll be using ST_DelaunayTriangles function from PostGIS (https://postgis.net/docs/ST_DelaunayTriangles.html), adds a database dependency but thats no problem in my case.

@vpenades
Copy link
Owner

vpenades commented Aug 6, 2019

That's another reason why I didn't implement a polygon triangulator, there's more than one algorithm, and there's no algorithm that fits all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants