pythonpoint-cloudslidaropen3d

How to rotate a point cloud so that the obb of the point cloud coincides with the abb


I have a series of radar point clouds and I have used shapfile to segment out several of these areas, which are all rectangular in shape from the z-axis. I would like to know if there is a way to rotate them so that one edge is parallel to the x or y axis. My idea is to create obb enclosing boxes with abb enclosing boxes and then compare the two and rotate them cyclically. Thanks!

aabb = cloud.get_axis_aligned_bounding_box()
aabb.color = (1, 0, 0)

obb = cloud.get_oriented_bounding_box()
obb.color = (0, 1, 0)

Solution

  • You should be able to call cloud.rotate() directly to which you pass a 3x3 rotation matrix.

    To get that 3x3 rotation matrix you have multiple options:

    e.g.

    cloud.rotate(o3d.geometry.get_rotation_matrix_from_axis_angle([np.radians(90), 0, 0]))
    

    (this should apply a 90 degrees rotation on the x axis: adjust as needed)