compute_centroid

Function compute_centroid 

Source
pub fn compute_centroid(
    points: &ArrayView2<'_, f64>,
    vertex_indices: &[usize],
) -> Vec<f64>
Expand description

Compute the centroid of a set of high-dimensional points

§Arguments

  • points - Input points array
  • vertex_indices - Indices of points to include in centroid calculation

§Returns

  • Vector representing the centroid coordinates

§Examples

use scirs2_spatial::convex_hull::geometry::high_dimensional::compute_centroid;
use scirs2_core::ndarray::array;

let points = array![
    [0.0, 0.0, 0.0],
    [3.0, 0.0, 0.0],
    [0.0, 3.0, 0.0],
    [0.0, 0.0, 3.0]
];
let vertices = vec![0, 1, 2, 3];

let centroid = compute_centroid(&points.view(), &vertices);
assert_eq!(centroid, vec![0.75, 0.75, 0.75]);