在Open3D中,scale是用于对MeshBase对象进行缩放的方法。scale方法将会对MeshBase对象的所有顶点坐标进行一定的缩放,从而实现对MeshBase对象大小的调整。
函数原型:
def scale(self, scale=1.0, center=None):
"""
缩放MeshBase对象。
:param scale: 缩放因子
:type scale: float
:param center: 缩放中心点. 默认为(None, None, None)
:type center: Optional[Sequence[float, float, float]]]
"""
scale方法没有返回值,直接修改调用对象的属性。
在下面的示例中,我们创建一个正方体,使用scale方法进行缩放。
import open3d as o3d
import numpy as np
# 创建正方体
mesh_box = o3d.geometry.TriangleMesh.create_box(width=1.0, height=1.0, depth=1.0)
mesh_box.paint_uniform_color([1.0, 0.0, 0.0])
# 对正方体进行缩放
mesh_box.scale(0.5)
# 显示结果
o3d.visualization.draw_geometries([mesh_box])