pub struct UnitVec3(/* private fields */);Expand description
A Vec3 that is normalised to unit length at construction time.
Stored as a plain Vec3 internally — the invariant is only enforced
at the construction boundary.
Implementations§
Source§impl UnitVec3
impl UnitVec3
Sourcepub fn try_from_vec(v: Vec3) -> Option<Self>
pub fn try_from_vec(v: Vec3) -> Option<Self>
Construct from a Vec3, normalising it. Returns None for zero vectors.
Sourcepub fn new_unchecked(v: Vec3) -> Self
pub fn new_unchecked(v: Vec3) -> Self
Construct without checking — caller asserts |v| ≈ 1.
§Safety
Violating the unit-length invariant leads to incorrect geometric results,
not unsound memory, so this is not unsafe in the Rust sense.
Sourcepub fn cross(self, rhs: Self) -> Vec3
pub fn cross(self, rhs: Self) -> Vec3
Cross product — result is a plain Vec3 (may not be unit length).
Sourcepub fn angle_to(self, other: Self) -> f64
pub fn angle_to(self, other: Self) -> f64
Angle between two unit vectors (radians, always in [0, π]).
Sourcepub fn perp_basis(self) -> (Self, Self)
pub fn perp_basis(self) -> (Self, Self)
Build an orthonormal basis (self, u, v) where u and v span the
plane perpendicular to self. u is arbitrary but consistent.
Trait Implementations§
impl Copy for UnitVec3
impl StructuralPartialEq for UnitVec3
Auto Trait Implementations§
impl Freeze for UnitVec3
impl RefUnwindSafe for UnitVec3
impl Send for UnitVec3
impl Sync for UnitVec3
impl Unpin for UnitVec3
impl UnsafeUnpin for UnitVec3
impl UnwindSafe for UnitVec3
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