extend
函数用于向Vector2dVector
添加另一个向量或列表中的所有向量。
void extend(self, other: Union[Vector2d, List[Vector2d]])
other
:待添加的向量或向量列表。可以是一个Vector2d
类型或一个由Vector2d
组成的列表。extend
函数没有返回值,但向原始向量列表添加了待添加的向量。
import open3d as o3d
import numpy as np
# 创建一个Vector2dVector
vec = o3d.utility.Vector2dVector([[0, 0], [1, 1]])
# 定义一个待添加的Vector2d列表
new_vecs = [o3d.utility.Vector2d(2, 2), o3d.utility.Vector2d(3, 3)]
# 向原始列表中添加新的向量列表
vec.extend(new_vecs)
# 打印扩展后的向量列表
print(vec)
输出结果:
Vector2dVector[[0.000000, 0.000000], [1.000000, 1.000000], [2.000000, 2.000000], [3.000000, 3.000000]]
other
必须是一个Vector2d
类型或一个由Vector2d
组成的列表。other
是一个空列表,则不会添加任何向量到原始列表中。