shadermath

Struct Float2

Source
pub struct Float2 {
    pub x: f32,
    pub y: f32,
}
Expand description

Vector containing 2 floating point values.

Fields§

§x: f32

The x-component of the vector.

§y: f32

The y-component of the vector.

Implementations§

Source§

impl Float2

Source

pub fn new(x: f32, y: f32) -> Self

Creates a vector from 2 floating point values.

Source

pub fn abs(&self) -> Self

Computes the per-component absolute numbers.

Source

pub fn acos(&self) -> Self

Computes the per-component arccosine numbers (in radians). Each component should be a value within the range of -1 to 1. Return values are in the range 0, pi or NaN if the number is outside the range -1 to 1.

Source

pub fn all(&self) -> bool

Determines if all components of the vector are non-zero.

Source

pub fn any(&self) -> bool

Determines if any components of the vector are non-zero.

Source

pub fn asin(&self) -> Self

Computes the per-component arcsine numbers (in radians). Each component should be a value within the range of -1 to 1. Return values are in the range -pi/2 to pi/2 or NaN if the number is outside the range -1 to 1.

Source

pub fn atan(&self) -> Self

Computes the per-component arctangent numbers (in radians). Return values are in the range -pi/2 to pi/2.

Source

pub fn atan2(&self) -> f32

Computes the four quadrant arctangent of y and x (in radians).

Source

pub fn ceil(&self) -> Self

Computes the per-component smallest integers greater than or equal to self.x and self.y respectively.

Source

pub fn clamp(&self, min: f32, max: f32) -> Self

Computes the per-component clamped numbers between min and max.

Source

pub fn cos(&self) -> Self

Computes the per-component cosine numbers (in radians).

Source

pub fn cosh(&self) -> Self

Computes the per-component hyperbolic cosine numbers.

Source

pub fn degrees(&self) -> Self

Converts the per-component numbers from radians to degrees.

Source

pub fn distance(&self, rhs: &Self) -> f32

Computes the distance scalar between two vectors.

Source

pub fn dot(&self, rhs: &Self) -> f32

Computes the dot product of two vectors.

Source

pub fn exp(&self) -> Self

Computes the per-component e^(self), the exponential function.

Source

pub fn exp2(&self) -> Self

Computes the per-component 2^(self).

Source

pub fn floor(&self) -> Self

Computes the per-component largest integers less than or equal to self.x and self.y respectively.

Source

pub fn fmod(&self, rhs: &Self) -> Self

Computes the floating-point remainder of division for each component.

Source

pub fn frac(&self) -> Self

Computes the fractional (or decimal) part of each component; which is greater than or equal to 0 and less than 1.

Source

pub fn ldexp(&self, exponent: &Self) -> Self

Computes value * 2^exponent for each component of the vector.

Source

pub fn length(&self) -> f32

Computes the length scalar between two vectors.

Source

pub fn lerp(&self, rhs: &Self, t: f32) -> Self

Computes a linear interpolation between two vectors.

Source

pub fn log(&self) -> Self

Computes the natural logarithm (base e) of each component of the vector.

Source

pub fn log10(&self) -> Self

Computes the natural logarithm (base 10) of each component of the vector.

Source

pub fn log2(&self) -> Self

Computes the natural logarithm (base 2) of each component of the vector.

Source

pub fn mad(&self, b: &Self, c: &Self) -> Self

Computes the multiply-add operation: (self * b) + c.

Source

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

Computes the component-wise maximum of two vectors.

Source

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

Computes the component-wise minimum of two vectors.

Source

pub fn normalize(&self) -> Self

Computes the normalized vector (unit vector) of self.

Source

pub fn pow(&self, exponent: f32) -> Self

Computes the component-wise power: self^exponent.

Source

pub fn radians(&self) -> Self

Converts the per-component numbers from degrees to radians.

Source

pub fn rcp(&self) -> Self

Computes the reciprocal of each component of the vector. Equivalent to 1 / self.

Source

pub fn rcp_safe(&self) -> Self

Computes the reciprocal of each component of the vector. Equivalent to 1 / self and returning 0 when self is 0.

Source

pub fn reflect(&self, normal: &Self) -> Self

Computes the reflection of an incident vector self about a normal vector normal.

Source

pub fn refract(&self, normal: &Self, eta: f32) -> Self

Computes the refraction vector for the given incident vector, normal, and refraction index.

Source

pub fn round(&self) -> Self

Rounds each component of the vector to the nearest integer.

Source

pub fn rsqrt(&self) -> Self

Computes the reciprocal square root of each component of the vector.

Source

pub fn saturate(&self) -> Self

Clamps each component of the vector to the range [0, 1].

Source

pub fn sign(&self) -> Self

Computes the sign of each component of the vector.

Source

pub fn sin(&self) -> Self

Computes the per-component sine numbers (in radians).

Source

pub fn sinh(&self) -> Self

Computes the per-component hyperbolic sine numbers.

Source

pub fn smoothstep(&self, min: &Self, max: &Self) -> Self

Performs smoothstep interpolation on each component of the vector.

Source

pub fn sqrt(&self) -> Self

Computes the square root of each component of the vector.

Source

pub fn step(&self, edge: &Self) -> Self

Computes the component-wise step function. For each component: returns 0.0 if self < edge, else returns 1.0.

Source

pub fn tan(&self) -> Self

Computes the per-component tangent numbers (in radians).

Source

pub fn tanh(&self) -> Self

Computes the per-component hyperbolic tangent numbers.

Source

pub fn trunc(&self) -> Self

Truncates each component of the vector to its integer portion.

Source

pub fn xx(&self) -> Float2

Returns a swizzled vector.

Source

pub fn xy(&self) -> Float2

Returns a swizzled vector.

Source

pub fn yx(&self) -> Float2

Returns a swizzled vector.

Source

pub fn yy(&self) -> Float2

Returns a swizzled vector.

Source

pub fn xxx(&self) -> Float3

Returns a swizzled vector.

Source

pub fn xxy(&self) -> Float3

Returns a swizzled vector.

Source

pub fn xyx(&self) -> Float3

Returns a swizzled vector.

Source

pub fn xyy(&self) -> Float3

Returns a swizzled vector.

Source

pub fn yxx(&self) -> Float3

Returns a swizzled vector.

Source

pub fn yxy(&self) -> Float3

Returns a swizzled vector.

Source

pub fn yyx(&self) -> Float3

Returns a swizzled vector.

Source

pub fn yyy(&self) -> Float3

Returns a swizzled vector.

Source

pub fn xxxx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xxxy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xxyx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xxyy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xyxx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xyxy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xyyx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn xyyy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yxxx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yxxy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yxyx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yxyy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yyxx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yyxy(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yyyx(&self) -> Float4

Returns a swizzled vector.

Source

pub fn yyyy(&self) -> Float4

Returns a swizzled vector.

Trait Implementations§

Source§

impl Add<f32> for Float2

Source§

type Output = Float2

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for Float2

Source§

type Output = Float2

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<f32> for Float2

Source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
Source§

impl AddAssign for Float2

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Float2

Source§

fn clone(&self) -> Float2

Returns a copy 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 Float2

Source§

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

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

impl Display for Float2

Source§

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

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

impl Div<f32> for Float2

Source§

type Output = Float2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self

Performs the / operation. Read more
Source§

impl Div for Float2

Source§

type Output = Float2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Float2

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl DivAssign for Float2

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl From<(f32, f32)> for Float2

Source§

fn from(lhs: (f32, f32)) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Float2

Source§

fn from(lhs: f32) -> Self

Converts to this type from the input type.
Source§

impl Mul<f32> for Float2

Source§

type Output = Float2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for Float2

Source§

type Output = Float2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Float2

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl MulAssign for Float2

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl Neg for Float2

Source§

type Output = Float2

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Float2

Source§

fn eq(&self, rhs: &Self) -> 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 Float2

Source§

type Output = Float2

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Float2

Source§

type Output = Float2

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign<f32> for Float2

Source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
Source§

impl SubAssign for Float2

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for Float2

Auto Trait Implementations§

§

impl Freeze for Float2

§

impl RefUnwindSafe for Float2

§

impl Send for Float2

§

impl Sync for Float2

§

impl Unpin for Float2

§

impl UnwindSafe for Float2

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.