Spatial objects and computations based on NumPy arrays for 2D, 3D, and higher-dimensional geometric calculations.
npx @tessl/cli install tessl/pypi-scikit-spatial@9.0.0A comprehensive Python library providing spatial objects and computations based on NumPy arrays. The library enables developers to work with geometric objects and perform complex spatial calculations in 2D, 3D, and higher-dimensional spaces with robust numerical computing capabilities.
pip install scikit-spatialpip install 'scikit-spatial[plotting]'from skspatial.objects import Point, Vector, Line, Plane, PointsCommon patterns for importing spatial objects:
from skspatial.objects import (
Point, Vector, Points, Line, LineSegment,
Plane, Circle, Sphere, Triangle, Cylinder
)For measurement and transformation functions:
from skspatial.measurement import area_triangle, volume_tetrahedron, area_signed
from skspatial.transformation import transform_coordinates
from skspatial.plotting import plot_2d, plot_3dfrom skspatial.objects import Point, Vector, Line, Plane
# Create spatial objects from array-like data
point = Point([1, 2, 3])
vector = Vector([0, 1, 0])
line = Line(point=[0, 0, 0], direction=[1, 1, 0])
# Objects inherit from NumPy arrays
print(vector.size) # 3
print(vector.mean()) # 1.0
# Use specialized spatial methods
unit_vector = vector.unit()
print(unit_vector.norm()) # 1.0
# Project point onto line
projected = line.project_point([5, 6, 7])
print(projected) # Point([5.5, 5.5, 0.0])
# Create plane from three points
plane = Plane.from_points([0, 0, 0], [1, 0, 0], [0, 1, 0])
print(plane.normal) # Vector([0, 0, 1])
# Intersection operations
intersection = plane.intersect_line(line)
print(intersection) # Point([0, 0, 0])scikit-spatial is built on a foundational principle: spatial objects as NumPy arrays. Every spatial object inherits from numpy.ndarray, providing full NumPy functionality while adding specialized spatial methods. This design enables seamless integration with the NumPy ecosystem while maintaining geometric semantics.
Key Design Elements:
This architecture distinguishes scikit-spatial from symbolic geometry libraries by prioritizing numerical computation performance and NumPy ecosystem compatibility.
Fundamental building blocks including points, vectors, and collections of points. These objects form the foundation of all geometric computations and inherit full NumPy array functionality.
class Point(np.ndarray):
def __init__(self, array): ...
def distance_point(self, other) -> np.float64: ...
def plot_2d(self, ax_2d, **kwargs): ...
def plot_3d(self, ax_3d, **kwargs): ...
class Vector(np.ndarray):
def __init__(self, array): ...
@classmethod
def from_points(cls, point_a, point_b) -> 'Vector': ...
def norm(self, **kwargs) -> np.float64: ...
def unit(self) -> 'Vector': ...
def cross(self, other) -> 'Vector': ...
def angle_between(self, other) -> float: ...
class Points(np.ndarray):
def __init__(self, points): ...
def centroid(self) -> Point: ...
def are_collinear(self, **kwargs) -> bool: ...
def are_coplanar(self, **kwargs) -> bool: ...Lines, line segments, and planes with comprehensive geometric operations including projections, intersections, and distance calculations. Supports both infinite geometric objects and bounded segments.
class Line:
def __init__(self, point, direction): ...
@classmethod
def from_points(cls, point_a, point_b) -> 'Line': ...
@classmethod
def best_fit(cls, points, **kwargs) -> 'Line': ...
def project_point(self, point) -> Point: ...
def intersect_line(self, other, **kwargs) -> Point: ...
def distance_point(self, point) -> np.float64: ...
class Plane:
def __init__(self, point, normal): ...
@classmethod
def from_points(cls, point_a, point_b, point_c, **kwargs) -> 'Plane': ...
@classmethod
def best_fit(cls, points, **kwargs) -> 'Plane': ...
def intersect_line(self, line, **kwargs) -> Point: ...
def intersect_plane(self, other, **kwargs) -> Line: ...Circles, spheres, and cylinders with specialized methods for curved surface computations, intersections, and volume calculations.
class Circle:
def __init__(self, point, radius): ...
@classmethod
def from_points(cls, point_a, point_b, point_c, **kwargs) -> 'Circle': ...
def area(self) -> float: ...
def circumference(self) -> float: ...
def intersect_line(self, line) -> Tuple[Point, Point]: ...
class Sphere:
def __init__(self, point, radius): ...
def volume(self) -> float: ...
def surface_area(self) -> float: ...
def intersect_line(self, line) -> Tuple[Point, Point]: ...
class Cylinder:
def __init__(self, point, vector, radius): ...
def volume(self) -> np.float64: ...
def surface_area(self) -> np.float64: ...Standalone functions for computing geometric properties including areas, volumes, triangle analysis, and spatial relationships.
def area_triangle(point_a, point_b, point_c) -> np.float64: ...
def volume_tetrahedron(point_a, point_b, point_c, point_d) -> np.float64: ...
def area_signed(points) -> float: ...
class Triangle:
def __init__(self, point_a, point_b, point_c): ...
def area(self) -> np.float64: ...
def perimeter(self) -> np.float64: ...
def classify(self, **kwargs) -> str: ...
def is_right(self, **kwargs) -> bool: ...Coordinate system transformations and comprehensive matplotlib-based visualization support for both 2D and 3D plotting.
def transform_coordinates(points, point_origin, vectors_basis) -> np.ndarray: ...
def plot_2d(*plotters) -> Tuple: ...
def plot_3d(*plotters) -> Tuple: ...from typing import Union, Sequence, Tuple
import numpy as np
array_like = Union[np.ndarray, Sequence]