pub struct Ball {
pub mid: f64,
pub rad: f64,
}Expand description
A ball: midpoint ± radius, guaranteed to contain the true value.
Invariant: rad >= 0.
Fields§
§mid: f64Midpoint of the enclosure interval.
rad: f64Radius (non-negative) of the enclosure interval.
Implementations§
Source§impl Ball
impl Ball
Sourcepub fn from_exact(x: f64) -> Ball
pub fn from_exact(x: f64) -> Ball
Construct a point ball (exact representation, radius 0).
Sourcepub fn from_interval(lo: f64, hi: f64) -> Option<Ball>
pub fn from_interval(lo: f64, hi: f64) -> Option<Ball>
Construct a ball from a closed interval [lo, hi].
Returns None when lo > hi.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true when the ball represents a valid enclosure (rad >= 0).
Sourcepub fn add(&self, other: &Ball) -> Ball
pub fn add(&self, other: &Ball) -> Ball
Add two balls, propagating the enclosure guarantee.
[a±r_a] + [b±r_b] = [a+b ± (r_a + r_b + fp_rounding)]
Sourcepub fn mul(&self, other: &Ball) -> Ball
pub fn mul(&self, other: &Ball) -> Ball
Multiply two balls using the interval arithmetic rule.
Multiplication error bound:
|a*b - mid_a*mid_b| <= |mid_a|*r_b + |mid_b|*r_a + r_a*r_b
plus floating-point rounding of the midpoint product.
Sourcepub fn div(&self, other: &Ball) -> Option<Ball>
pub fn div(&self, other: &Ball) -> Option<Ball>
Divide two balls. Returns None when the divisor ball contains 0.
Trait Implementations§
impl Copy for Ball
impl StructuralPartialEq for Ball
Auto Trait Implementations§
impl Freeze for Ball
impl RefUnwindSafe for Ball
impl Send for Ball
impl Sync for Ball
impl Unpin for Ball
impl UnsafeUnpin for Ball
impl UnwindSafe for Ball
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ClosedNeg for Twhere
T: Neg<Output = T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.