【发布时间】:2016-03-22 19:08:59
【问题描述】:
我正在尝试将多面模型/stl 文件转换为实体模型。我目前采用的方法是为每个小平面/三角形面提取法向量和/或平面方程,并取它们的点积。
如果点积为 1 或接近 1,则法线指向同一方向,因此我将取它们的平均值。目标是为每个 facet 提取 10,000 个法向量/平面方程,通过点积将它们相互比较,然后输出近似 facet 模型的 10 个法向量/10 个平面方程。
比较多面模型/STL 文件的多个法线向量的良好数据结构是什么?
我正在研究八叉树/rtrees,但我对它们没有太多经验。我还考虑过在 Disco 库中使用 MapReduce 方法。
下面的方法可能适用于少数方面 (50),但一旦达到 1000 个方面,它就会成为一个挑战
# if the planes are not coplanar
#place sympy code here
#plane_list.append(sp.Plane(sp.Point3D(temp_tuple[1][0][0],temp_tuple[1][0][1],temp_tuple[1][0][2]), sp.Point3D(temp_tuple[1][1][0],temp_tuple[1][1][1],temp_tuple[1][1][2]), sp.Point3D(temp_tuple[1][2][0],temp_tuple[1][2][1],temp_tuple[1][2][2])))
#compare normals from each plane equation
for j in range(len(normals_list)):
print("Normal for plane equation " +str(j) + " is "+ str(normals_list[j]))
for k in range(len(normals_list)):
#
if j is not k:
temp_array1=np.array(normals_list[j])
temp_array2=np.array(normals_list[k])
#dot_product=np.dot(temp_array1, temp_array2)
dot_product=np.vdot(temp_array1,temp_array2)
print("The vector dot product for "+str(j)+" and "+str(k)+" is "+str(dot_product))
unit_vectorj = np.sqrt(np.dot(temp_array1, temp_array1))
unit_vectork = np.sqrt(np.dot(temp_array2, temp_array2))
#if the normals point in approximately the same direction
if float(dot_product)==1.0:
cntr+=1
print("The number of times is "+str(cntr))
mean_normals.append(normals_list[j])
【问题讨论】:
标签: python vector stl 3d normals