#[repr(C)]pub struct Vector4<T> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
}Expand description
A 4D vector with x, y, z, and w components.
Often used for homogeneous coordinates in 3D graphics.
§Examples
use rs_math3d::vector::Vector4;
let v = Vector4::new(1.0, 2.0, 3.0, 1.0);
// w=1 for positions, w=0 for directionsFields§
§x: TX component.
y: TY component.
z: TZ component.
w: TW component.
Implementations§
Trait Implementations§
Source§impl<T: FloatScalar> FloatVector<T> for Vector4<T>
impl<T: FloatScalar> FloatVector<T> for Vector4<T>
Source§fn distance(l: &Self, r: &Self) -> T
fn distance(l: &Self, r: &Self) -> T
Computes the Euclidean distance between two vectors. Read more
Source§fn length_squared(&self) -> T
fn length_squared(&self) -> T
Computes the squared length (avoids a square root). Read more
Source§fn try_normalize(&self, epsilon: T) -> Option<Self>
fn try_normalize(&self, epsilon: T) -> Option<Self>
Returns a normalized vector or
None when the length is too small.Source§fn normalize_or_zero(&self, epsilon: T) -> Self
fn normalize_or_zero(&self, epsilon: T) -> Self
Returns a normalized vector or the zero vector when too small.
Source§fn normalize_with_inv_len(&self, inv_len: T) -> Self
fn normalize_with_inv_len(&self, inv_len: T) -> Self
Normalizes using a precomputed inverse length (e.g., from rsqrt).
Source§fn try_normalize_with_inv_len(
&self,
len_sq: T,
inv_len: T,
epsilon: T,
) -> Option<Self>
fn try_normalize_with_inv_len( &self, len_sq: T, inv_len: T, epsilon: T, ) -> Option<Self>
Normalizes with precomputed length squared and inverse length.
Source§impl<T: Scalar> Vector<T> for Vector4<T>
impl<T: Scalar> Vector<T> for Vector4<T>
impl<T: Copy> Copy for Vector4<T>
Auto Trait Implementations§
impl<T> Freeze for Vector4<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector4<T>where
T: RefUnwindSafe,
impl<T> Send for Vector4<T>where
T: Send,
impl<T> Sync for Vector4<T>where
T: Sync,
impl<T> Unpin for Vector4<T>where
T: Unpin,
impl<T> UnwindSafe for Vector4<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more