mesh.rotate() is always relative, unlike mesh.translate() - please add a parameter so we can specify an absolute rotation
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
### Checklist
- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).
### Proposed new feature or change
In our application, we want to move and rotate a mesh to positions and rotations that we specify. The mesh.translate() function has the helpful parameter IsRelative, so you can specify whether you are telling the mesh to move **by** an amount, or **to** a position. However, mesh.rotate does not have this parameter, and so there is no way to tell it to rotate to an orientation. To put it into simple English, it's possible to make a mesh rotate right or left, but not possible to tell it to face north.
This would be very helpful in some of our applications. We can attempt to work around it by getting the difference between the prior and desired rotation, and then providing that increment to the function - but that is suboptimal and will be prone to both synchronization errors and rounding errors.
Here is some code that can be used to test this. You can see that rotation is incremental rather than absolute, because the rate of rotation accelerates:
```
import open3d as o3d
import numpy as np
import time
def rotate_mesh_in_loop():
# Initialize visualization
vis = o3d.visualization.Visualizer()
vis.create_window()
# Get sample bunny mesh
bunny = o3d.data.BunnyMesh()
mesh = o3d.io.read_triangle_mesh(bunny.path)
mesh.compute_vertex_normals()
vis.add_geometry(mesh)
total_rotation_angle_y = 0
for i in range(120): # This will rotate 90 degrees in 1-degree increments
# Reset to home position
mesh.transform(np.eye(4))
# Increment the rotation angle by 1 degree in radians
total_rotation_angle_y += np.radians(.2)
# Create a rotation matrix for the new total rotation angle
R = mesh.get_rotation_matrix_from_xyz((0, total_rotation_angle_y, 0))
# Apply the rotation
mesh.rotate(R, center=(0, 0, 0))
# Update the mesh in visualization
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
# Pause for 1/30th of a second to simulate 30Hz operation
time.sleep(1/30)
vis.destroy_window()
if __name__ == "__main__":
rotate_mesh_in_loop()
```
### References
_No response_
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.