spheresmooth.geometry#
geometry.py — Public spherical geometry utilities for spheresmooth
This module provides the same functionality as the exported functions in the R package spheresmooth. The functions here define the public-facing API, while internal components such as gradient and penalty computations are encapsulated inside _internal.py.
Features provided:
Basic vector operations (dot, cross, norm2)
Vector/matrix normalization (normalize_lower, normalize)
Spherical distance computation (spherical_dist)
Exponential map (exp_map, identical to the R version)
Geodesic path computation (geodesic_lower, geodesic)
Piecewise geodesic construction (piecewise_geodesic)
This module works closely with smoothing.py and follows the same piecewise-geodesic structure as the original R implementation in spheresmooth.
Functions
|
Compute the cross product u × v. |
|
Compute the dot product of two vectors. |
|
Exponential map on S^2. |
|
Compute geodesic on S2 between p and q at times t ∈ [a,b]. |
|
Compute a single geodesic point on S^2 between points p and q at a specific time t ∈ [a, b]. |
|
Compute the L2 norm of a vector. |
|
Normalize a vector OR each row of a matrix. |
|
Normalize a single vector using the L2 norm. |
|
Replicates EXACT R behavior of piecewise_geodesic(): - Iterate segments j = 1..K-1 - For each segment, take t satisfying knots[j] <= t < knots[j+1] - Compute geodesic_lower for each t_sub in order - Append in the same order (rbind in R) - Does NOT reorder gamma to match global t order |
|
Spherical distance between x and y on the unit sphere: |