Skip to main content

ProlateHyperspheroid

Struct ProlateHyperspheroid 

Source
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>

Source

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).

Source

pub fn volume(&self) -> f64

The Lebesgue measure of the set: zeta_N r_1 r_2^(N - 1).

Source

pub fn contains(&self, x: &[f64; N]) -> bool

Whether x lies in the closed set: |x - a| + |x - b| <= max_cost.

Source

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.

Source

pub fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; N]

Draws a state uniformly from the set.

Uses N + 1 RNG draws when N is even and N + 2 when it is odd (Box-Muller pairs and one draw for the radius), plus a retry in the probability-zero case of an all-zero Gaussian vector.

Trait Implementations§

Source§

impl<const N: usize> Clone for ProlateHyperspheroid<N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Copy for ProlateHyperspheroid<N>

Source§

impl<const N: usize> Debug for ProlateHyperspheroid<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> PartialEq for ProlateHyperspheroid<N>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<const N: usize> StructuralPartialEq for ProlateHyperspheroid<N>

Auto Trait Implementations§

§

impl<const N: usize> Forget for ProlateHyperspheroid<N>

§

impl<const N: usize> Freeze for ProlateHyperspheroid<N>
where [f64; N]: Freeze, Option<[f64; N]>: Freeze,

§

impl<const N: usize> Move for ProlateHyperspheroid<N>

§

impl<const N: usize> RefUnwindSafe for ProlateHyperspheroid<N>

§

impl<const N: usize> Send for ProlateHyperspheroid<N>
where [f64; N]: Send, Option<[f64; N]>: Send,

§

impl<const N: usize> Sync for ProlateHyperspheroid<N>
where [f64; N]: Sync, Option<[f64; N]>: Sync,

§

impl<const N: usize> Unpin for ProlateHyperspheroid<N>
where [f64; N]: Unpin, Option<[f64; N]>: Unpin,

§

impl<const N: usize> UnsafeUnpin for ProlateHyperspheroid<N>

§

impl<const N: usize> UnwindSafe for ProlateHyperspheroid<N>
where [f64; N]: UnwindSafe, Option<[f64; N]>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.