Skip to main content

Vector3

Struct Vector3 

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

Fields§

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

Implementations§

Source§

impl Vector3

Source

pub const ZERO: Self

The zero vector (0, 0, 0).

Source

pub const ONE: Self

The vector (1, 1, 1).

Source

pub const X: Self

The unit vector along +X (1, 0, 0).

Source

pub const Y: Self

The unit vector along +Y (0, 1, 0).

Source

pub const Z: Self

The unit vector along +Z (0, 0, 1).

Source

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

Construct a new Vector3.

Source

pub fn zero() -> Self

Zero vector. (raymath Vector3Zero)

Source

pub fn one() -> Self

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

Source

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

Add scalar to all components. (raymath Vector3AddValue)

Source

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

Subtract scalar from all components. (raymath Vector3SubtractValue)

Source

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

Scale vector by scalar. (raymath Vector3Scale)

Source

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

Component-wise multiply. (raymath Vector3Multiply)

Source

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

Cross product. (raymath Vector3CrossProduct)

Source

pub fn perpendicular(self) -> Self

Perpendicular vector. (raymath Vector3Perpendicular)

Source

pub fn length(self) -> f32

Vector length. (raymath Vector3Length)

Source

pub fn length_sqr(self) -> f32

Squared vector length. (raymath Vector3LengthSqr)

Source

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

Dot product. (raymath Vector3DotProduct)

Source

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

Distance between two vectors. (raymath Vector3Distance)

Source

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

Squared distance between two vectors. (raymath Vector3DistanceSqr)

Source

pub fn angle(self, other: Vector3) -> f32

Angle between two vectors (radians). (raymath Vector3Angle)

Source

pub fn negate(self) -> Self

Negate vector. (raymath Vector3Negate)

Source

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

Component-wise divide. (raymath Vector3Divide)

Source

pub fn normalize(self) -> Self

Normalize vector. (raymath Vector3Normalize)

Source

pub fn project(self, other: Vector3) -> Self

Project self onto other. (raymath Vector3Project)

Source

pub fn reject(self, other: Vector3) -> Self

Reject self from other (component perpendicular to other). (raymath Vector3Reject)

Source

pub fn transform(self, mat: Matrix) -> Self

Transform by matrix. (raymath Vector3Transform)

Source

pub fn rotate_by_quaternion(self, q: Quaternion) -> Self

Rotate by quaternion. (raymath Vector3RotateByQuaternion)

Source

pub fn rotate_by_axis_angle(self, axis: Vector3, angle: f32) -> Self

Rotate by axis and angle (radians). (raymath Vector3RotateByAxisAngle)

Source

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

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

Source

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

Linear interpolation. (raymath Vector3Lerp)

Source

pub fn cubic_hermite( self, tangent1: Vector3, v2: Vector3, tangent2: Vector3, amount: f32, ) -> Self

Cubic Hermite interpolation. (raymath Vector3CubicHermite)

Source

pub fn reflect(self, normal: Vector3) -> Self

Reflect vector about normal. (raymath Vector3Reflect)

Source

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

Component-wise minimum. (raymath Vector3Min)

Source

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

Component-wise maximum. (raymath Vector3Max)

Source

pub fn barycenter(p: Vector3, a: Vector3, b: Vector3, c: Vector3) -> Self

Barycentric coordinates of point p in triangle (a, b, c). (raymath Vector3Barycenter)

Source

pub fn unproject(self, projection: Matrix, view: Matrix) -> Self

Unproject vector from screen space using projection and view matrices. (raymath Vector3Unproject)

Source

pub fn to_float_array(self) -> float3

Convert to array of floats. (raymath Vector3ToFloatV)

Source

pub fn invert(self) -> Self

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

Source

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

Clamp components between min and max vectors. (raymath Vector3Clamp)

Source

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

Clamp length between min and max scalars. (raymath Vector3ClampValue)

Source

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

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

Source

pub fn refract(self, n: Vector3, r: f32) -> Self

Refract through surface with index ratio r. (raymath Vector3Refract)

Trait Implementations§

Source§

impl Add for Vector3

Source§

type Output = Vector3

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Vector3

Source§

fn add_assign(&mut self, rhs: Vector3)

Performs the += operation. Read more
Source§

impl Clone for Vector3

Source§

fn clone(&self) -> Vector3

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

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

impl Div for Vector3

Source§

type Output = Vector3

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

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

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

Source§

impl From<[f32; 3]> for Vector3

Source§

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

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

Source§

impl Mul for Vector3

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Vector3

Source§

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

Source§

impl Sub for Vector3

Source§

type Output = Vector3

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Vector3

Source§

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