Skip to main content

Vector4

Struct Vector4 

Source
pub struct Vector4 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}
Expand description

A vector with four single-precision components.

Fields§

§x: f32

The X component of the vector.

§y: f32

The Y component of the vector.

§z: f32

The Z component of the vector.

§w: f32

The W component of the vector.

Implementations§

Source§

impl Vector4

Source

pub const ZERO: Vector4

The vector (0, 0, 0, 0).

Source

pub const ONE: Vector4

The vector (1, 1, 1, 1).

Source

pub const UNIT_X: Vector4

The vector (1, 0, 0, 0).

Source

pub const UNIT_Y: Vector4

The vector (0, 1, 0, 0).

Source

pub const UNIT_Z: Vector4

The vector (0, 0, 1, 0).

Source

pub const UNIT_W: Vector4

The vector (0, 0, 0, 1).

Source

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

Creates a vector from its components.

Source

pub const fn from_value(value: f32) -> Self

Creates a vector whose components all have the same value.

Source

pub const fn from_vector2(value: Vector2, z: f32, w: f32) -> Self

Creates a vector from a Vector2 and the Z and W components.

Source

pub const fn from_vector3(value: Vector3, w: f32) -> Self

Creates a vector from a Vector3 and a W component.

Source

pub fn abs(value: Vector4) -> Vector4

Returns a vector whose elements are the absolute values of each of the specified vector’s elements.

Source

pub fn clamp(value1: Vector4, min: Vector4, max: Vector4) -> Vector4

Restricts a vector between a minimum and a maximum value (min(max(value, min), max), so max wins when the bounds are inverted).

Source

pub fn distance(value1: Vector4, value2: Vector4) -> f32

Computes the Euclidean distance between the two given points.

Source

pub fn distance_squared(value1: Vector4, value2: Vector4) -> f32

Returns the Euclidean distance squared between two specified points.

Source

pub fn dot(vector1: Vector4, vector2: Vector4) -> f32

Returns the dot product of two vectors.

Source

pub fn length(&self) -> f32

Returns the length of the vector.

Source

pub fn length_squared(&self) -> f32

Returns the length of the vector squared.

Source

pub fn lerp(value1: Vector4, value2: Vector4, amount: f32) -> Vector4

Performs a linear interpolation between two vectors based on the given weighting.

Source

pub fn max(value1: Vector4, value2: Vector4) -> Vector4

Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.

Source

pub fn min(value1: Vector4, value2: Vector4) -> Vector4

Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.

Source

pub fn normalize(vector: Vector4) -> Vector4

Returns a vector with the same direction as the specified vector, but with a length of one (NaN components for a zero-length vector).

Source

pub fn square_root(value: Vector4) -> Vector4

Returns a vector whose elements are the square root of each of a specified vector’s elements.

Source

pub fn transform(vector: Vector4, matrix: Matrix4x4) -> Vector4

Transforms a four-dimensional vector by a specified 4x4 matrix.

Source

pub fn transform_vector3(position: Vector3, matrix: Matrix4x4) -> Vector4

Transforms a three-dimensional vector (with an implied w of one) by a specified 4x4 matrix.

Source

pub fn transform_vector2(position: Vector2, matrix: Matrix4x4) -> Vector4

Transforms a two-dimensional vector (with an implied z of zero and w of one) by a specified 4x4 matrix.

Trait Implementations§

Source§

impl Add for Vector4

Source§

type Output = Vector4

The resulting type after applying the + operator.
Source§

fn add(self, right: Vector4) -> Vector4

Performs the + operation. Read more
Source§

impl AddAssign for Vector4

Source§

fn add_assign(&mut self, right: Vector4)

Performs the += operation. Read more
Source§

impl BatchValue for Vector4

Source§

fn write_to(&self, out: &mut Vec<u8>)

Source§

fn read_from(input: &mut BatchValueReader<'_>) -> Self

Source§

impl Clone for Vector4

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 Copy for Vector4

Source§

impl Debug for Vector4

Source§

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

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

impl Default for Vector4

Source§

fn default() -> Self

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

impl Display for Vector4

Source§

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

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

impl Div for Vector4

Source§

type Output = Vector4

The resulting type after applying the / operator.
Source§

fn div(self, right: Vector4) -> Vector4

Performs the / operation. Read more
Source§

impl Div<f32> for Vector4

Source§

type Output = Vector4

The resulting type after applying the / operator.
Source§

fn div(self, right: f32) -> Vector4

Performs the / operation. Read more
Source§

impl DivAssign for Vector4

Source§

fn div_assign(&mut self, right: Vector4)

Performs the /= operation. Read more
Source§

impl DivAssign<f32> for Vector4

Source§

fn div_assign(&mut self, right: f32)

Performs the /= operation. Read more
Source§

impl ExpressionVariantValue for Vector4

Source§

const FFI_VARIANT_TYPE: Option<VariantType>

The variant type a foreign function parameter of this type is matched against, or None when the type cannot be a foreign function parameter.
Source§

fn try_from_variant(v: &ExpressionVariant) -> Option<Self>

Source§

fn into_variant(self) -> ExpressionVariant

Source§

impl From<Vector4> for ExpressionVariant

Source§

fn from(value: Vector4) -> ExpressionVariant

Converts to this type from the input type.
Source§

impl IInterpolator<Vector4> for Vector4Interpolator

Source§

fn interpolate(&self, from: Vector4, to: Vector4, progress: f32) -> Vector4

Source§

impl Mul for Vector4

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, right: Vector4) -> Vector4

Performs the * operation. Read more
Source§

impl Mul<Vector4> for f32

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, right: Vector4) -> Vector4

Performs the * operation. Read more
Source§

impl Mul<f32> for Vector4

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, right: f32) -> Vector4

Performs the * operation. Read more
Source§

impl MulAssign for Vector4

Source§

fn mul_assign(&mut self, right: Vector4)

Performs the *= operation. Read more
Source§

impl MulAssign<f32> for Vector4

Source§

fn mul_assign(&mut self, right: f32)

Performs the *= operation. Read more
Source§

impl Neg for Vector4

Source§

type Output = Vector4

The resulting type after applying the - operator.
Source§

fn neg(self) -> Vector4

Performs the unary - operation. Read more
Source§

impl PartialEq for Vector4

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 StructuralPartialEq for Vector4

Source§

impl Sub for Vector4

Source§

type Output = Vector4

The resulting type after applying the - operator.
Source§

fn sub(self, right: Vector4) -> Vector4

Performs the - operation. Read more
Source§

impl SubAssign for Vector4

Source§

fn sub_assign(&mut self, right: Vector4)

Performs the -= operation. Read more

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> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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> PropertyValue for T
where T: Clone + PartialEq + 'static,

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 = !

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.