Args: polygon_surfaces (np.ndarray): Polygon surfaces with shape of [num_polygon, max_num_surfaces, max_num_points_of_surface, 3]. All surfaces' normal vector must direct to internal. Max_num_points_of_surface must at least 3. Returns: t
(polygon_surfaces)
| 627 | |
| 628 | |
| 629 | def surface_equ_3d(polygon_surfaces): |
| 630 | """ |
| 631 | |
| 632 | Args: |
| 633 | polygon_surfaces (np.ndarray): Polygon surfaces with shape of |
| 634 | [num_polygon, max_num_surfaces, max_num_points_of_surface, 3]. |
| 635 | All surfaces' normal vector must direct to internal. |
| 636 | Max_num_points_of_surface must at least 3. |
| 637 | |
| 638 | Returns: |
| 639 | tuple: normal vector and its direction. |
| 640 | """ |
| 641 | # return [a, b, c], d in ax+by+cz+d=0 |
| 642 | # polygon_surfaces: [num_polygon, num_surfaces, num_points_of_polygon, 3] |
| 643 | surface_vec = polygon_surfaces[:, :, :2, :] - \ |
| 644 | polygon_surfaces[:, :, 1:3, :] |
| 645 | # normal_vec: [..., 3] |
| 646 | normal_vec = np.cross(surface_vec[:, :, 0, :], surface_vec[:, :, 1, :]) |
| 647 | # print(normal_vec.shape, points[..., 0, :].shape) |
| 648 | # d = -np.inner(normal_vec, points[..., 0, :]) |
| 649 | d = np.einsum('aij, aij->ai', normal_vec, polygon_surfaces[:, :, 0, :]) |
| 650 | return normal_vec, -d |
| 651 | |
| 652 | |
| 653 | @numba.njit |
no outgoing calls
no test coverage detected