Skip to main content

Vector3

Struct Vector3 

Source
#[repr(C)]
pub struct Vector3 { pub x: f32, pub y: f32, pub z: f32, }
Expand description

A vector with three single-precision components.

The layout is the one of the reference runtime and is relied on when the value is passed to a graphics API by address (as a vertex attribute, for example): three consecutive singles, x, y, z.

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.

Implementations§

Source§

impl Vector3

Source

pub const ZERO: Vector3

The vector (0, 0, 0).

Source

pub const ONE: Vector3

The vector (1, 1, 1).

Source

pub const UNIT_X: Vector3

The vector (1, 0, 0).

Source

pub const UNIT_Y: Vector3

The vector (0, 1, 0).

Source

pub const UNIT_Z: Vector3

The vector (0, 0, 1).

Source

pub const fn new(x: f32, y: f32, z: 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) -> Self

Creates a vector from a Vector2 and a Z component.

Source

pub fn abs(value: Vector3) -> Vector3

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

Source

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

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 cross(vector1: Vector3, vector2: Vector3) -> Vector3

Computes the cross product of two vectors.

Source

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

Computes the Euclidean distance between the two given points.

Source

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

Returns the Euclidean distance squared between two specified points.

Source

pub fn dot(vector1: Vector3, vector2: Vector3) -> 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: Vector3, value2: Vector3, amount: f32) -> Vector3

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

Source

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

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

Source

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

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

Source

pub fn normalize(value: Vector3) -> Vector3

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: Vector3) -> Vector3

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

Source

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

Transforms a vector by a specified 4x4 matrix.

Source

pub fn transform_quaternion(value: Vector3, rotation: Quaternion) -> Vector3

Transforms a vector by the specified rotation.

Source

pub fn transform_normal(normal: Vector3, matrix: Matrix4x4) -> Vector3

Transforms a vector normal by the given 4x4 matrix.

Trait Implementations§

Source§

impl Add for Vector3

Source§

type Output = Vector3

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Vector3

Source§

fn add_assign(&mut self, right: Vector3)

Performs the += operation. Read more
Source§

impl BatchValue for Vector3

Source§

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

Source§

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

Source§

impl Clone for Vector3

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 Vector3

Source§

impl Debug for Vector3

Source§

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

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

impl Default for Vector3

Source§

fn default() -> Self

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

impl Display for Vector3

Source§

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

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

impl Div for Vector3

Source§

type Output = Vector3

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<f32> for Vector3

Source§

type Output = Vector3

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign for Vector3

Source§

fn div_assign(&mut self, right: Vector3)

Performs the /= operation. Read more
Source§

impl DivAssign<f32> for Vector3

Source§

fn div_assign(&mut self, right: f32)

Performs the /= operation. Read more
Source§

impl ExpressionVariantValue for Vector3

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<Vector3> for Vector3D

The widening conversion to the double-precision vector.

Source§

fn from(value: Vector3) -> Vector3D

Converts to this type from the input type.
Source§

impl From<Vector3> for ExpressionVariant

Source§

fn from(value: Vector3) -> ExpressionVariant

Converts to this type from the input type.
Source§

impl From<Vector3D> for Vector3

The narrowing conversion of the double-precision vector.

Source§

fn from(value: Vector3D) -> Vector3

Converts to this type from the input type.
Source§

impl IInterpolator<Vector3> for Vector3Interpolator

Source§

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

Source§

impl Mul for Vector3

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vector3> for f32

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f32> for Vector3

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign for Vector3

Source§

fn mul_assign(&mut self, right: Vector3)

Performs the *= operation. Read more
Source§

impl MulAssign<f32> for Vector3

Source§

fn mul_assign(&mut self, right: f32)

Performs the *= operation. Read more
Source§

impl Neg for Vector3

Source§

type Output = Vector3

The resulting type after applying the - operator.
Source§

fn neg(self) -> Vector3

Performs the unary - operation. Read more
Source§

impl PartialEq for Vector3

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 Vector3

Source§

impl Sub for Vector3

Source§

type Output = Vector3

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Vector3

Source§

fn sub_assign(&mut self, right: Vector3)

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.