Skip to main content

Vector4

Struct Vector4 

Source
pub struct Vector4 {
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub w: f64,
}
Expand description

three.js’ Vector4: an ordered quadruplet (x, y, z, w), used for points and directions in 4D space, homogeneous coordinates, and quaternion-like axis/angle packing.

Fields§

§x: f64

The x component.

§y: f64

The y component.

§z: f64

The z component.

§w: f64

The w component.

Implementations§

Source§

impl Vector4

Source

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

Constructs a new vector with the given components.

Source

pub fn width(&self) -> f64

Vector4.width — the alias Vector4 exposes for z.

Source

pub fn height(&self) -> f64

Vector4.height — the alias Vector4 exposes for w.

Source

pub fn set(&mut self, x: f64, y: f64, z: f64, w: f64) -> &mut Self

Sets the vector components.

Source

pub fn set_scalar(&mut self, scalar: f64) -> &mut Self

Vector4.setScalar().

Source

pub fn set_x(&mut self, x: f64) -> &mut Self

Sets the x component.

Source

pub fn set_y(&mut self, y: f64) -> &mut Self

Sets the y component.

Source

pub fn set_z(&mut self, z: f64) -> &mut Self

Sets the z component.

Source

pub fn set_w(&mut self, w: f64) -> &mut Self

Sets the w component.

Source

pub fn set_component(&mut self, index: usize, value: f64) -> &mut Self

Vector4.setComponent(); panics where three.js throws.

Source

pub fn get_component(&self, index: usize) -> f64

Vector4.getComponent().

Source

pub fn copy(&mut self, v: &Self) -> &mut Self

Vector4.copy(): unlike three.js, which defaults a missing v.w to 1 (it also accepts a Vector3), this always copies v.w since v is statically a Vector4.

Source

pub fn add(&mut self, v: &Self) -> &mut Self

Adds the given vector to this one.

Source

pub fn add_scalar(&mut self, s: f64) -> &mut Self

Vector4.addScalar().

Source

pub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Adds a and b, storing the result in this vector.

Source

pub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self

Vector4.addScaledVector().

Source

pub fn sub(&mut self, v: &Self) -> &mut Self

Subtracts the given vector from this one.

Source

pub fn sub_scalar(&mut self, s: f64) -> &mut Self

Vector4.subScalar().

Source

pub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Subtracts b from a, storing the result in this vector.

Source

pub fn multiply(&mut self, v: &Self) -> &mut Self

Multiplies this vector by the given vector, component-wise.

Source

pub fn multiply_scalar(&mut self, scalar: f64) -> &mut Self

Multiplies each component of this vector by the given scalar.

Source

pub fn apply_matrix4(&mut self, m: &Matrix4) -> &mut Self

Vector4.applyMatrix4().

Source

pub fn divide(&mut self, v: &Self) -> &mut Self

Divides this vector by the given vector, component-wise.

Source

pub fn divide_scalar(&mut self, scalar: f64) -> &mut Self

Vector4.divideScalar().

Source

pub fn set_axis_angle_from_quaternion(&mut self, q: &Quaternion) -> &mut Self

Vector4.setAxisAngleFromQuaternion(): xyz is the axis, w the angle.

Source

pub fn set_axis_angle_from_rotation_matrix(&mut self, m: &Matrix4) -> &mut Self

Vector4.setAxisAngleFromRotationMatrix().

Source

pub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self

Vector4.setFromMatrixPosition().

Source

pub fn min(&mut self, v: &Self) -> &mut Self

Vector4.min().

Source

pub fn max(&mut self, v: &Self) -> &mut Self

Vector4.max().

Source

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

Vector4.clamp().

Source

pub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self

Vector4.clampScalar().

Source

pub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self

Vector4.clampLength().

Source

pub fn floor(&mut self) -> &mut Self

Vector4.floor().

Source

pub fn ceil(&mut self) -> &mut Self

Vector4.ceil().

Source

pub fn round(&mut self) -> &mut Self

Vector4.round() — Math.round, which rounds half up (toward +Infinity), not half away from zero the way Rust’s f64::round does.

Source

pub fn round_to_zero(&mut self) -> &mut Self

Vector4.roundToZero() — Math.trunc.

Source

pub fn negate(&mut self) -> &mut Self

Vector4.negate().

Source

pub fn dot(&self, v: &Self) -> f64

Vector4.dot().

Source

pub fn length_sq(&self) -> f64

Vector4.lengthSq().

Source

pub fn length(&self) -> f64

Vector4.length(): the Euclidean length from (0, 0, 0, 0).

Source

pub fn manhattan_length(&self) -> f64

Vector4.manhattanLength().

Source

pub fn normalize(&mut self) -> &mut Self

Vector4.normalize(): divides by the length, or by 1 when the length is 0.

Source

pub fn set_length(&mut self, length: f64) -> &mut Self

Vector4.setLength().

Source

pub fn lerp(&mut self, v: &Self, alpha: f64) -> &mut Self

Vector4.lerp().

Source

pub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self

Vector4.lerpVectors().

Source

pub fn equals(&self, v: &Self) -> bool

Vector4.equals().

Source

pub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self

Vector4.fromArray().

Source

pub fn to_array(&self) -> [f64; 4]

Vector4.toArray().

Trait Implementations§

Source§

impl Clone for Vector4

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

new Vector4() — w defaults to 1, not 0.

Source§

impl PartialEq for Vector4

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 Vector4

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,