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

查看:34
本文介绍了如何通过计算确定一个点是在 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.

您可以使用 Convex Hull 库来检查一个点是否在船体内.大多数库使用有符号距离函数来确定点是否在内部.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天全站免登陆