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

Bug: Triangualte with 'a' and small values <10 ** -4 #26

Closed
icemtel opened this issue Jun 25, 2018 · 4 comments
Closed

Bug: Triangualte with 'a' and small values <10 ** -4 #26

icemtel opened this issue Jun 25, 2018 · 4 comments

Comments

@icemtel
Copy link
Contributor

icemtel commented Jun 25, 2018

I don't think this will be fixed any time soon, the source of the problem is probably in C code. But I want to make others aware of this problem.
Using triangulate with parameter 'aX' (which sets a restriction on maximum triangle area) with X - a number <10**-4, the Triangle will fully ignore this argument, and maximum triangle area will be unrestricted.

This is quite unexpected, because this means that algorithm will already have problems with triangles of linear size 10**-3-10**-2, which is not that small.

import scipy as sp
import triangle

boundary_points = sp.array([[-1, -1], [1, -1], [1, 1], [-1, 1]])

max_areas = [10 ** -5, 9 * 10 ** -5, 10 ** -4, 1.1 * 10 ** - 4, 10 ** -2 ]

print('Max area   Num of triangles')
for max_area in max_areas:
    tri_data = {'vertices': boundary_points}
    code = 'a{0}'.format(max_area)
    tri = triangle.triangulate(tri_data, code)

    coords = tri['vertices']
    trias = tri['triangles']

    print('{:.2e}   '.format(max_area), len(trias))

For me this prints

Max area   Num of triangles
1.00e-05    4
9.00e-05    2
1.00e-04    62223
1.10e-04    56758
1.00e-02    628

I could reproduce this problem with circular geometry and for objects of different size, also with additional code 'q' the problem remains.

@icemtel
Copy link
Contributor Author

icemtel commented Jun 25, 2018

UPD: in wo80/Triangle#37 C code of Triangle 1.6 was checked and it works fine. The python bindings use the same version, so the problem has to be with python library.

@icemtel
Copy link
Contributor Author

icemtel commented Jun 26, 2018

code = 'a{0}'.format(max_area)

has to be replaced with

code = 'a{0:.31f}'.format(max_area)

for correct formatting. Otherwise any value below 10 ** -4 will be written in the exponential form.

@icemtel icemtel closed this as completed Jun 26, 2018
@drufat
Copy link
Owner

drufat commented Jun 26, 2018

I have not updated the version of the triangle C library that the python bindings use. If the problem has been fixed recently, these bindings still use the older version of the code. Maybe it would be a good idea to upgrade to the latest version when I have more time.

@icemtel
Copy link
Contributor Author

icemtel commented Jun 27, 2018

The problem was on my side, but some updates where made in C code indeed.
See wo80/Triangle#37 (comment) and wo80/Triangle#37 (comment)

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