Mesh deformation
如果我们想根据少量的约束来变形三角形网格,我们可以使用网格变形算法。Open3D通过[SorkineAndAlexa2007]实现了尽可能严格的方法,该方法优化了以下能量函数
是我们想要优化的旋转矩阵,
分别是优化前后的顶点位置。
是顶点i的邻居的集合。权重
是余切权重。
Open3D 在deform_as_rigid_as_possible中实现了此方法。此方法的第一个参数constraint_ids是一组引用三角形网格中的顶点的参数。第二个参数constrint_pos定义优化后这些顶点应位于哪个位置。优化过程是一个迭代方案。因此,我们还可以通过 max_iter定义迭代次数。
armadillo = o3d.data.ArmadilloMesh()
mesh = o3d.io.read_triangle_mesh(armadillo.path)
vertices = np.asarray(mesh.vertices)
static_ids = [idx for idx in np.where(vertices[:, 1] < -30)[0]]
static_pos = []
for id in static_ids:
static_pos.append(vertices[id])
handle_ids = [2490]
handle_pos = [vertices[2490] + np.array((-40, -40, -40))]
constraint_ids = o3d.utility.IntVector(static_ids + handle_ids)
constraint_pos = o3d.utility.Vector3dVector(static_pos + handle_pos)
with o3d.utility.VerbosityContextManager(
o3d.utility.VerbosityLevel.Debug) as cm:
mesh_prime = mesh.deform_as_rigid_as_possible(constraint_ids,
constraint_pos,
max_iter=50)
Smoothed ARAP 平滑的 ARAP
Open3D 还实现了 ARAP 目标的平滑版本,定义为
,
这会惩罚相邻旋转矩阵的偏差。 α是正则化项的权衡参数,并且A是表面积。
平滑化的目标可以通过deform_as_rigid_as_possible将参数energy与参数Smoothed 一起使用。
https://zhuanlan.zhihu.com/p/25846219 https://zhuanlan.zhihu.com/p/25804146