OBB
- 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).
### My Question
Hi all, I am trying to get a specific orientation for a mesh. For that, once I created the mesh, I multiply by the inverse of the current OBB orientation to make the current orientation unity. The position seems to get centred while the orientation returned is still the same. Is there a way to force or retain the orientation? This does not happen if the box created symmetrical. Is it because when I call get_oriented_bounding_box, it recalculates the convex-hull and then redo all the computation to get the orientation? Below is a code snippet that exhibits this. Probably the mesh is getting rotated, the question will be how to get its current orientation?
```
import numpy as np
import open3d as o3d
def get_mesh_pose(mesh):
pose = np.eye(4)
bb = mesh.get_oriented_bounding_box()
pose[:3, :3] = bb.R
pose[:3, 3] = bb.center
return pose
def create_mesh(width, height, depth):
return o3d.geometry.TriangleMesh.create_box(width=width,
height=height,
depth=depth)
mesh = create_mesh(4, 3, 4)
curr_pose = get_mesh_pose(mesh)
print("current pose of the mesh")
print(repr(curr_pose))
print("product of the inverse")
print(np.linalg.inv(curr_pose).dot(curr_pose))
mesh.transform(np.linalg.inv(curr_pose))
print("after applying transformation")
print(repr(get_mesh_pose(mesh)))
new_pose = np.array([[ 0.33, -0.94, -0. , 0.2 ],
[-0.94, -0.33, -0. , -1. ],
[ 0. , 0. , -1. , 0. ],
[ 0. , 0. , 0. , 1. ]])
mesh.transform(new_pose)
print("after applying new transformation")
print(repr(get_mesh_pose(mesh)))
```
The above code produces the following output.
```
current pose of the mesh
array([[ 1. , 0. , 0. , 2. ],
[ 0. , 0. , -1. , 1.5],
[ 0. , 1. , 0. , 2. ],
[ 0. , 0. , 0. , 1. ]])
product of the inverse
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
after applying transformation
array([[ 0., 1., 0., 0.],
[ 1., 0., 0., 0.],
[ 0., 0., -1., 0.],
[ 0., 0., 0., 1.]])
after applying new transformation
array([[ 0. , 1. , 0. , 0.2],
[ 1. , 0. , 0. , -1. ],
[ 0. , 0. , -1. , 0. ],
[ 0. , 0. , 0. , 1. ]])
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.