#[repr(C, align(16))]pub struct Vector4 {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}Expand description
An owning representation of a 4-component Euclidean vector.
Like Vec4, the Vector4 object represents a Euclidean vector in
4D. Unlike the Vec4, this is an owning representation that stores the
actual content of the vector.
Fields§
§x: f32The X-component of the vector.
y: f32The Y-component of the vector.
z: f32The Z-component of the vector.
w: f32The W-component of the vector.
Implementations§
source§impl Vector4
impl Vector4
sourcepub const ZERO: Vector4 = _
pub const ZERO: Vector4 = _
A constant for a Null vector, which has magnitude 0 and exists at the origin.
sourcepub const UNIT_X: Vector4 = _
pub const UNIT_X: Vector4 = _
A constant for a unit vector in the positive X-direction.
sourcepub const UNIT_Y: Vector4 = _
pub const UNIT_Y: Vector4 = _
A constant for a unit vector in the positive Y-direction.
sourcepub const UNIT_Z: Vector4 = _
pub const UNIT_Z: Vector4 = _
A constant for a unit vector in the positive Z-direction.
sourcepub const UNIT_W: Vector4 = _
pub const UNIT_W: Vector4 = _
A constant for a unit vector in the positive W-direction.
sourcepub const NEG_UNIT_X: Vector4 = _
pub const NEG_UNIT_X: Vector4 = _
A constant for a unit vector in the negative X-direction.
sourcepub const NEG_UNIT_Y: Vector4 = _
pub const NEG_UNIT_Y: Vector4 = _
A constant for a unit vector in the negative Y-direction.
sourcepub const NEG_UNIT_Z: Vector4 = _
pub const NEG_UNIT_Z: Vector4 = _
A constant for a unit vector in the negative Z-direction.
sourcepub const NEG_UNIT_W: Vector4 = _
pub const NEG_UNIT_W: Vector4 = _
A constant for a unit vector in the negative W-direction.
sourcepub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self
Constructs this vector from an x, y, z, and w coordinate.
§Parameters
x- the x-componenty- the y-componentz- the z-componentw- the w-component
sourcepub const fn from_array(array: &[f32; 4]) -> Self
pub const fn from_array(array: &[f32; 4]) -> Self
sourcepub const fn from_slice(slice: &[f32]) -> Result<Self, VecError>
pub const fn from_slice(slice: &[f32]) -> Result<Self, VecError>
sourcepub const unsafe fn from_slice_unchecked(slice: &[f32]) -> Self
pub const unsafe fn from_slice_unchecked(slice: &[f32]) -> Self
sourcepub fn from_vec4i(other: &Vec4i) -> Self
pub fn from_vec4i(other: &Vec4i) -> Self
sourcepub fn from_vec4u(other: &Vec4u) -> Self
pub fn from_vec4u(other: &Vec4u) -> Self
Methods from Deref<Target = Vec4>§
sourcepub fn as_mut_slice(&mut self) -> &mut [f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
sourcepub fn as_mut_ptr(&mut self) -> *mut f32
pub fn as_mut_ptr(&mut self) -> *mut f32
Returns this vector as a mutable ptr of f32.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f32>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f32>
Returns a mutable iterator over the vector.
sourcepub fn x_mut(&mut self) -> &mut f32
pub fn x_mut(&mut self) -> &mut f32
Returns a mutable reference to the X-coordinate of this 3-component vector.
sourcepub fn y_mut(&mut self) -> &mut f32
pub fn y_mut(&mut self) -> &mut f32
Returns a mutable reference to the Y-coordinate of this 3-component vector.
sourcepub fn z_mut(&mut self) -> &mut f32
pub fn z_mut(&mut self) -> &mut f32
Returns a mutable reference to the Z-coordinate of this 3-component vector.
sourcepub fn w_mut(&mut self) -> &mut f32
pub fn w_mut(&mut self) -> &mut f32
Returns a mutable reference to the W-coordinate of this 3-component vector.
sourcepub fn xy_mut(&mut self) -> &mut Vec2
pub fn xy_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the xy coordinates of this vector.
sourcepub fn yz_mut(&mut self) -> &mut Vec2
pub fn yz_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn zw_mut(&mut self) -> &mut Vec2
pub fn zw_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the zw coordinates of this vector.
sourcepub fn xyz_mut(&mut self) -> &mut Vec3
pub fn xyz_mut(&mut self) -> &mut Vec3
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn yzw_mut(&mut self) -> &mut Vec3
pub fn yzw_mut(&mut self) -> &mut Vec3
Returns a mutable reference to the zw coordinates of this vector.
sourcepub fn square_magnitude(&self) -> f32
pub fn square_magnitude(&self) -> f32
Computes the square magnitude of this two-component vector.
sourcepub fn magnitude(&self) -> f32
pub fn magnitude(&self) -> f32
Computes the magnitude of this vector.
Where possible, consider using Vec4::square_magnitude as this will
avoid the need to compute the square-root.
sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Queries whether this vector is normalized (e.g. has a magnitude of 1).
sourcepub fn normalized(&self) -> Vector4
pub fn normalized(&self) -> Vector4
Returns normalized vector.
sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns whether all components of this Vec are finite.
§Example
Basic use:
let finite = Vector4::UNIT_X;
let not_finite = Vector4::new(f32::INFINITY, 3.0, 0.0, -1.0);
assert!(finite.is_finite());
assert!(!not_finite.is_finite());sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
Trait Implementations§
source§impl AddAssign<&Vec4> for Vector4
impl AddAssign<&Vec4> for Vector4
source§fn add_assign(&mut self, rhs: &Vec4)
fn add_assign(&mut self, rhs: &Vec4)
+= operation. Read moresource§impl AddAssign<&Vector4> for Vec4
impl AddAssign<&Vector4> for Vec4
source§fn add_assign(&mut self, rhs: &Vector4)
fn add_assign(&mut self, rhs: &Vector4)
+= operation. Read moresource§impl AddAssign<&Vector4> for Vector4
impl AddAssign<&Vector4> for Vector4
source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
+= operation. Read moresource§impl AddAssign<Vector4> for Vec4
impl AddAssign<Vector4> for Vec4
source§fn add_assign(&mut self, rhs: Vector4)
fn add_assign(&mut self, rhs: Vector4)
+= operation. Read moresource§impl AddAssign for Vector4
impl AddAssign for Vector4
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl BorrowMut<Vec4> for Vector4
impl BorrowMut<Vec4> for Vector4
source§fn borrow_mut(&mut self) -> &mut Vec4
fn borrow_mut(&mut self) -> &mut Vec4
source§impl DivAssign<f32> for Vector4
impl DivAssign<f32> for Vector4
source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/= operation. Read moresource§impl From<Vector4> for Quaternion
impl From<Vector4> for Quaternion
source§impl MulAssign<f32> for Vector4
impl MulAssign<f32> for Vector4
source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*= operation. Read moresource§impl PartialOrd for Vector4
impl PartialOrd for Vector4
source§impl RemAssign<f32> for Vector4
impl RemAssign<f32> for Vector4
source§fn rem_assign(&mut self, rhs: f32)
fn rem_assign(&mut self, rhs: f32)
%= operation. Read moresource§impl SubAssign<&Vec4> for Vector4
impl SubAssign<&Vec4> for Vector4
source§fn sub_assign(&mut self, rhs: &Vec4)
fn sub_assign(&mut self, rhs: &Vec4)
-= operation. Read moresource§impl SubAssign<&Vector4> for Vec4
impl SubAssign<&Vector4> for Vec4
source§fn sub_assign(&mut self, rhs: &Vector4)
fn sub_assign(&mut self, rhs: &Vector4)
-= operation. Read moresource§impl SubAssign<&Vector4> for Vector4
impl SubAssign<&Vector4> for Vector4
source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
-= operation. Read moresource§impl SubAssign<Vector4> for Vec4
impl SubAssign<Vector4> for Vec4
source§fn sub_assign(&mut self, rhs: Vector4)
fn sub_assign(&mut self, rhs: Vector4)
-= operation. Read moresource§impl SubAssign for Vector4
impl SubAssign for Vector4
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreimpl Copy for Vector4
impl StructuralPartialEq for Vector4
Auto Trait Implementations§
impl Freeze for Vector4
impl RefUnwindSafe for Vector4
impl Send for Vector4
impl Sync for Vector4
impl Unpin for Vector4
impl UnwindSafe for Vector4
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)