Skip to main content

Vec3

Struct Vec3 

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

A three-component single-precision vector.

Fields§

§x: f32

X component.

§y: f32

Y component.

§z: f32

Z component.

Implementations§

Source§

impl Vec3

Source

pub const ZERO: Self

Zero vector.

Source

pub const ONE: Self

One on every axis.

Source

pub const X: Self

Positive X axis.

Source

pub const Y: Self

Positive Y axis.

Source

pub const Z: Self

Positive Z axis.

Source

pub const NAN: Self

NaN on every axis.

Source

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

Builds a vector.

Source

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

Builds a vector with equal components.

Source

pub const fn from_array(value: [f32; 3]) -> Self

Builds from an array.

Source

pub fn from_slice(value: &[f32]) -> Self

Builds from the first three slice entries.

Source

pub const fn to_array(&self) -> [f32; 3]

Returns components.

Source

pub fn is_finite(self) -> bool

Returns whether every component is finite.

Source

pub fn is_normalized(self) -> bool

Returns whether the length is approximately one.

Source

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

Dot product.

Source

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

Cross product.

Source

pub fn length_squared(self) -> f32

Squared length.

Source

pub fn length(self) -> f32

Length.

Source

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

Squared point distance.

Source

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

Point distance.

Source

pub fn normalize(self) -> Self

Normalized vector.

Source

pub fn normalize_or_zero(self) -> Self

Normalized vector, or zero when degenerate.

Source

pub fn try_normalize(self) -> Option<Self>

Attempts normalization.

Source

pub fn abs(self) -> Self

Componentwise absolute value.

Source

pub fn sqrt(self) -> Self

Componentwise square root.

Source

pub fn recip(self) -> Self

Componentwise reciprocal.

Source

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

Componentwise minimum.

Source

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

Componentwise maximum.

Source

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

Componentwise clamp.

Source

pub fn min_element(self) -> f32

Smallest component.

Source

pub fn max_element(self) -> f32

Largest component.

Source

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

Linear interpolation.

Source

pub fn reject_from_normalized(self, normal: Self) -> Self

Rejects this vector from a normalized direction.

Source

pub fn any_orthonormal_vector(self) -> Self

Returns a deterministic orthonormal vector.

Source

pub const fn extend(self, w: f32) -> Vec4

Appends a W component.

Trait Implementations§

Source§

impl Add for Vec3

Source§

type Output = Vec3

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Vec3

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Vec3

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 Vec3

Source§

impl Debug for Vec3

Source§

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

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

impl Default for Vec3

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Vec3

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div for Vec3

Source§

type Output = Vec3

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<f32> for Vec3

Source§

type Output = Vec3

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Vec3

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl From<&[f32; 3]> for Vec3

Source§

fn from(value: &[f32; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec3> for [f32; 3]

Source§

fn from(value: Vec3) -> Self

Converts to this type from the input type.
Source§

impl From<Vec3> for Vec3

Source§

fn from(value: Vec3) -> Self

Converts to this type from the input type.
Source§

impl From<Vec3> for Vec3

Source§

fn from(value: Vec3) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 3]> for Vec3

Source§

fn from(value: [f32; 3]) -> Self

Converts to this type from the input type.
Source§

impl Mul for Vec3

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vec3> for Quat

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vec3> for Mat3

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vec3> for f32

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f32> for Vec3

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Vec3

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl Neg for Vec3

Source§

type Output = Vec3

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Vec3

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 Pod for Vec3

Source§

impl Serialize for Vec3

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Vec3

Source§

impl Sub for Vec3

Source§

type Output = Vec3

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Vec3

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Sum for Vec3

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Zeroable for Vec3

Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl Freeze for Vec3

§

impl RefUnwindSafe for Vec3

§

impl Send for Vec3

§

impl Sync for Vec3

§

impl Unpin for Vec3

§

impl UnsafeUnpin for Vec3

§

impl UnwindSafe for Vec3

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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, 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.