This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
from . import multisurface, surface | ||
from . import multisurface, surface, mesh | ||
|
||
__all__ = [ | ||
"multisurface", | ||
"surface", | ||
] | ||
__all__ = ["multisurface", "surface", "mesh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from dtcc_builder import _dtcc_builder | ||
|
||
from dtcc_model import Surface, MultiSurface, Mesh | ||
from dtcc_builder.register import register_model_method | ||
|
||
import numpy as np | ||
|
||
|
||
@register_model_method | ||
def ray_intersection( | ||
mesh: Mesh, origin: np.ndarray, direction: np.ndarray | ||
) -> np.ndarray: | ||
""" | ||
Compute the intersection points of a ray with a mesh. | ||
Args: | ||
mesh (Mesh): The mesh. | ||
origin (np.ndarray): The origin of the ray. | ||
direction (np.ndarray): The direction of the ray. | ||
Returns: | ||
np.ndarray: The intersection points. | ||
""" | ||
|
||
origin = np.array(origin, dtype=np.float64) | ||
direction = np.array(direction, dtype=np.float64) | ||
ms = MultiSurface() | ||
for face in mesh.faces: | ||
s = Surface( | ||
vertices=np.array( | ||
( | ||
mesh.vertices[face[0]], | ||
mesh.vertices[face[1]], | ||
mesh.vertices[face[2]], | ||
) | ||
) | ||
) | ||
ms.surfaces.append(s) | ||
return ms.ray_intersection(origin, direction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters