Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotate a pointcloud in z axis

I am trying to rotate a pcd but I get the following error, how do I fix the same -

import open3d as o3d 
import numpy as np 

xyz = o3d.io.read_point_cloud("data.pcd")
xyz = xyz.rotate(xyz.get_rotation_matrix_from_xyz((0.7 * np.pi, 0, 0.6 * np.pi)),center=True)

Error -

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: get_rotation_matrix_from_xyz(): incompatible function arguments. The following argument types are supported:
    1. (rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]]

Invoked with: array([[-0.30901699, -0.95105652,  0.        ],
       [-0.55901699,  0.18163563, -0.80901699],
       [ 0.76942088, -0.25      , -0.58778525]]); kwargs: center=True

how do i fix the same

like image 415
Suman Avatar asked Sep 11 '25 00:09

Suman


1 Answers

The center argument is not boolean, but should describe the rotation center (see docs):

center (numpy.ndarray[float64[3, 1]]) – Rotation center used for transformation

This would rotate around the origin (0,0,0):

import open3d as o3d 
import numpy as np 

xyz = o3d.io.read_point_cloud("data.pcd")
R = xyz.get_rotation_matrix_from_xyz((0.7 * np.pi, 0, 0.6 * np.pi))
xyz = xyz.rotate(R, center=(0,0,0))
like image 97
snwflk Avatar answered Sep 14 '25 11:09

snwflk