porepy.geometry.distances module
The module contains functions for distance computations.
- point_pointset(p, pset, exponent=2)[source]
Compute distance between a point and a set of points.
- Parameters:
- Returns:
Array of distances
(shape=(num_points,)).- Return type:
- points_polygon(p, poly, tol=1e-5)[source]
Compute distance from points to a polygon. Also find closest point on the polygon.
- Parameters:
- Returns:
A tuple of 3 elements.
ndarray:shape=(num_points,)Distance from points to polygon.
ndarray:shape=(nd, num_points,)For each point, the closest point on the polygon.
ndarray:shape=(num_points)Trueif the point is found in the interior,Falseif on a bounding segment.- Return type:
- points_segments(p, start, end)[source]
Compute distances between points and line segments.
The function also returns the closest points on the segments.
- pointset(p, max_diag=False)[source]
Compute mutual distance between all points in a point set.
- Parameters:
- Returns:
Array of distances between points
(shape=(num_points, num_points)).- Return type:
- segment_overlap_segment_set(start, end, start_set, end_set, return_indices=False, tol=1e-5)[source]
Detects whether a given segment overlaps the segments in a set.
The function currently works only for 2D geometries:
nd == 2.- Parameters:
start (ndarray) –
shape=(nd,)Start point of a segment.
end (ndarray) –
shape=(nd,)End point of a segment.
start_set (ndarray) –
shape=(nd, num_segments)Start points of the set of segments.
end_set (ndarray) –
shape=(nd, num_segments)End points of the set of segments.
return_indices (bool) –
default=FalseWhether the function should also return indices of overlappings.
tol (float) –
default=1e-5Tolerance to be used.
- Returns:
If
return_indices==True, we return a tuple of 2 elements.bool:Trueif the segment overlaps any of the segments in the set,Falseotherwise.
ndarray:shape=(num_overlapping,)Indices of overlappings.
Otherwise, the 0th element of the tuple is returned.
- Return type:
- segment_segment_set(start, end, start_set, end_set)[source]
Compute distance and closest points between a segment and a set of segments.
Note
Algorithm can be found at http://geomalgorithms.com/code.html (see file “C07_Line_Line_Distance.cpp”, function
dist3D_Segment_to_Segment()).- Parameters:
- Returns:
A tuple of 3 elements.
ndarray:shape=(num_segments,)The distance from the main segment to each of the segments in the set.
ndarray:shape=(nd, num_segments)For each segment in the segment set, the point closest on the main segment.
ndarray:shape=(nd, num_segments)For each segment in the segment set, the point closest on the secondary segment.
- Return type:
- segment_set(start, end)[source]
Compute distance and closest points between sets of line segments.