-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Mesh3d generates inaccurate mesh #2194
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
Comments
When a Mesh3d is defined only by vertices (the faces are not given), then the Delaunay triangulation of this set is generated, to associate faces (triangles). The Delaunay triangulation of a set of 3D points is unique if no four points are coplanar. |
Your solution can be used as temporary workaround for small amount of points, because in that case this is not applicable. In my case, three points on two sides indicated by red lines are located on the vertical planes, and form a phantom face. The same three points on the opposite sides of the plot located on vertical planes as well, but they are without face, as it should be. So why then the phantom faces are not formed from each side everywhere? If you plot the unit cube with So why the faces suddenly appears in my case above, and here and here? Anyway, I suppose this is a bug with strange behavior. |
Some info on this issue here (Stabbing Delaunay Tetrahedralizations, Jonathan Richard Shewchuk, University of California at Berkeley). On page 3, figure 3 displays the proper wrapping (triangulation) of the point cloud from the bottom (lower convex hull). |
I analyzed more deeply your issue and I realized that you made an unsuitable choice for triangulating your point cloud. Just try to triangulate a sphere, starting from a point cloud generated on it and you'll have a bigger surprise than in the case of your shared data, that led to this issue. Mesh3d can generate and plot four types of geometric objects, depending on the alphahull value
Your surface can be easily triangulated as follows:
Your generated Mathematica plot is generated in the same way, not using a 3d Delaunay triangulation as you did. Any surface of equation z=f(x,y), as well as any parameterized surface can be triangulated and the corresponding x, y, z, i,j, k passed to the Mesh3d constructor. For implicit surfaces of equation, F(x,y,z)=constant, Plotly provides the class You can also read a 3d mesh from an obj off, ply, or stl file and plot the corresponding Mesh3d. Hence there are a lot of possibilities to use Plotly Mesh3d, but unfortunately I chose a wrong way to get your data triangulated. |
@empet, thank you for you explanation, everything you wrote is right, there are different ways how to triangulate the point cloud, I'm aware of them :) However, my point is about this exact default/pure Mesh3D method, without ijk, alphahull and other stuff defined. The problem is with default Mesh3D usage. In other words, the consistency issue. Why the default Mesh3d method works on points 5-6-7 and 7-8-1, and suddenly does not work on points 1-2-3 and 3-4-5, even if they are coplanar and projected on a line? The same happens here, with default Mesh3d implementation. By the way, I'm pretty sure that the wall-foming points in this example are coplanar as well and projected on the line. Should the average user deal with this behavior as with usual/normal one, or this is a bug of Mesh3d (or math behind)? |
An user should read the Plotly docs and learn that Mesh3d is not devised to perform surface triangulation, and as a consequence to triangulate his point cloud using one of the methods I outlined in the answer above. I repeat: The Mesh3d generates from x, y, z, a 3d Delaunay triangulation, i.e. a tetrahedralization. |
@empet, let's abstract from everything written above. Look, there is the "Simple 3D Mesh example", right the first one here. It tells me, that I can create a surface represented by a point cloud. Let's call it "surface", even if it is very rough. If you rotate it, it is a thin surface. I did the same with my points, because this feature is present in plotly and I can use it. Please, understand me right, I'm not asking for technical support and the better way how to solve my task :) I'm just curious about this strange and rare behavior applicable to this simple mesh3d with xyz only. Is it possible to explain, why do these walls appear, even if they should not be there? |
These are examples of tetrahedralization. They are generated from random 3d data, and exhibit vertical "walls", as tetrahedra faces. The same data, https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt, generate the following tetrahedralization with `delaunayaxis='y': |
I got your point. If we change the delaunayaxis say to "x" the vertices of the tetrahedrons formed by the point cloud will form a surface "coated" from x direction. That is fine. That is clear. So, why is there a wall from one side in my example and on the other side is not? Points 5-6-7 belong to one tetrahedron and points 1-2-3 belong to another one. In first case (5-6-7) there is no tetrahedron face, in another case (1-2-3) there is a tetrahedron face. Why? |
The two plots (that generated in the Plotly tutorial, and this one with delaunayais='y') are not smooth surfaces and we cannot affirm that they are graph of functions of the form z=f(x,y), respectively y = g(x,z), because they can exhibit vertical triangles, respectively triangles parallel to yaxis in the second case. In your much discussed case the point cloud consists in a discretization of a surface of type z=f(x,y), and in this case Mesh3d attempts to to remove from tetrahedra the faces that are not on the surface but it fails because this surface is far from being a slight perturbation of a z-plane, i.e. a plane of equation z=constant, for which the algorithm works. |
Just skimmed this thread (it's probably stale now) but wondering if anyone has found a better solution to tell plotly to do the triangulation in 2d (x, y) for the (x, y, z) plotting? I think that is one of the confusing issues people are hitting. I can manually do a delaunay and pass that through but seems like plotly is doing this itself just need a way of saying (use only these coords) |
Mesh3d creates useless or phantom "walls" on rendering. The issue was already described in 2016 here (case 1, case 2) but was abandoned without solution or any bug report. Recently, I met the same behavior with my data (see picture below, red lines drawn manually).
From another view the edges are displayed properly.
This shall be displayed in proper way. I tested it in with similar data in Wolfram Mathematica.
Attached data (Jupyter notebook, and CSV data):
error_plots_bug.zip
The text was updated successfully, but these errors were encountered: