adaptive.learner.triangulation module¶
Triangulation
¶
A triangulation object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
2d array-like of floats
|
Coordinates of vertices. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
list of float tuples
|
Coordinates of the triangulation vertices. |
simplices |
set of integer tuples
|
List with indices of vertices forming individual simplices |
vertex_to_simplices |
list of sets
|
Set of simplices connected to a vertex, the index of the vertex is the index of the list. |
hull |
set of int
|
Exterior vertices |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the list of coordinates is incorrect or the points do not form one or more simplices in the |
Source code in adaptive/learner/triangulation.py
hull
property
¶
Compute hull from triangulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check
|
bool
|
Whether to raise an error if the computed hull is different from stored. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
hull |
set of int
|
Vertices in the hull. |
delete_simplex
¶
add_simplex
¶
get_vertices
¶
get_vertex
¶
get_reduced_simplex
¶
get_reduced_simplex(point, simplex, eps=1e-08) -> list
Check whether vertex lies within a simplex.
Returns:
| Name | Type | Description |
|---|---|---|
vertices |
list of ints
|
Indices of vertices of the simplex to which the vertex belongs. An empty list indicates that the vertex is outside the simplex. |
Source code in adaptive/learner/triangulation.py
point_in_simplex
¶
locate_point
¶
Find to which simplex the point belongs.
Return indices of the simplex containing the point. Empty tuple means the point is outside the triangulation
Source code in adaptive/learner/triangulation.py
faces
¶
Iterator over faces of a simplex or vertex sequence.
Source code in adaptive/learner/triangulation.py
containing
¶
circumscribed_circle
¶
Compute the center and radius of the circumscribed circle of a simplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplex
|
tuple of ints
|
the simplex to investigate |
required |
Returns:
| Type | Description |
|---|---|
tuple (center point, radius)
|
The center and radius of the circumscribed circle |
Source code in adaptive/learner/triangulation.py
point_in_cicumcircle
¶
Source code in adaptive/learner/triangulation.py
bowyer_watson
¶
Modified Bowyer-Watson point adding algorithm.
Create a hole in the triangulation around the new point, then retriangulate this hole.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pt_index
|
the index of the point to inspect |
required |
Returns:
| Name | Type | Description |
|---|---|---|
deleted_simplices |
set of tuples
|
Simplices that have been deleted |
new_simplices |
set of tuples
|
Simplices that have been added |
Source code in adaptive/learner/triangulation.py
add_point
¶
Add a new vertex and create simplices as appropriate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
float vector
|
Coordinates of the point to be added. |
required |
transform
|
N*N matrix of floats
|
Multiplication matrix to apply to the point (and neighbouring simplices) when running the Bowyer Watson method. |
None
|
simplex
|
tuple of ints
|
Simplex containing the point. Empty tuple indicates points outside the hull. If not provided, the algorithm costs O(N), so this should be used whenever possible. |
None
|
Source code in adaptive/learner/triangulation.py
volume
¶
volumes
¶
reference_invariant
¶
vertex_to_simplices and simplices are compatible.
Source code in adaptive/learner/triangulation.py
vertex_invariant
¶
get_neighbors_from_vertices
¶
get_face_sharing_neighbors
¶
Keep only the simplices sharing a whole face with simplex.
get_simplices_attached_to_points
¶
get_opposing_vertices
¶
Source code in adaptive/learner/triangulation.py
FakeDelaunay
¶
Bases: Delaunay
Throw in a Triangulation object, and receive a brandnew scipy.spatial.Delaunay
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
2d arraylike of floats
|
|
required |
simplices
|
2d arraylike of integers
|
|
required |
Source code in adaptive/learner/triangulation.py
fast_norm
¶
Take the vector norm for len 2, 3 vectors. Defaults to a square root of the dot product for larger vectors.
Note that for large vectors, it is possible for integer overflow to occur. For instance: vec = [49024, 59454, 12599, -63721, 18517, 27961] dot(vec, vec) = -1602973744
Source code in adaptive/learner/triangulation.py
fast_2d_point_in_simplex
¶
Source code in adaptive/learner/triangulation.py
point_in_simplex
¶
Source code in adaptive/learner/triangulation.py
fast_2d_circumcircle
¶
Compute the center and radius of the circumscribed circle of a triangle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
the points of the triangle to investigate |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(center point : tuple(float), radius: float) |
Source code in adaptive/learner/triangulation.py
fast_3d_circumcircle
¶
Compute the center and radius of the circumscribed sphere of a simplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
the points of the triangle to investigate |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(center point : tuple(float), radius: float) |
Source code in adaptive/learner/triangulation.py
fast_det
¶
Source code in adaptive/learner/triangulation.py
circumsphere
¶
Compute the center and radius of a N dimension sphere which touches each point in pts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
array-like, of shape (N-dim + 1, N-dim)
|
The points for which we would like to compute a circumsphere. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
center |
tuple of floats of size N-dim
|
|
radius |
a positive float
|
|
A valid center and radius, if a circumsphere is possible, and no points are repeated.
|
|
|
If points are repeated, or a circumsphere is not possible, will return nans, and a
|
|
|
ZeroDivisionError may occur.
|
|
|
Will fail for matrices which are not (N-dim + 1, N-dim) in size due to non-square determinants:
|
|
|
will raise numpy.linalg.LinAlgError.
|
|
|
May fail for points that are integers (due to 32bit integer overflow).
|
|
Source code in adaptive/learner/triangulation.py
orientation
¶
Compute the orientation of the face with respect to a point, origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
array-like, of shape (N-dim, N-dim)
|
The hyperplane we want to know the orientation of Do notice that the order in which you provide the points is critical |
required |
origin
|
array-like, point of shape (N-dim)
|
The point to compute the orientation from |
required |
Returns:
| Type | Description |
|---|---|
0 if the origin lies in the same hyperplane as face,
|
|
-1 or 1 to indicate left or right orientation
|
|
If two points lie on the same side of the face, the orientation will
|
|
be equal, if they lie on the other side of the face, it will be negated.
|
|
Source code in adaptive/learner/triangulation.py
is_iterable_and_sized
¶
simplex_volume_in_embedding
¶
simplex_volume_in_embedding(vertices) -> float
Calculate the volume of a simplex in a higher dimensional embedding. That is: dim > len(vertices) - 1. For example if you would like to know the surface area of a triangle in a 3d space.
This algorithm has not been tested for numerical stability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
2D arraylike of floats
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
volume |
float
|
the volume of the simplex with given vertices. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the vertices do not form a simplex (for example, because they are coplanar, colinear or coincident). |
Warning: this algorithm has not been tested for numerical stability.
|
|