如何通过计算确定点在3D模型之内还是之外 [英] How to determine whether a point is inside or outside a 3D model computationally

查看:72
本文介绍了如何通过计算确定点在3D模型之内还是之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3D模型的.obj和.ply文件.

I have a .obj and .ply file of a 3D model.

我想做的是阅读此3D模型文件,并查看3D坐标列表是在3D模型空间之内还是之外.例如,如果3D模型是半径为1的球体,则(0,0,0)将位于( True )的内部,而(2,0,0)将位于( False).当然,我使用的3D模型并不像球体那么简单.

What I want to do is read this 3D model file and see if a list of 3D coordinates are either inside or outside the 3D model space. For example, if the 3D model is a sphere with radius 1, (0,0,0) would be inside (True) and (2,0,0) would be outside (False). Of course the 3D model I'm using is not as simple as a sphere.

我想添加一些我考虑使用的方法.由于我使用的是Python,因此我考虑使用PyMesh,因为它们的交集功能看起来很有希望.但是,我拥有的坐标列表不是网格文件,而只是矢量,因此它似乎不是适合使用的函数.

I would like to add some of the methods I considered using. Since I am using Python, I thought of using PyMesh, as their intersection feature looked promising. However the list of coordinates I have are not mesh files but just vectors, so it didn't seem to be the appropriate function to use.

我还找到了方法使用射线投射.但是,如何使用PyMesh或任何其他Python工具来做到这一点是我需要建议的.

I also found this method using ray casting. However, how to do this with PyMesh, or any other Python tool is something I need advice on.

推荐答案

将我的评论转换为未来读者的答案.

Converting my comment into an answer for future readers.

您可以使用凸包库来检查点是否在包内.大多数库使用符号距离函数来确定该点是否在内部. trimesh 是实现此功能的库之一.

You can use a Convex Hull library to check whether a point is inside the hull. Most libraries use signed distance function to determine whether the point is inside. trimesh is one of the libraries that implements this feature.

这篇关于如何通过计算确定点在3D模型之内还是之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆