Module properties

Module properties 

Source
Expand description

Convex hull properties and analysis

This module provides functions to compute various geometric properties of convex hulls, including volume, surface area, and point containment testing.

§Module Organization

  • volume - Volume/area/length calculations for different dimensions
  • surface_area - Surface area/perimeter calculations and compactness measures
  • containment - Point-in-hull testing and distance calculations

§Examples

§Volume Calculations

use scirs2_spatial::convex_hull::ConvexHull;
use scirs2_spatial::convex_hull::properties::volume::compute_volume;
use scirs2_core::ndarray::array;

// 2D square with area 1
let points = array![[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]];
let hull = ConvexHull::new(&points.view()).expect("Operation failed");
let area = compute_volume(&hull).expect("Operation failed");
assert!((area - 1.0).abs() < 1e-10);

§Surface Area Calculations

use scirs2_spatial::convex_hull::ConvexHull;
use scirs2_spatial::convex_hull::properties::surface_area::{compute_surface_area, compute_compactness};
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 hull = ConvexHull::new(&points.view()).expect("Operation failed");

let perimeter = compute_surface_area(&hull).expect("Operation failed");
assert!((perimeter - 4.0).abs() < 1e-10);

let compactness = compute_compactness(&hull).expect("Operation failed");
assert!(compactness > 0.7); // Square is fairly compact

§Point Containment Testing

use scirs2_spatial::convex_hull::ConvexHull;
use scirs2_spatial::convex_hull::properties::containment::{check_point_containment, distance_to_hull};
use scirs2_core::ndarray::array;

let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]];
let hull = ConvexHull::new(&points.view())?;

// Test containment
assert!(check_point_containment(&hull, &[0.1, 0.1])?);
assert!(!check_point_containment(&hull, &[2.0, 2.0])?);

// Compute distance
let dist = distance_to_hull(&hull, &[0.5, 0.5])?;
assert!(dist < 0.0); // Inside the hull

§Combined Analysis

use scirs2_spatial::convex_hull::ConvexHull;
use scirs2_spatial::convex_hull::properties::*;
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 hull = ConvexHull::new(&points.view()).expect("Operation failed");

let vol = volume::compute_volume(&hull).expect("Operation failed");
let area = surface_area::compute_surface_area(&hull).expect("Operation failed");
let ratio = surface_area::compute_surface_to_volume_ratio(&hull).expect("Operation failed");
let compactness = surface_area::compute_compactness(&hull).expect("Operation failed");

println!("Volume: {}, Surface Area: {}, Ratio: {}, Compactness: {}",
         vol, area, ratio, compactness);

Re-exports§

pub use volume::compute_volume;
pub use volume::compute_volume_bounds;
pub use volume::compute_volume_monte_carlo;
pub use volume::is_volume_computation_reliable;
pub use surface_area::compute_compactness;
pub use surface_area::compute_surface_area;
pub use surface_area::compute_surface_area_bounds;
pub use surface_area::compute_surface_to_volume_ratio;
pub use surface_area::is_surface_area_computation_reliable;
pub use containment::check_multiple_containment;
pub use containment::check_point_containment;
pub use containment::distance_to_hull;

Modules§

containment
Point containment testing for convex hulls
surface_area
Surface area computation for convex hulls
volume
Volume computation for convex hulls

Structs§

HullAnalysis
Comprehensive hull analysis results
HullStatistics
Get geometric statistics for a convex hull

Functions§

analyze_hull
Perform comprehensive analysis of a convex hull
get_hull_statistics
Get geometric statistics for a convex hull