pub struct AlphaShape { /* private fields */ }Expand description
Alpha shape of a point set
An alpha shape is a generalization of convex hull that can represent non-convex boundaries. It is parametrized by α which controls the level of detail.
Implementations§
Source§impl AlphaShape
impl AlphaShape
Sourcepub fn new(points: &Array2<f64>, alpha: f64) -> SpatialResult<Self>
pub fn new(points: &Array2<f64>, alpha: f64) -> SpatialResult<Self>
Create a new alpha shape
§Arguments
points- The points to compute alpha shape for, shape (npoints, ndim)alpha- The alpha parameter (≥ 0)
§Returns
- A new AlphaShape instance or an error
§Examples
use scirs2_spatial::alphashapes::AlphaShape;
use scirs2_core::ndarray::array;
let points = array![
[0.0, 0.0],
[1.0, 0.0],
[1.0, 1.0],
[0.0, 1.0]
];
let alphashape = AlphaShape::new(&points, 1.0).expect("Operation failed");
let boundary = alphashape.boundary();
println!("Boundary: {:?}", boundary);Sourcepub fn multi_alpha(
points: &Array2<f64>,
alphas: &[f64],
) -> SpatialResult<Vec<Self>>
pub fn multi_alpha( points: &Array2<f64>, alphas: &[f64], ) -> SpatialResult<Vec<Self>>
Compute alpha shape for multiple alpha values efficiently
§Arguments
points- The points to compute alpha shapes foralphas- Vector of alpha values to compute
§Returns
- Vector of alpha shapes corresponding to each alpha value
§Examples
use scirs2_spatial::alphashapes::AlphaShape;
use scirs2_core::ndarray::array;
let points = array![
[0.0, 0.0],
[1.0, 0.0],
[1.0, 1.0],
[0.0, 1.0],
[0.5, 0.5]
];
let alphas = vec![0.5, 1.0, 2.0];
let shapes = AlphaShape::multi_alpha(&points, &alphas).expect("Operation failed");
for (i, shape) in shapes.iter().enumerate() {
println!("Alpha {}: {} boundary elements", alphas[i], shape.boundary().len());
}Sourcepub fn boundary(&self) -> &[Vec<usize>]
pub fn boundary(&self) -> &[Vec<usize>]
Get the boundary of the alpha shape
§Returns
- Vector of boundary faces (edges in 2D, triangles in 3D)
Sourcepub fn circumradii(&self) -> &[f64]
pub fn circumradii(&self) -> &[f64]
Get the circumradii of all simplices
Sourcepub fn measure(&self) -> SpatialResult<f64>
pub fn measure(&self) -> SpatialResult<f64>
Sourcepub fn find_optimal_alpha(
points: &Array2<f64>,
criterion: &str,
) -> SpatialResult<(f64, Self)>
pub fn find_optimal_alpha( points: &Array2<f64>, criterion: &str, ) -> SpatialResult<(f64, Self)>
Find optimal alpha value using the alpha spectrum
§Arguments
points- Input pointscriterion- Optimization criterion (“area”, “volume”, “boundary”)
§Returns
- Optimal alpha value and corresponding alpha shape
§Examples
use scirs2_spatial::alphashapes::AlphaShape;
use scirs2_core::ndarray::array;
let points = array![
[0.0, 0.0],
[1.0, 0.0],
[1.0, 1.0],
[0.0, 1.0],
[0.5, 0.5]
];
let (optimal_alpha, shape) = AlphaShape::find_optimal_alpha(&points, "area").expect("Operation failed");
println!("Optimal alpha: {}", optimal_alpha);Trait Implementations§
Source§impl Clone for AlphaShape
impl Clone for AlphaShape
Source§fn clone(&self) -> AlphaShape
fn clone(&self) -> AlphaShape
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AlphaShape
impl RefUnwindSafe for AlphaShape
impl Send for AlphaShape
impl Sync for AlphaShape
impl Unpin for AlphaShape
impl UnsafeUnpin for AlphaShape
impl UnwindSafe for AlphaShape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.