__init__.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. """
  2. =============================================================
  3. Spatial algorithms and data structures (:mod:`scipy.spatial`)
  4. =============================================================
  5. .. currentmodule:: scipy.spatial
  6. Spatial Transformations
  7. =======================
  8. Contained in the `scipy.spatial.transform` submodule.
  9. Nearest-neighbor Queries
  10. ========================
  11. .. autosummary::
  12. :toctree: generated/
  13. KDTree -- class for efficient nearest-neighbor queries
  14. cKDTree -- class for efficient nearest-neighbor queries (faster impl.)
  15. Rectangle
  16. Distance metrics are contained in the :mod:`scipy.spatial.distance` submodule.
  17. Delaunay Triangulation, Convex Hulls and Voronoi Diagrams
  18. =========================================================
  19. .. autosummary::
  20. :toctree: generated/
  21. Delaunay -- compute Delaunay triangulation of input points
  22. ConvexHull -- compute a convex hull for input points
  23. Voronoi -- compute a Voronoi diagram hull from input points
  24. SphericalVoronoi -- compute a Voronoi diagram from input points on the surface of a sphere
  25. HalfspaceIntersection -- compute the intersection points of input halfspaces
  26. Plotting Helpers
  27. ================
  28. .. autosummary::
  29. :toctree: generated/
  30. delaunay_plot_2d -- plot 2-D triangulation
  31. convex_hull_plot_2d -- plot 2-D convex hull
  32. voronoi_plot_2d -- plot 2-D voronoi diagram
  33. .. seealso:: :ref:`Tutorial <qhulltutorial>`
  34. Simplex representation
  35. ======================
  36. The simplices (triangles, tetrahedra, ...) appearing in the Delaunay
  37. tessellation (N-dim simplices), convex hull facets, and Voronoi ridges
  38. (N-1 dim simplices) are represented in the following scheme::
  39. tess = Delaunay(points)
  40. hull = ConvexHull(points)
  41. voro = Voronoi(points)
  42. # coordinates of the j-th vertex of the i-th simplex
  43. tess.points[tess.simplices[i, j], :] # tessellation element
  44. hull.points[hull.simplices[i, j], :] # convex hull facet
  45. voro.vertices[voro.ridge_vertices[i, j], :] # ridge between Voronoi cells
  46. For Delaunay triangulations and convex hulls, the neighborhood
  47. structure of the simplices satisfies the condition:
  48. ``tess.neighbors[i,j]`` is the neighboring simplex of the i-th
  49. simplex, opposite to the j-vertex. It is -1 in case of no
  50. neighbor.
  51. Convex hull facets also define a hyperplane equation::
  52. (hull.equations[i,:-1] * coord).sum() + hull.equations[i,-1] == 0
  53. Similar hyperplane equations for the Delaunay triangulation correspond
  54. to the convex hull facets on the corresponding N+1 dimensional
  55. paraboloid.
  56. The Delaunay triangulation objects offer a method for locating the
  57. simplex containing a given point, and barycentric coordinate
  58. computations.
  59. Functions
  60. ---------
  61. .. autosummary::
  62. :toctree: generated/
  63. tsearch
  64. distance_matrix
  65. minkowski_distance
  66. minkowski_distance_p
  67. procrustes
  68. """
  69. from __future__ import division, print_function, absolute_import
  70. from .kdtree import *
  71. from .ckdtree import *
  72. from .qhull import *
  73. from ._spherical_voronoi import SphericalVoronoi
  74. from ._plotutils import *
  75. from ._procrustes import procrustes
  76. from . import transform
  77. __all__ = [s for s in dir() if not s.startswith('_')]
  78. __all__ += ['distance']
  79. from . import distance
  80. from scipy._lib._testutils import PytestTester
  81. test = PytestTester(__name__)
  82. del PytestTester