Skip to main content

Vector4

Struct Vector4 

Source
#[repr(C)]
pub struct Vector4 { pub x: f32, pub y: f32, pub z: f32, pub w: f32, }

Fields§

§x: f32§y: f32§z: f32§w: f32

Implementations§

Source§

impl Vector4

Source

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

Construct a new Vector4.

Source

pub fn zero() -> Self

Zero vector. (raymath Vector4Zero)

Source

pub fn one() -> Self

Vector with all components set to 1. (raymath Vector4One)

Source

pub fn add_value(self, add: f32) -> Self

Add scalar to all components. (raymath Vector4AddValue)

Source

pub fn sub_value(self, sub: f32) -> Self

Subtract scalar from all components. (raymath Vector4SubtractValue)

Source

pub fn length(self) -> f32

Vector length. (raymath Vector4Length)

Source

pub fn length_sqr(self) -> f32

Squared vector length. (raymath Vector4LengthSqr)

Source

pub fn dot(self, other: Vector4) -> f32

Dot product. (raymath Vector4DotProduct)

Source

pub fn distance(self, other: Vector4) -> f32

Distance between two vectors. (raymath Vector4Distance)

Source

pub fn distance_sqr(self, other: Vector4) -> f32

Squared distance between two vectors. (raymath Vector4DistanceSqr)

Source

pub fn scale(self, scale: f32) -> Self

Scale vector by scalar. (raymath Vector4Scale)

Source

pub fn multiply(self, other: Vector4) -> Self

Component-wise multiply. (raymath Vector4Multiply)

Source

pub fn negate(self) -> Self

Negate vector. (raymath Vector4Negate)

Source

pub fn divide(self, other: Vector4) -> Self

Component-wise divide. (raymath Vector4Divide)

Source

pub fn normalize(self) -> Self

Normalize vector. (raymath Vector4Normalize)

Source

pub fn min(self, other: Vector4) -> Self

Component-wise minimum. (raymath Vector4Min)

Source

pub fn max(self, other: Vector4) -> Self

Component-wise maximum. (raymath Vector4Max)

Source

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

Linear interpolation. (raymath Vector4Lerp)

Source

pub fn move_towards(self, target: Vector4, max_distance: f32) -> Self

Move towards target by at most maxDistance. (raymath Vector4MoveTowards)

Source

pub fn invert(self) -> Self

Invert components (1/x, 1/y, 1/z, 1/w). (raymath Vector4Invert)

Source

pub fn equals(self, other: Vector4) -> bool

Approximate equality (uses raymath epsilon). (raymath Vector4Equals)

Trait Implementations§

Source§

impl Add for Vector4

Source§

type Output = Vector4

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Vector4

Source§

fn add_assign(&mut self, rhs: Vector4)

Performs the += operation. Read more
Source§

impl Clone for Vector4

Source§

fn clone(&self) -> Vector4

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

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

impl Div for Vector4

Source§

type Output = Vector4

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl From<(f32, f32, f32, f32)> for Vector4

Source§

fn from((x, y, z, w): (f32, f32, f32, f32)) -> Self

Construct from an (x, y, z, w) tuple.

Source§

impl From<Color> for Vector4

Source§

fn from(v: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Quaternion> for Vector4

Source§

fn from(q: Quaternion) -> Self

Converts to this type from the input type.
Source§

impl From<Vector4> for Quaternion

Source§

fn from(v: Vector4) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 4]> for Vector4

Source§

fn from([x, y, z, w]: [f32; 4]) -> Self

Construct from an [x, y, z, w] array.

Source§

impl Mul for Vector4

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: 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, rhs: f32) -> Vector4

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Vector4

Source§

fn mul_assign(&mut self, rhs: 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: &Vector4) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Vector4

Source§

impl Sub for Vector4

Source§

type Output = Vector4

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Vector4

Source§

fn sub_assign(&mut self, rhs: 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> 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, 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.