MeshRay error?

error.3dm (59.2 KB) (13.0 KB)
error2.3dm (28.7 KB)
I tried meshRay hit, and found an error.
ray(start point(0,0,0), direction vector(1,0,0))

  1. I used brep(5surfaces{pentagon}, and 6 vertices).
    and shoot the ray to the center vertex.
    and found meshray function ignores one face.
    Is there anyone who knows why?
  2. please check erro2.3dm and tell me why it happens,.
    I have to make much complicated code unless this will be fixed.
    (of course “?” case can be treated as no hit.)
    if it is bug, then will it be fixed soon ?

When you shoot a ray which is intended to hit a mesh exactly at a convex vertex it will either hit it straight on, hit it just on the ‘inside’ or it will just about miss it. If you’re lucky enough to get an exact hit, you’ll get the answer you were looking for. If you manage to hit the mesh just below the vertex you’ll get two answers (one entry and one exit wound), and if you just miss the vertex you’ll get no result.

The inherent inaccuracies in floating point mathematics mean that you probably can’t trust the least significant digits of whatever numbers describe your geometry so if your algorithm relies on two floating point numbers being exactly the same it will give you a lot of grief.

As a possible way forward, if you’re expecting to hit vertices of a mesh, it may make more sense to construct lines to these vertices and see if they are within some directional tolerance of your original ray.

Thank you for your reply, David.
when I tried
" Dim msa() As mesh
msa = mesh.CreateFromBrep(br, mp)",
the createFromBrep fuction returns seperate mesh array
and made correct result. but I have to iterate all the mesh array and have to select one. But if it happens with a single mesh(many faces)? then iterating mesh array is not enough. and cheking if the result returned all the faces around hit vertex will be more difficult.
I am still wondering whether the problem comes from tolerance and double digit, becase I used the very simple and same breps.(I used simple polyline(using gridsnap) or a dot and pentagon polyline to make the breps ) and the same ray3d.(when I tested the mesh tolerance to meshparameter.Tolerance = 0.00000001, then only one face of pyramid pentagon returned many meshfaces hits. I think it is easy to be solved inside rhino, not from user.

I tested this polysurface because there can be the same rayhit(even though I use ‘createfrombrep’.)
if the ray hits at the vertex and the edge of a single mesh and the mesh vertex have two or more mesh faces and the ray direction is parallel to the face or the edge, I have to know what will happen. (11.3 KB)