Geometry
Module for geometric calculations in 2D and 3D spaces.
This module provides utility functions for geometric calculations. It include the computation of distances between points and line segments in 2D and 3D spaces. It is used to remove the crack from the pacman region in SIF estimation.
Functions:
| Name | Description |
|---|---|
distance_point_to_segment |
Computes the distance between points and a line segment. |
distance_point_to_segment(P, A, B)
Computes the distance between points and a line segment in 2D or 3D space.
This function calculates the shortest distance from each point in array P to the line segment defined by endpoints A and B.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
P
|
ndarray
|
Array of shape (n, m) where n is the number of points and m is the number of dimensions (2 or 3). Each row represents a point. |
required |
A
|
ndarray
|
1D array of shape (m,) representing one endpoint of the segment. |
required |
B
|
ndarray
|
1D array of shape (m,) representing the other endpoint of the segment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
distance |
ndarray
|
Array of shape (n,) where each element is the distance from the corresponding point in P to the segment AB. |
Source code in src/gcrack/utils/geometry.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |