pub struct RayQuad {
pub center: Vec3,
pub normal: Vec3,
pub right: Vec3,
pub up: Vec3,
pub half_width: f32,
pub half_height: f32,
}Expand description
Axis-aligned quad represented with local basis vectors.
right, up, and normal are expected to be normalized and mutually
orthogonal. Half extents use the same units as center, normally metres.
§Examples
use ailloli_ui_openxr::math::{RayQuad, Vec3};
let quad = RayQuad::new(Vec3::default(), Vec3::new(0.0, 0.0, 1.0), Vec3::new(1.0, 0.0, 0.0), Vec3::new(0.0, 1.0, 0.0), 0.5, 0.25);
assert_eq!((quad.half_width, quad.half_height), (0.5, 0.25));Fields§
§center: Vec3Quad center in world space.
normal: Vec3Front-facing unit normal.
right: Vec3Local positive-X unit vector.
up: Vec3Local positive-Y unit vector.
half_width: f32Horizontal half extent, normally in metres.
half_height: f32Vertical half extent, normally in metres.
Implementations§
Source§impl RayQuad
impl RayQuad
Sourcepub const fn new(
center: Vec3,
normal: Vec3,
right: Vec3,
up: Vec3,
half_width: f32,
half_height: f32,
) -> Self
pub const fn new( center: Vec3, normal: Vec3, right: Vec3, up: Vec3, half_width: f32, half_height: f32, ) -> Self
Creates a quad without normalizing its basis or clamping its extents.
§Examples
use ailloli_ui_openxr::math::{RayQuad, Vec3};
let quad = RayQuad::new(Vec3::default(), Vec3::new(0.0, 0.0, 1.0), Vec3::new(1.0, 0.0, 0.0), Vec3::new(0.0, 1.0, 0.0), 1.0, 0.5);
assert_eq!(quad.center, Vec3::default());Sourcepub fn intersect(&self, origin: Vec3, direction: Vec3) -> Option<QuadHit>
pub fn intersect(&self, origin: Vec3, direction: Vec3) -> Option<QuadHit>
Intersects a ray against the finite quad.
The direction is normalized, with (0, 0, -1) used for an exact zero
vector. Parallel rays, intersections behind the origin, and points beyond
the inclusive quad edges return None. Returned UV coordinates are in
[0, 1].
§Examples
use ailloli_ui_openxr::math::{RayQuad, Vec3};
let quad = RayQuad::new(Vec3::default(), Vec3::new(0.0, 0.0, 1.0), Vec3::new(1.0, 0.0, 0.0), Vec3::new(0.0, 1.0, 0.0), 0.5, 0.5);
let hit = quad.intersect(Vec3::new(0.0, 0.0, -1.0), Vec3::new(0.0, 0.0, 1.0)).unwrap();
assert_eq!((hit.u, hit.v), (0.5, 0.5));Trait Implementations§
Auto Trait Implementations§
impl Freeze for RayQuad
impl RefUnwindSafe for RayQuad
impl Send for RayQuad
impl Sync for RayQuad
impl Unpin for RayQuad
impl UnwindSafe for RayQuad
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,
§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>
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>
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