Skip to main content

Vec3

Struct Vec3 

Source
pub struct Vec3 {
    pub x: Fixed,
    pub y: Fixed,
    pub z: Fixed,
}
Expand description

A three-dimensional vector. See Vec2 for the contract; it is the same.

Fields§

§x: Fixed§y: Fixed§z: Fixed

Implementations§

Source§

impl Vec3

Source

pub const ZERO: Self

The origin.

Source

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

From components.

Source

pub const fn from_ints(x: i32, y: i32, z: i32) -> Self

From whole numbers.

Source

pub fn dot(self, other: Self) -> Fixed

The dot product.

Source

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

The cross product: a vector perpendicular to both.

Source

pub fn length_squared(self) -> Fixed

The squared length. See Vec2::length_squared on why to prefer it.

Source

pub fn length_squared_wide(self) -> Wide

The squared length at full width. See Vec2::length_squared_wide.

Source

pub fn length(self) -> Fixed

The length, floored. Computed through the full-width square.

Source

pub fn distance(self, other: Self) -> Fixed

The distance to another point.

Source

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

A unit vector in the same direction, or None for the zero vector. See Vec2::normalize on how close to unit the result is.

Source

pub fn lerp(self, other: Self, t: Fixed) -> Self

Linear interpolation, t clamped to [0, 1].

Source

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

self with its component along a unit normal removed.

Trait Implementations§

Source§

impl Add for Vec3

Source§

type Output = Vec3

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for Vec3

Source§

fn clone(&self) -> Vec3

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() -> Vec3

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

impl Eq for Vec3

Source§

impl Hash for Vec3

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<Fixed> for Vec3

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

fn mul(self, factor: Fixed) -> Self

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: &Vec3) -> 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 Vec3

Source§

impl Sub for Vec3

Source§

type Output = Vec3

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

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> 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, 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.