porepy.utils.sort_points module
Functions to sort points and edges belonging to geometric objects.
- sort_multiple_point_pairs(lines)[source]
Function to sort multiple pairs of points to form circular chains.
The routine contains essentially the same functionality as sort_point_pairs, but stripped down to the special case of circular chains. Differently to sort_point_pairs, this variant sorts an arbitrary amount of independent point pairs. The chains are restricted by the assumption that each contains equally many line segments. Finally, this routine uses numba.
- Parameters
lines (
np.ndarray
) – Array of size 2 * num_chains x num_lines_per_chain, containing node indices. For each pair of two rows, each column represents a line segment connectng the two nodes in the two entries of this column.- Returns
- Sorted version of lines, where for each chain, the collection
of l
- Return type
np.ndarray
- Raises
ImportError ifine segments has been potentially flipped and sorted. –
- sort_point_pairs(lines, check_circular=True, is_circular=True)[source]
Sort pairs of numbers to form a chain.
The target application is to sort lines, defined by their start end endpoints, so that they form a continuous polyline.
The algorithm is brute-force, using a double for-loop. This can surely be improved.
- Parameters
- Returns
- sorted line pairs. If lines had more than 2 rows,
the extra are sorted accordingly.
- np.ndarray, n: Sorted column indices, so that
sorted_lines = lines[:, sort_ind], modulo flipping of rows in individual columns
- Return type
np.ndarray, 2xn
- sort_point_plane(pts, centre, normal=None, tol=1e-5)[source]
Sort the points which lie on a plane.
The algorithm assumes a star-shaped disposition of the points with respect the centre.
- Parameters
- Returns
np.array, 1xn, sorted point ids.
- Return type
map_pts
- sort_triangle_edges(t)[source]
Sort a set of triangles so that no edges occur twice with the same ordering.
For a planar triangulation, this will end up with all the triangles being ordered CW or CCW. In cases where the triangulated surface(s) do not share a common plane, methods based on geometry are at best cumbersome. This approach should work also in those cases.
- Parameters
t (
np.ndarray, 3 x n_tri
) – Triangulation to have vertexes ordered.- Returns
With the vertexes ordered.
- Return type
np.ndarray, 3 x n_tri
Example
>>> t = np.array([[0, 1, 2], [1, 2, 3]]).T >>> sort_triangle_edges(t) np.array([[0, 2], [1, 1], [2, 3]])