pub fn sample_sphere_surface(
dim: usize,
n: usize,
radius: f64,
positive: bool,
seed: u64,
) -> IgraphResult<Vec<Vec<f64>>>Expand description
Sample points uniformly from the surface of a sphere.
Generates n points uniformly distributed on the surface of a
dim-dimensional sphere of the given radius, centered at the
origin. Uses the Muller (1959) method: generate dim independent
standard normals, normalize to unit length, then scale by radius.
If positive is true, all coordinates are mapped to their
absolute values (restricting to the positive orthant).
Returns a Vec<Vec<f64>> where each inner Vec has dim elements.
§Errors
Returns InvalidArgument if:
dim < 2radius <= 0
§Examples
use rust_igraph::sample_sphere_surface;
let points = sample_sphere_surface(3, 2, 1.0, false, 42).unwrap();
assert_eq!(points.len(), 2);
assert_eq!(points[0].len(), 3);
// Each point lies on the unit sphere
for p in &points {
let r2: f64 = p.iter().map(|&x| x * x).sum();
assert!((r2 - 1.0).abs() < 1e-10);
}