我基本上想在3D对象的网格(包括python中的表面法线)上生成随机表面点。我在该领域没有很多经验。因此,有人可以向我推荐一些解决任务的软件包,方法和方法吗?
查看过open3d和trimesh,但仍然有一些麻烦。
谢谢!
答案 0 :(得分:0)
我会使用matplotlib
。也许您需要在this page here上使用“三面图”?您可以CTRL+F
Tri-Surface plots
从字面上快速找到它,并查看它生成的图像以查看它是否正是您想要的。
答案 1 :(得分:0)
使用三边形很简单:
In [1]: import trimesh
In [2]: m = trimesh.creation.icosphere()
In [3]: m
Out[3]: <trimesh.base.Trimesh at 0x7f99bec7d550>
In [4]: m.sample?
Signature: m.sample(count, return_index=False)
Docstring:
Return random samples distributed normally across the
surface of the mesh
Parameters
---------
count : int
Number of points to sample
return_index : bool
If True will also return the index of which face each
sample was taken from.
Returns
---------
samples : (count, 3) float
Points on surface of mesh
face_index : (count, ) int
Index of self.faces
File: /media/psf/Dropbox/robotics/trimesh/trimesh/base.py
Type: method
In [5]: points, index = m.sample(1000, return_index=True)
In [6]: points
Out[6]:
array([[ 0.79934465, 0.58103816, 0.1308479 ],
[-0.07373243, 0.08338232, 0.99055759],
[ 0.71660325, 0.21369974, 0.65889903],
...,
[-0.08330094, 0.98915598, 0.10205582],
[ 0.2558548 , -0.68523377, -0.6770221 ],
[-0.11483521, 0.97023335, 0.19696663]])
In [8]: normals = m.face_normals[index]
In [9]: normals
Out[9]:
array([[ 0.79167915, 0.58957859, 0.16012871],
[-0.04950537, 0.06905681, 0.99638365],
[ 0.73810358, 0.21732806, 0.63872656],
...,
[-0.06905681, 0.99638365, 0.04950537],
[ 0.23921922, -0.7022584 , -0.67052763],
[-0.08142553, 0.97123096, 0.22378629]])
通过找到每个点的重心坐标,然后对顶点法线进行插值,可以获得更好的法线,但是仅使用面法线非常容易。