Get x cube mesh of size 1 centered at origin. ### Parameters tri (bool, optional): return triangulated mesh. Defaults to False, which returns quad mesh. ### Returns vertices (np.ndarray): shape (8, 3) faces (np.ndarray): shape (12, 3)
(tri: bool = False)
| 606 | |
| 607 | |
| 608 | def cube(tri: bool = False) -> Tuple[np.ndarray, np.ndarray]: |
| 609 | """ |
| 610 | Get x cube mesh of size 1 centered at origin. |
| 611 | |
| 612 | ### Parameters |
| 613 | tri (bool, optional): return triangulated mesh. Defaults to False, which returns quad mesh. |
| 614 | |
| 615 | ### Returns |
| 616 | vertices (np.ndarray): shape (8, 3) |
| 617 | faces (np.ndarray): shape (12, 3) |
| 618 | """ |
| 619 | vertices = np.array([ |
| 620 | [-0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [0.5, -0.5, 0.5], [-0.5, -0.5, 0.5], # v0-v1-v2-v3 |
| 621 | [-0.5, 0.5, -0.5], [0.5, 0.5, -0.5], [0.5, -0.5, -0.5], [-0.5, -0.5, -0.5] # v4-v5-v6-v7 |
| 622 | ], dtype=np.float32).reshape((-1, 3)) |
| 623 | |
| 624 | faces = np.array([ |
| 625 | [0, 1, 2, 3], # v0-v1-v2-v3 (front) |
| 626 | [4, 5, 1, 0], # v4-v5-v1-v0 (top) |
| 627 | [3, 2, 6, 7], # v3-v2-v6-v7 (bottom) |
| 628 | [5, 4, 7, 6], # v5-v4-v7-v6 (back) |
| 629 | [1, 5, 6, 2], # v1-v5-v6-v2 (right) |
| 630 | [4, 0, 3, 7] # v4-v0-v3-v7 (left) |
| 631 | ], dtype=np.int32) |
| 632 | |
| 633 | if tri: |
| 634 | faces = mesh.triangulate(faces, vertices=vertices) |
| 635 | |
| 636 | return vertices, faces |
| 637 | |
| 638 | |
| 639 | def camera_frustum(extrinsics: np.ndarray, intrinsics: np.ndarray, depth: float = 1.0) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: |
nothing calls this directly
no outgoing calls
no test coverage detected