package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Delaunay
]
type t = [ `Delaunay | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?furthest_site:bool -> ?incremental:bool -> ?qhull_options:string -> points:[> `Ndarray ] Np.Obj.t -> unit -> t

Delaunay(points, furthest_site=False, incremental=False, qhull_options=None)

Delaunay tessellation in N dimensions.

.. versionadded:: 0.9

Parameters ---------- points : ndarray of floats, shape (npoints, ndim) Coordinates of points to triangulate furthest_site : bool, optional Whether to compute a furthest-site Delaunay triangulation. Default: False

.. versionadded:: 0.12.0 incremental : bool, optional Allow adding new points incrementally. This takes up some additional resources. qhull_options : str, optional Additional options to pass to Qhull. See Qhull manual for details. Option 'Qt' is always enabled. Default:'Qbb Qc Qz Qx Q12' for ndim > 4 and 'Qbb Qc Qz Q12' otherwise. Incremental mode omits 'Qz'.

.. versionadded:: 0.12.0

Attributes ---------- points : ndarray of double, shape (npoints, ndim) Coordinates of input points. simplices : ndarray of ints, shape (nsimplex, ndim+1) Indices of the points forming the simplices in the triangulation. For 2-D, the points are oriented counterclockwise. neighbors : ndarray of ints, shape (nsimplex, ndim+1) Indices of neighbor simplices for each simplex. The kth neighbor is opposite to the kth vertex. For simplices at the boundary, -1 denotes no neighbor. equations : ndarray of double, shape (nsimplex, ndim+2) normal, offset forming the hyperplane equation of the facet on the paraboloid (see `Qhull documentation <http://www.qhull.org/>`__ for more). paraboloid_scale, paraboloid_shift : float Scale and shift for the extra paraboloid dimension (see `Qhull documentation <http://www.qhull.org/>`__ for more). transform : ndarray of double, shape (nsimplex, ndim+1, ndim) Affine transform from ``x`` to the barycentric coordinates ``c``. This is defined by::

T c = x - r

At vertex ``j``, ``c_j = 1`` and the other coordinates zero.

For simplex ``i``, ``transformi,:ndim,:ndim`` contains inverse of the matrix ``T``, and ``transformi,ndim,:`` contains the vector ``r``.

If the simplex is degenerate or nearly degenerate, its barycentric transform contains NaNs. vertex_to_simplex : ndarray of int, shape (npoints,) Lookup array, from a vertex, to some simplex which it is a part of. If qhull option 'Qc' was not specified, the list will contain -1 for points that are not vertices of the tessellation. convex_hull : ndarray of int, shape (nfaces, ndim) Vertices of facets forming the convex hull of the point set. The array contains the indices of the points belonging to the (N-1)-dimensional facets that form the convex hull of the triangulation.

.. note::

Computing convex hulls via the Delaunay triangulation is inefficient and subject to increased numerical instability. Use `ConvexHull` instead. coplanar : ndarray of int, shape (ncoplanar, 3) Indices of coplanar points and the corresponding indices of the nearest facet and the nearest vertex. Coplanar points are input points which were *not* included in the triangulation due to numerical precision issues.

If option 'Qc' is not specified, this list is not computed.

.. versionadded:: 0.12.0 vertices Same as `simplices`, but deprecated. vertex_neighbor_vertices : tuple of two ndarrays of int; (indptr, indices) Neighboring vertices of vertices. The indices of neighboring vertices of vertex `k` are ``indicesindptr[k]:indptr[k+1]``. furthest_site True if this was a furthest site triangulation and False if not.

.. versionadded:: 1.4.0

Raises ------ QhullError Raised when Qhull encounters an error condition, such as geometrical degeneracy when options to resolve are not enabled. ValueError Raised if an incompatible array is given as input.

Notes ----- The tessellation is computed using the Qhull library `Qhull library <http://www.qhull.org/>`__.

.. note::

Unless you pass in the Qhull option 'QJ', Qhull does not guarantee that each input point appears as a vertex in the Delaunay triangulation. Omitted points are listed in the `coplanar` attribute.

Examples -------- Triangulation of a set of points:

>>> points = np.array([0, 0], [0, 1.1], [1, 0], [1, 1]) >>> from scipy.spatial import Delaunay >>> tri = Delaunay(points)

We can plot it:

>>> import matplotlib.pyplot as plt >>> plt.triplot(points:,0, points:,1, tri.simplices) >>> plt.plot(points:,0, points:,1, 'o') >>> plt.show()

Point indices and coordinates for the two triangles forming the triangulation:

>>> tri.simplices array([2, 3, 0], # may vary [3, 1, 0], dtype=int32)

Note that depending on how rounding errors go, the simplices may be in a different order than above.

>>> pointstri.simplices array([[ 1. , 0. ], # may vary [ 1. , 1. ], [ 0. , 0. ]], [[ 1. , 1. ], [ 0. , 1.1], [ 0. , 0. ]])

Triangle 0 is the only neighbor of triangle 1, and it's opposite to vertex 1 of triangle 1:

>>> tri.neighbors1 array(-1, 0, -1, dtype=int32) >>> pointstri.simplices[1,1] array( 0. , 1.1)

We can find out which triangle points are in:

>>> p = np.array((0.1, 0.2), (1.5, 0.5), (0.5, 1.05)) >>> tri.find_simplex(p) array( 1, -1, 1, dtype=int32)

The returned integers in the array are the indices of the simplex the corresponding point is in. If -1 is returned, the point is in no simplex. Be aware that the shortcut in the following example only works corretcly for valid points as invalid points result in -1 which is itself a valid index for the last simplex in the list.

>>> p_valids = np.array((0.1, 0.2), (0.5, 1.05)) >>> tri.simplicestri.find_simplex(p_valids) array([3, 1, 0], # may vary [3, 1, 0], dtype=int32)

We can also compute barycentric coordinates in triangle 1 for these points:

>>> b = tri.transform1,:2.dot(np.transpose(p - tri.transform1,2)) >>> np.c_np.transpose(b), 1 - b.sum(axis=0) array([ 0.1 , 0.09090909, 0.80909091], [ 1.5 , -0.90909091, 0.40909091], [ 0.5 , 0.5 , 0. ])

The coordinates for the first point are all positive, meaning it is indeed inside the triangle. The third point is on a vertex, hence its null third coordinate.

val add_points : ?restart:bool -> points:[> `Ndarray ] Np.Obj.t -> [> tag ] Obj.t -> Py.Object.t

add_points(points, restart=False)

Process a set of additional new points.

Parameters ---------- points : ndarray New points to add. The dimensionality should match that of the initial points. restart : bool, optional Whether to restart processing from scratch, rather than adding points incrementally.

Raises ------ QhullError Raised when Qhull encounters an error condition, such as geometrical degeneracy when options to resolve are not enabled.

See Also -------- close

Notes ----- You need to specify ``incremental=True`` when constructing the object to be able to add points incrementally. Incremental addition of points is also not possible after `close` has been called.

val close : [> tag ] Obj.t -> Py.Object.t

close()

Finish incremental processing.

Call this to free resources taken up by Qhull, when using the incremental mode. After calling this, adding more points is no longer possible.

val find_simplex : ?bruteforce:bool -> ?tol:float -> xi:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

find_simplex(self, xi, bruteforce=False, tol=None)

Find the simplices containing the given points.

Parameters ---------- tri : DelaunayInfo Delaunay triangulation xi : ndarray of double, shape (..., ndim) Points to locate bruteforce : bool, optional Whether to only perform a brute-force search tol : float, optional Tolerance allowed in the inside-triangle check. Default is ``100*eps``.

Returns ------- i : ndarray of int, same shape as `xi` Indices of simplices containing each point. Points outside the triangulation get the value -1.

Notes ----- This uses an algorithm adapted from Qhull's ``qh_findbestfacet``, which makes use of the connection between a convex hull and a Delaunay triangulation. After finding the simplex closest to the point in N+1 dimensions, the algorithm falls back to directed search in N dimensions.

val lift_points : x:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

lift_points(self, x)

Lift points to the Qhull paraboloid.

val plane_distance : xi:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

plane_distance(self, xi)

Compute hyperplane distances to the point `xi` from all simplices.

val points : t -> Py.Object.t

Attribute points: get value or raise Not_found if None.

val points_opt : t -> Py.Object.t option

Attribute points: get value as an option.

val simplices : t -> Py.Object.t

Attribute simplices: get value or raise Not_found if None.

val simplices_opt : t -> Py.Object.t option

Attribute simplices: get value as an option.

val neighbors : t -> Py.Object.t

Attribute neighbors: get value or raise Not_found if None.

val neighbors_opt : t -> Py.Object.t option

Attribute neighbors: get value as an option.

val equations : t -> Py.Object.t

Attribute equations: get value or raise Not_found if None.

val equations_opt : t -> Py.Object.t option

Attribute equations: get value as an option.

val transform : t -> Py.Object.t

Attribute transform: get value or raise Not_found if None.

val transform_opt : t -> Py.Object.t option

Attribute transform: get value as an option.

val vertex_to_simplex : t -> Py.Object.t

Attribute vertex_to_simplex: get value or raise Not_found if None.

val vertex_to_simplex_opt : t -> Py.Object.t option

Attribute vertex_to_simplex: get value as an option.

val convex_hull : t -> Py.Object.t

Attribute convex_hull: get value or raise Not_found if None.

val convex_hull_opt : t -> Py.Object.t option

Attribute convex_hull: get value as an option.

val coplanar : t -> Py.Object.t

Attribute coplanar: get value or raise Not_found if None.

val coplanar_opt : t -> Py.Object.t option

Attribute coplanar: get value as an option.

val vertices : t -> Py.Object.t

Attribute vertices: get value or raise Not_found if None.

val vertices_opt : t -> Py.Object.t option

Attribute vertices: get value as an option.

val vertex_neighbor_vertices : t -> Py.Object.t

Attribute vertex_neighbor_vertices: get value or raise Not_found if None.

val vertex_neighbor_vertices_opt : t -> Py.Object.t option

Attribute vertex_neighbor_vertices: get value as an option.

val furthest_site : t -> Py.Object.t

Attribute furthest_site: get value or raise Not_found if None.

val furthest_site_opt : t -> Py.Object.t option

Attribute furthest_site: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.