RealInterval

Struct RealInterval 

Source
pub struct RealInterval {
    pub min: f32,
    pub max: f32,
}
Expand description

Represents a closed range on the real numbers.

Fields§

§min: f32

The starting value of this range.

§max: f32

The ending value of this range.

Implementations§

Source§

impl RealInterval

Source

pub fn min_max(min: f32, max: f32) -> Self

Creates a new interval from the given minimum and maximum. The maximum must be at least as big as the minimum, or this will panic.

Source

pub fn point(value: f32) -> Self

Creates a range that contains a single point.

Source

pub fn point_extents(value: f32, half_extent: f32) -> Self

Creates a range from a point and extents around the point.

Source

pub fn contains(self, value: f32) -> bool

Determines whether the provided value lies within this interval.

Source

pub fn abs(self) -> Self

Takes the absolute value of this range.

Source

pub fn len(&self) -> f32

Provides the length of this interval.

Source

pub fn min(self, rhs: Self) -> Self

Applies the minimum function between two ranges.

Source

pub fn max(self, rhs: Self) -> Self

Applies the maximum function between two ranges.

Source

pub fn minf(self, value: f32) -> Self

Applies a scalar minimum to this range.

Source

pub fn maxf(self, value: f32) -> Self

Applies a scalar maximum to this range.

Source

pub fn powf(self, value: f32) -> Self

Applies a scalar power to this range. The interval must be non-negative.

Source

pub fn powi(self, value: i32) -> Self

Applies an integral scalar power to this range.

Source

pub fn mul_pow2(self, value: i32) -> Option<Self>

Multiplies this range by the provided integer power of 2.

Source

pub fn mul_pow2_unchecked(self, value: i32) -> Self

Multiplies this range by the provided integer power of 2 without overflow checking. This function is safe, but in the case where the exponent of either minimum or maximum has an overflow, the result is not specified.

Source

pub fn round(self) -> Self

Rounds this range to the nearest whole number.

Trait Implementations§

Source§

impl Add<f32> for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl BitAnd for RealInterval

Source§

type Output = Option<RealInterval>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitOr for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl Clone for RealInterval

Source§

fn clone(&self) -> RealInterval

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RealInterval

Source§

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

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

impl Default for RealInterval

Source§

fn default() -> RealInterval

Returns the “default value” for a type. Read more
Source§

impl Display for RealInterval

Source§

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

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

impl Mul<RealInterval> for f32

Source§

type Output = RealInterval

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: RealInterval) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: RealInterval) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for RealInterval

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub<f32> for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for RealInterval

Source§

type Output = RealInterval

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Copy for RealInterval

Source§

impl StructuralPartialEq for RealInterval

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.