Create an o3d mesh representing a plane. The mesh contains two triangles. Args: top_left: the top left coordinate of the plane top_right: the top right coordinate of the plane bottom_left: the bottom left coordinate of the pla
(
top_left: T.List[float], # (3,)
top_right: T.List[float], # (3,)
bottom_left: T.List[float], # (3,)
bottom_right: T.Optional[T.List[float]] = None, # (3,)
)
| 737 | |
| 738 | |
| 739 | def create_o3d_plane_mesh( |
| 740 | top_left: T.List[float], # (3,) |
| 741 | top_right: T.List[float], # (3,) |
| 742 | bottom_left: T.List[float], # (3,) |
| 743 | bottom_right: T.Optional[T.List[float]] = None, # (3,) |
| 744 | ) -> o3d.geometry.TriangleMesh: |
| 745 | """ |
| 746 | Create an o3d mesh representing a plane. |
| 747 | The mesh contains two triangles. |
| 748 | |
| 749 | Args: |
| 750 | top_left: |
| 751 | the top left coordinate of the plane |
| 752 | top_right: |
| 753 | the top right coordinate of the plane |
| 754 | bottom_left: |
| 755 | the bottom left coordinate of the plane |
| 756 | bottom_right: |
| 757 | the bottom right coordinate of the plane. |
| 758 | If None, will assumed to be a parallelgram |
| 759 | |
| 760 | Returns: |
| 761 | o3d mesh |
| 762 | """ |
| 763 | if isinstance(top_left, list): |
| 764 | top_left = np.array(top_left, dtype=np.float64) |
| 765 | if isinstance(top_right, list): |
| 766 | top_right = np.array(top_right, dtype=np.float64) |
| 767 | if isinstance(bottom_left, list): |
| 768 | bottom_left = np.array(bottom_left, dtype=np.float64) |
| 769 | if isinstance(bottom_right, list): |
| 770 | bottom_right = np.array(bottom_right, dtype=np.float64) |
| 771 | |
| 772 | if bottom_right is None: |
| 773 | bottom_right = top_right + (bottom_left - top_left) |
| 774 | |
| 775 | mesh = o3d.geometry.TriangleMesh() |
| 776 | np_vertices = np.stack( |
| 777 | [ |
| 778 | top_left, |
| 779 | top_right, |
| 780 | bottom_left, |
| 781 | bottom_right, |
| 782 | ], axis=0) # (4, 3) |
| 783 | np_triangles = np.array( |
| 784 | [ |
| 785 | [0, 2, 1], |
| 786 | [1, 2, 3], |
| 787 | ]).astype(np.int32) |
| 788 | mesh.vertices = o3d.utility.Vector3dVector(np_vertices) |
| 789 | mesh.triangles = o3d.utility.Vector3iVector(np_triangles) |
| 790 | |
| 791 | return mesh |
| 792 | |
| 793 | |
| 794 | def create_video( |
nothing calls this directly
no outgoing calls
no test coverage detected