pub struct ProlateHyperspheroid<const N: usize> { /* private fields */ }Expand description
The prolate hyperspheroid {x : |x - a| + |x - b| <= max_cost} in R^N: every state that can
lie on a path from a to b of Euclidean length at most max_cost.
This is the informed set of Informed RRT* and BIT* (Gammell, Srinivasa and Barfoot 2014,
“Informed RRT*: Optimal sampling-based path planning focused via direct sampling of an
admissible ellipsoidal heuristic”). Its foci are a and b, its transverse diameter is
max_cost, and all conjugate diameters are sqrt(max_cost^2 - |b - a|^2).
ProlateHyperspheroid::sample maps a uniform sample of the unit ball through the
scaling diag(r_1, r_2, ..., r_2) and a rotation that takes the first axis onto b - a. A
linear map keeps the distribution uniform. The rotation is a Householder reflection rather
than the SVD of Gammell et al.: with all conjugate radii equal, only the first axis has to
be placed, and any orthogonal map that places it yields the same set.
§Examples
use rand_core::SeedableRng;
use sampling_planning::ProlateHyperspheroid;
let ellipse = ProlateHyperspheroid::new([0.0, 0.0], [4.0, 0.0], 5.0).expect("non-degenerate");
let mut rng = rand_pcg::Pcg64Mcg::seed_from_u64(1);
for _ in 0..100 {
assert!(ellipse.contains(&ellipse.sample(&mut rng)));
}Implementations§
Source§impl<const N: usize> ProlateHyperspheroid<N>
impl<const N: usize> ProlateHyperspheroid<N>
Sourcepub fn new(a: [f64; N], b: [f64; N], max_cost: f64) -> Option<Self>
pub fn new(a: [f64; N], b: [f64; N], max_cost: f64) -> Option<Self>
The hyperspheroid with foci a and b and transverse diameter max_cost.
Returns None when the set has no interior: N == 0, max_cost not finite, or
max_cost <= |b - a| (no path is that short, or only the straight segment is).
Sourcepub fn contains(&self, x: &[f64; N]) -> bool
pub fn contains(&self, x: &[f64; N]) -> bool
Whether x lies in the closed set: |x - a| + |x - b| <= max_cost.
Sourcepub fn cost_through(&self, x: &[f64; N]) -> f64
pub fn cost_through(&self, x: &[f64; N]) -> f64
The length |x - a| + |x - b| of the shortest path from a through x to b.