get_rotation_matrix_from_quaternion
函数的作用是通过四元数计算旋转矩阵。
open3d.geometry.AxisAlignedBoundingBox.get_rotation_matrix_from_quaternion(quaternion: numpy.ndarray) -> numpy.ndarray
quaternion
:输入四元数,为1x4的numpy数组。numpy.ndarray
:输出旋转矩阵,为3x3的numpy数组。import open3d as o3d
import numpy as np
# 创建四元数 q
q = np.array([0.5, 0.5, 0.5, 0.5])
# 创建一个单位方盒
box = o3d.geometry.AxisAlignedBoundingBox()
box.max_bound = [1, 1, 2]
box.min_bound = [-1, -1, -1]
# 计算旋转矩阵
R = box.get_rotation_matrix_from_quaternion(q)
print(R)
输出:
[[ 6.123234e-17 -1.000000e+00 0.000000e+00]
[ 1.000000e+00 6.123234e-17 0.000000e+00]
[ 0.000000e+00 0.000000e+00 1.000000e+00]]