MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / compute_distances_gjk

Function compute_distances_gjk

python/dolfinx/geometry.py:295–320  ·  view source on GitHub ↗

Compute the distance between a set of convex bodies. For each convex body defined in `bodies`; (a set of 3D points for each body) find the shortest distance vector to to the body `q` defined by another set of 3D points. The method uses the Gilbert-Johnson-Keerthi (GJK) distance

(
    bodies: list[npt.NDArray[Real]], q: npt.NDArray[Real], num_threads: int
)

Source from the content-addressed store, hash-verified

293
294
295def compute_distances_gjk(
296 bodies: list[npt.NDArray[Real]], q: npt.NDArray[Real], num_threads: int
297) -> npt.NDArray[Real]:
298 """Compute the distance between a set of convex bodies.
299
300 For each convex body defined in `bodies`;
301 (a set of 3D points for each body) find the shortest distance vector
302 to to the body `q` defined by another set of 3D points.
303 The method uses the
304 Gilbert-Johnson-Keerthi (GJK) distance algorithm.
305
306 Args:
307 bodies: List of bodies, where each body is an array of
308 (``shape=(num_points_i, 3, gdim)``).
309 q: Body 2 list of points (``shape=(num_points_2, 3)``).
310 num_threads: Number of threads to use for GJK computation.
311
312 Returns:
313 Shortest vector between the two bodies.
314 """
315 assert all([p.dtype == q.dtype for p in bodies])
316 if np.issubdtype(q.dtype, np.float32):
317 return _cpp.geometry.compute_distances_gjk_float32(bodies, q, num_threads)
318 elif np.issubdtype(q.dtype, np.float64):
319 return _cpp.geometry.compute_distances_gjk_float64(bodies, q, num_threads)
320 raise RuntimeError("Invalid dtype in compute_distances_gjk")
321
322
323def determine_point_ownership(

Callers 1

find_colliding_cellsFunction · 0.90

Calls

no outgoing calls

Tested by 1

find_colliding_cellsFunction · 0.72