pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}Expand description
Three-dimensional single-precision vector used by the XR geometry helpers.
Coordinates use the caller’s space and units; runtime modules conventionally use metres for world-space vectors.
§Examples
use ailloli_ui_openxr::math::Vec3;
let vector = Vec3::new(1.0, 2.0, 3.0);
assert_eq!((vector.x, vector.y, vector.z), (1.0, 2.0, 3.0));Fields§
§x: f32X component.
y: f32Y component.
z: f32Z component.
Implementations§
Source§impl Vec3
impl Vec3
Sourcepub const fn new(x: f32, y: f32, z: f32) -> Self
pub const fn new(x: f32, y: f32, z: f32) -> Self
Creates a vector from its three components.
§Examples
use ailloli_ui_openxr::math::Vec3;
assert_eq!(Vec3::new(4.0, 5.0, 6.0).z, 6.0);Sourcepub fn dot(self, rhs: Self) -> f32
pub fn dot(self, rhs: Self) -> f32
Returns the scalar dot product.
§Examples
use ailloli_ui_openxr::math::Vec3;
assert_eq!(Vec3::new(1.0, 2.0, 3.0).dot(Vec3::new(4.0, 5.0, 6.0)), 32.0);Sourcepub fn cross(self, rhs: Self) -> Self
pub fn cross(self, rhs: Self) -> Self
Returns the right-handed cross product.
§Examples
use ailloli_ui_openxr::math::Vec3;
assert_eq!(Vec3::new(1.0, 0.0, 0.0).cross(Vec3::new(0.0, 1.0, 0.0)), Vec3::new(0.0, 0.0, 1.0));Sourcepub fn len_sq(self) -> f32
pub fn len_sq(self) -> f32
Returns the squared Euclidean length without a square root.
§Examples
use ailloli_ui_openxr::math::Vec3;
assert_eq!(Vec3::new(2.0, 3.0, 6.0).len_sq(), 49.0);Sourcepub fn len(self) -> f32
pub fn len(self) -> f32
Returns the Euclidean length.
§Examples
use ailloli_ui_openxr::math::Vec3;
assert_eq!(Vec3::new(3.0, 4.0, 0.0).len(), 5.0);Sourcepub fn normalize_or(self, fallback: Self) -> Self
pub fn normalize_or(self, fallback: Self) -> Self
Normalizes the vector, returning fallback only for exact zero length.
§Examples
use ailloli_ui_openxr::math::Vec3;
let fallback = Vec3::new(0.0, 0.0, -1.0);
assert_eq!(Vec3::default().normalize_or(fallback), fallback);Trait Implementations§
Source§impl AddAssign for Vec3
impl AddAssign for Vec3
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl Copy for Vec3
impl StructuralPartialEq for Vec3
Auto Trait Implementations§
impl Freeze for Vec3
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().