Mesh.IsPointInside() persistent bug

Hi there-

It looks like Mesh.IsPointInside() will occasionally fail, when a test vertex strikes the inclusion mesh precisely on an edge. Writing one from scratch following David’s logic from this thread over on the old GH forum: reproduces the error. I made a quick fix that does a second test based on another arbitrary vector and then determines if the number of intersections for either test is an odd number…doubles the effort, but seems to work. In any event, it’s worth knowing that this bug is persistent.



Hi Dave,

This is a known issue.

I’ll mention this to the developer again.

– Dale

Thanks, Dale! It fails rarely…but does indeed.

This method don’t work at all in my case -

Mesh is closed also tolerance here no matter if ZeroTolerance / Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance / 1000 also no change with true or false always is false i wanted to build convexhull so it’s crucial for me.

First i thought that normals here are crucial but they are not :thinking:

Ok method will work if:

mesh.Vertices.CombineIdentical(true, true);

First i thought it will work but now i see that it randomly gives different results.

@stevebaer Any recomendations?

I’m not sure what your mesh looks like. The algorithm simply creates a line from the test point to a point know to be outside of the mesh. An intersection is run on this line with the mesh and if the number of intersections is an odd number, true is returned. I’m sure there is a more robust approach, but that is what we currently have implemented.

You could try the same test with the MeshLine intersect routine in RhinoCommon.

Thanks @stevebaer for suggestion. I’ll try with MeshLine one. Btw. i’m making quickhull algorithm so there’s a lot of points on edge and that’s probably the issue here.

The Waterman Polyhedra add-on included a QuickHull implementation - and it’s available in Grasshopper…

– Dale

@dale i use GH only for quick prototyping code i needed this in c# and now i have partially with IsPointInside and if something is giving false it just falls to closest point with tolerance quick and dirty workaround but it works finally.