-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Scipy Delaunay triangulation is not oriented #2953
Comments
By "consistent", do you mean counterclockwise ordering of the neighbor triangles? Such ordering is indeed not guaranteed. The Scipy code works essentially in the |
Based on this information, I'm marking this as an enhancement request. Producing oriented output is also possible, and probably would be the least surprising result in 2D. |
For 2D surface triangulation consistent orientation of the triangles would be the behaviour I would expect by default. From casual experiment it seems this is the default behaviour in Matlab, for instance. |
Under what conditions would we expect the triangulation to default to oriented? 2D and 3D delaunay? I'm happy to open a pull request for this as I'm pretty sure I've identified where in the code to fix this. Maybe we would like to be able to handle the |
qdelaunay man page seems to claim it produces oriented output for N-d. Fixing the orientation in the same way is quite cheap --- the only thing that needs to be taken care of is doing the same permutation in the neighbor simplex map too. Due to the fact that we are using qhull as a library rather than command-line program, fixing up the orientation is slightly more involved than just passing on flags. The relevant Qhull code is in |
Yes the relevant code seems to be Line 1175:
as you stated. Now looking at this it alludes to being able to handle ND simplicial facets. Drilling in to that code we find:
assuming we ignore the clockwise orientation flag then it only actually flips the vertices if the mesh is 2D and simplicial. Otherwise it just prints them in order. Therefore, it appears it only actually corrects 2D meshes - unless I am missing somewhere else that it does reorientation? Thus, a proposed solution would be something like (Around Line 609):
|
Pretty much so. However, it's best to not modify the qhull data structures directly as they may be needed later on for the incremental mode. I'm not sure about the > 2D case, but note that it flips the first two elements for all dimensions if the per-facet toporient flag is set. |
I could just be tired but are you sure this is true? It looks to be (from the snippet I posted) that if |
What about adding a kwarg |
Ah OK, you're right, it flips only 2D. I think any code that relies on a specific order of the vertices currently, is incorrect, because the order is not guaranteed and depends on implementation details. So we are free to change the behavior also without keywords. Always oriented in 2D is probably a good convention, and there's no performance cost. |
Is this a little dangerous? If we fix the |
The information in |
OK. My intuition says that in order to maintain a consistent |
Yes, the same orientation correction needs to be done also to that array. |
Fixed in gh-2954 |
I'm still not sure what to do with the "simplices" that result from 3d triangulation; how to convert them to the coordinates for individual triangular facets. |
The simplices from a 3D Delaunay triangulation are tetrahedra--so you'll have 4 triangular facets per simplex. There should be a variety of ways to iterate through the triangular facets, but that's probably better suited for a usage site like StackOverflow than a closed enhancement request on GitHub. There's a concise post / visualization available on the topic from Joseph O'Rourke, a well-known Professor of Computational Geometry & author of related textbooks. |
Which... makes me wonder what the purpose is...
It's "trianugulation," not "tetraherafication," or whatever...
…-----Original-Nachricht-----
The simplices from a 3D Delaunay triangulation are tetrahedra--so you'll
have 4 triangular facets per simplex.
|
Triangulation can be defined with no reference to triangles whatsoever and you can generalize the concept to N-dimensions. From: Devadoss, Satyan L.; O'Rourke, Joseph. Discrete and Computational Geometry (2011) Chapter 3: Triangulations: If you're no longer in the plane, the maximal set of non-crossing edges isn't either. There are a wide variety of reasons one may want this information. You might sum together the volumes of the tetrahedra to get the volume of the convex hull, or you may be designing a network that requires the connectivity enforced by the tetrahedra, etc. The circumspheres that include the vertices of the simplices (tetrahedra) also have unique properties. |
Well, I want the coordinates of the triangles as a result of Delaunay's
triangulation process, so I can analyse those statistically in order to see
whether the point distribution is clustered, random or patterned.
And I'm doing this in 3D.
…-----Original-Nachricht-----
Triangulation can be defined with no reference to triangles whatsoever and
you can generalize the concept to N-dimensions.
|
PC details
Linux dana 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Issue
With this mesh I am seeing inconsistent results from
scipy.spatial.Delaunay
. Assuming that the mesh has been loaded usingnumpy.loadtxt
into a variable calledpoints
, I duplicate the issue as follows:I have some code that checks the consistency of a triangulation (in terms of ordering) and the above code generates an inconsistent triangulation.
Ground Truth
In order to sanity check I compared the triangulation against the one created by
pyhull
. This is created using the same point set as follows:I've also generated the triangulation in Matlab using both
delaunay
anddelaunayn
and it yields results identical topyhull_t
. My triangulation consistency verifier also confirms that thepyhull_t
triangulation is correct.Options
In order to try and ensure that
scipy.spatial.Delaunay
is applying the same algorithm aspyhull
, I dove in to their source code. There I noticed that they always set the following flags:but running with those flags as follows:
still does not yield correct results.
Example output
An example of the triangulation I am seeing using the flags
Qbb Qc
:where we can see that the same indices are being generated, but the first two are sometimes swapped.
The text was updated successfully, but these errors were encountered: