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

3D possible? #4

Open
sweco-sekrsv opened this issue Nov 14, 2019 · 1 comment
Open

3D possible? #4

sweco-sekrsv opened this issue Nov 14, 2019 · 1 comment

Comments

@sweco-sekrsv
Copy link

Hi!
Is it possible to add a third dimension to the function?(z height)
Something like:
polygon = [(0,1,2), (-1, 0, 2.5), (0, -1, 2.5), (1, 0, 2)]

I tried it but get the error:
triangles = tripy.earclip(polygon)

 File "C:\Users\SEKRSV\AppData\Local\Programs\Python\Python36\lib\site-packages\tripy.py", line 30, in earclip
    polygon = [Point(*point) for point in polygon]
  File "C:\Users\SEKRSV\AppData\Local\Programs\Python\Python36\lib\site-packages\tripy.py", line 30, in <listcomp>
    polygon = [Point(*point) for point in polygon]
TypeError: __new__() takes 3 positional arguments but 4 were given
@MartinFalatic
Copy link
Collaborator

The problem in 3D space is quite a bit more complicated than on a single plane. While technically one can calculate the area of a triangle in 3D space with nearly as much ease as 2D, the surface itself depends on the points chosen. At a first glance I think this would be far more complicated than this library would provide.

However, for this class of problem in 3D you might want to look into Delaunay triangulation:

https://www.youtube.com/watch?v=63MM0EqXlT0

See also SciPy's implementation:

https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.Delaunay.html

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