pub type Ellipsoid = Hyperellipsoid<3>;Expand description
A sphere scaled along the x, y, and z axes.
§Examples
Basic construction and methods:
use approxim::assert_relative_eq;
use hoomd_geometry::{BoundingSphereRadius, Volume, shape::Ellipsoid};
use std::f64::consts::PI;
let sphere = Ellipsoid::with_semi_axes([
2.0.try_into()?,
2.0.try_into()?,
2.0.try_into()?,
]);
let bounding_radius = sphere.bounding_sphere_radius();
let volume = sphere.volume();
assert_eq!(bounding_radius.get(), 2.0);
assert_eq!(volume, 4.0 / 3.0 * PI * 2.0_f64.powi(3));Test for intersections using Convex:
use hoomd_geometry::{Convex, IntersectsAt, shape::Ellipsoid};
use hoomd_vector::Versor;
let ellipsoid = Convex(Ellipsoid::with_semi_axes([
1.0.try_into()?,
2.0.try_into()?,
3.0.try_into()?,
]));
let q = Versor::default();
assert_eq!(
ellipsoid.intersects_at(&ellipsoid, &[0.9, 0.0, 0.0].into(), &q),
true
);
assert_eq!(
ellipsoid.intersects_at(&ellipsoid, &[1.1, 0.0, 0.0].into(), &q),
true
);
assert_eq!(
ellipsoid.intersects_at(&ellipsoid, &[0.0, 1.9, 0.0].into(), &q),
true
);
assert_eq!(
ellipsoid.intersects_at(&ellipsoid, &[0.0, 2.1, 0.0].into(), &q),
true
);Aliased Type§
pub struct Ellipsoid { /* private fields */ }