Skip to main content

Crate stripack

Crate stripack 

Source
Expand description

§STRIPACK

Delaunay Triangulation on the Unit Sphere.

A safe Rust wrapper for the STRIPACK library, providing Delaunay triangulation of points distributed on the surface of a unit sphere.

§Overview

This crate provides algorithms for creating and manipulating Delaunay triangulations on spherical surfaces. A Delaunay triangulation maximizes the minimum angle of all triangles, making it optimal for interpolation and nearest-neighbor queries.

§Features

  • Triangulation Construction: Build Delaunay triangulations from sets of points on the unit sphere
  • Dynamic Operations: Add or remove nodes while maintaining the Delaunay property
  • Triangle Mesh Extraction: Get triangle indices, neighbor information, and edge data
  • Voronoi Diagrams: Generate Voronoi cells (dual of Delaunay triangulation)
  • Point Location: Find which triangle contains a given point
  • Nearest Neighbor Queries: Find the k-nearest nodes to any point or node
  • Boundary Detection: Identify boundary nodes for hemispherical data sets
  • Geometric Utilities: Circumcenters, spherical triangle areas, coordinate conversions

§Quick Start

use stripack::DelaunayTriangulation;

// Create triangulation from unit vectors
let x = vec![1.0, 0.0, 0.0, 0.0];
let y = vec![0.0, 1.0, 0.0, 0.0];
let z = vec![0.0, 0.0, 1.0, 1.0];

let triangulation = DelaunayTriangulation::new(x, y, z)?;

// Extract triangle mesh
let mesh = triangulation.triangle_mesh()?;

// Find nearest node to a point
let nearest = triangulation.nearest_node(&[1.0, 0.0, 0.0], 0)?;

§Main Types

  • DelaunayTriangulation: The primary structure representing a triangulation
  • MeshData: Triangle mesh with indices, neighbors, and positions
  • VoronoiCell: Circumcenter and radius information for Voronoi diagrams
  • LocationInfo: Result of point location queries
  • NearestNode: Index and distance for nearest neighbor queries

§Safety

This crate provides a memory-safe wrapper around the STRIPACK Fortran library. All FFI calls are encapsulated and exposed through a safe, idiomatic Rust API.

§Coordinate Systems

Points must lie on the unit sphere (x² + y² + z² = 1). Helper functions are provided for converting between Cartesian and spherical coordinates.

§Performance

Expected O(N log N) time complexity for construction with randomly ordered nodes. Worst case O(N²) if nodes are ordered (e.g., by latitude).

§See Also

Structs§

BoundaryInfo
The boundary nodes for a triangulation.
DelaunayTriangulation
A Delaunay triangulation on the unit sphere.
MeshData
The mesh data for the triangulation.
NearestNode
Information about the nearest node
NodeDeletionInfo
The information related to the new triangulation created by deleting a node.
SphericalCoordinates
Coordinates on a sphere.
VoronoiCell
Information about a Voronoi cell.

Enums§

AddNodeError
CircumcenterError
DeleteNodeError
ForceAdjacentError
InsideError
LocationInfo
NearestNodeError
TriangleMeshError
TriangulationError
VoronoiCellError

Functions§

arc_cosine
Computes the arc cosine with input truncated in the range [-1, 1].
areas
Computes the areas of a spherical triangle on the unit sphere.
cartesian_coordinates
Transform spherical coordinates into Cartesian coordinates.
circumcenter
Returns the circumcenter of a spherical triangle.
spherical_coordinates
Converts from Cartesian to spherical coordinates (latitude, longitude, radius).