ray_mesh.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def contains_points(mesh, points):
    '''
    Check if a mesh contains a set of points, using ray tests.

    If the point is on the surface of the mesh, behavior is undefined.

    Arguments
    ---------
    mesh: Trimesh object
    points: (n,3) points in space

    Returns
    ---------
    contains: (n) boolean array, whether point is inside mesh or not
    '''
    points = np.asanyarray(points)
    vector = unitize([0,0,1])
    rays = np.column_stack((points, 
                            np.tile(vector,(len(points),1)))).reshape((-1,2,3))
    hits = mesh.ray.intersects_location(rays)
    hits_count = np.array([len(i) for i in hits])
    contains = np.mod(hits_count, 2) == 1

    return contains
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号