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: f64The x component.
y: f64The y component.
z: f64The z component.
w: f64The w component.
Implementations§
Source§impl Vector4
impl Vector4
Sourcepub const fn new(x: f64, y: f64, z: f64, w: f64) -> Self
pub const fn new(x: f64, y: f64, z: f64, w: f64) -> Self
Constructs a new vector with the given components.
Sourcepub fn set_scalar(&mut self, scalar: f64) -> &mut Self
pub fn set_scalar(&mut self, scalar: f64) -> &mut Self
Vector4.setScalar().
Sourcepub fn set_component(&mut self, index: usize, value: f64) -> &mut Self
pub fn set_component(&mut self, index: usize, value: f64) -> &mut Self
Vector4.setComponent(); panics where three.js throws.
Sourcepub fn get_component(&self, index: usize) -> f64
pub fn get_component(&self, index: usize) -> f64
Vector4.getComponent().
Sourcepub fn copy(&mut self, v: &Self) -> &mut Self
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.
Sourcepub fn add_scalar(&mut self, s: f64) -> &mut Self
pub fn add_scalar(&mut self, s: f64) -> &mut Self
Vector4.addScalar().
Sourcepub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Adds a and b, storing the result in this vector.
Sourcepub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self
pub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self
Vector4.addScaledVector().
Sourcepub fn sub_scalar(&mut self, s: f64) -> &mut Self
pub fn sub_scalar(&mut self, s: f64) -> &mut Self
Vector4.subScalar().
Sourcepub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Subtracts b from a, storing the result in this vector.
Sourcepub fn multiply(&mut self, v: &Self) -> &mut Self
pub fn multiply(&mut self, v: &Self) -> &mut Self
Multiplies this vector by the given vector, component-wise.
Sourcepub fn multiply_scalar(&mut self, scalar: f64) -> &mut Self
pub fn multiply_scalar(&mut self, scalar: f64) -> &mut Self
Multiplies each component of this vector by the given scalar.
Sourcepub fn apply_matrix4(&mut self, m: &Matrix4) -> &mut Self
pub fn apply_matrix4(&mut self, m: &Matrix4) -> &mut Self
Vector4.applyMatrix4().
Sourcepub fn divide(&mut self, v: &Self) -> &mut Self
pub fn divide(&mut self, v: &Self) -> &mut Self
Divides this vector by the given vector, component-wise.
Sourcepub fn divide_scalar(&mut self, scalar: f64) -> &mut Self
pub fn divide_scalar(&mut self, scalar: f64) -> &mut Self
Vector4.divideScalar().
Sourcepub fn set_axis_angle_from_quaternion(&mut self, q: &Quaternion) -> &mut Self
pub fn set_axis_angle_from_quaternion(&mut self, q: &Quaternion) -> &mut Self
Vector4.setAxisAngleFromQuaternion(): xyz is the axis, w the angle.
Sourcepub fn set_axis_angle_from_rotation_matrix(&mut self, m: &Matrix4) -> &mut Self
pub fn set_axis_angle_from_rotation_matrix(&mut self, m: &Matrix4) -> &mut Self
Vector4.setAxisAngleFromRotationMatrix().
Sourcepub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self
pub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self
Vector4.setFromMatrixPosition().
Sourcepub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self
pub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self
Vector4.clampScalar().
Sourcepub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self
pub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self
Vector4.clampLength().
Sourcepub fn round(&mut self) -> &mut Self
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.
Sourcepub fn round_to_zero(&mut self) -> &mut Self
pub fn round_to_zero(&mut self) -> &mut Self
Vector4.roundToZero() — Math.trunc.
Sourcepub fn manhattan_length(&self) -> f64
pub fn manhattan_length(&self) -> f64
Vector4.manhattanLength().
Sourcepub fn normalize(&mut self) -> &mut Self
pub fn normalize(&mut self) -> &mut Self
Vector4.normalize(): divides by the length, or by 1 when the length
is 0.
Sourcepub fn set_length(&mut self, length: f64) -> &mut Self
pub fn set_length(&mut self, length: f64) -> &mut Self
Vector4.setLength().
Sourcepub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self
pub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self
Vector4.lerpVectors().
Sourcepub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
pub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
Vector4.fromArray().