hakanseven12 / delaunator-python Goto Github PK
View Code? Open in Web Editor NEWFast Delaunay triangulation of 2D points implemented in Python.
License: GNU Lesser General Public License v2.1
Fast Delaunay triangulation of 2D points implemented in Python.
License: GNU Lesser General Public License v2.1
Delaunator.py:276: SyntaxWarning: invalid escape sequence '\ '
apparently it doesn't like the comment in _legalize
So, like others, I've been experiencing a divide by zero error in the circumradius
function; however, it's not due to duplicate points.
My error is due to a set of three points that are in a straight line with each other.
The points in particular that are causing my error are: (137, 525)
, (137, 509)
, and (137, 392)
.
I get a divide by zero error if I run the below:
Python 3.9.2 (default, Feb 24 2021, 13:30:36)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> from Delaunator import Delaunator
>>> points = np.random.randint(1,1677.7215,size=(10000,2))
>>> triangles = Delaunator(points).triangles
/Users/jamie/Downloads/Delaunator.py:427: RuntimeWarning: divide by zero encountered in true_divide
d = 0.5/(dx * ey - dy * ex)
Am I doing something wrong?
Hi,
When I run the starter code, I get a divide by zero error:
from Delaunator import Delaunator
points = [[168, 180], [168, 178], [168, 179], [168, 181], [168, 23], [168, 23]]
triangles = Delaunator(points).triangles
print(triangles)
and the output is:
aryamansharda@Aryamans-MacBook-Pro Delaunay % python3 LowPolygonArt.py
Traceback (most recent call last):
File "LowPolygonArt.py", line 19, in <module>
triangles = Delaunator(points).triangles
File "/Users/aryamansharda/Downloads/Delaunay/Delaunator.py", line 19, in __init__
triangles = self.constructor(coords)
File "/Users/aryamansharda/Downloads/Delaunay/Delaunator.py", line 41, in constructor
triangles = self.update(coords)
File "/Users/aryamansharda/Downloads/Delaunay/Delaunator.py", line 100, in update
r = circumradius(i0x, i0y, i1x, i1y, coords[2 * i], coords[2 * i + 1])
File "/Users/aryamansharda/Downloads/Delaunay/Delaunator.py", line 427, in circumradius
d = 0.5/(dx * ey - dy * ex)
ZeroDivisionError: float division by zero
Hi, is there a way to use this python implementation to voronoi neighbors that exclude pairs that do not have a common edge, akin to this solution https://observablehq.com/@d3/voronoi-neighbors from d3-delanauy in javascript?
Hey all, Thanks for the useful program! Do the input point sets need to be integers for the code to be optimally performant? I'm thinking of using this routine in a Lloyd smoothing/mesh generation code written in Python, but it requires float points for the point sites.
Overall, is the performance anticipated to be similar to that of the javascript implementation?
Thanks.
What an interesting show! And I'd like to ask,how to use your code to triangulate an image ?
thank you
Hello, When I run test.py, it has a problem. Could you solve this problem? Thank u
Traceback (most recent call last):
File ".\Test.py", line 12, in <module>
triangles = Delaunator(points).triangles
File "D:\Workplace\bigdata\Delaunator-Python-master\Delaunator.py", line 19, in __init__
triangles = self.constructor(coords)
File "D:\Workplace\bigdata\Delaunator-Python-master\Delaunator.py", line 41, in constructor
triangles = self.update(coords)
File "D:\Workplace\bigdata\Delaunator-Python-master\Delaunator.py", line 237, in update
t = self._addTriangle(q, i, e, -1, self.hullTri[e], self.hullTri[q])
File "D:\Workplace\bigdata\Delaunator-Python-master\Delaunator.py", line 361, in _addTriangle
self._triangles[t] = i0
IndexError: list assignment index out of range
I randomly distributed a bunch of points and the result was triangulation that was completely wrong, with various edges overlapping/criss-crossing each other (and to be clear, not connecting at any vertex), I suspect the following warnings might be relevant:
Delaunator.py:419: RuntimeWarning: overflow encountered in long_scalars
dy * (ex * cp - bp * fx) +
Delaunator.py:420: RuntimeWarning: overflow encountered in long_scalars
ap * (ex * fy - ey * fx) < 0
Delaunator.py:418: RuntimeWarning: overflow encountered in long_scalars
return dx * (ey * cp - bp * fy) -\
The issue happens every time except for when I provide a set of trivial points, i.e 5 points with 4 at the corners and 1 in the middle or just 4 at the corners will triangulate perfectly but a bunch of randomly generated points just fails to triangulate at all.
So to clarify, the triangulation seems to be failing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.