pub struct PlaneFrame { /* private fields */ }Expand description
An origin and a right-handed orthonormal pair of in-plane axes.
§Invariant
A PlaneFrame that exists is orthonormal within the tolerance it was
built with. project and lift are exact
inverses on that basis, so the type cannot be used to produce the silently
wrong coordinates a skewed basis yields.
The fields are private precisely because the invariant is the point: a
public x would let a caller reassign one axis and keep the type.
Implementations§
Source§impl PlaneFrame
impl PlaneFrame
Sourcepub const fn ground() -> PlaneFrame
pub const fn ground() -> PlaneFrame
The z = 0 ground plane with the world x and y axes.
Sourcepub fn new(
origin: DVec3,
x: DVec3,
y: DVec3,
tolerance: Tolerance,
) -> Result<PlaneFrame, FrameError>
pub fn new( origin: DVec3, x: DVec3, y: DVec3, tolerance: Tolerance, ) -> Result<PlaneFrame, FrameError>
Validate a basis and build a frame from it.
Unit length and perpendicularity are both DIMENSIONLESS comparisons, so both use the ANGULAR tolerance. Using the linear tolerance here would make a pure direction test scale with the model length unit: the same skewed basis would be refused in metres and accepted in millimetres.
§Errors
Returns FrameError naming which property failed, so a caller
can report the cause rather than a bare rejection.
Sourcepub fn project(&self, point: DVec3) -> DVec2
pub fn project(&self, point: DVec3) -> DVec2
Map a model-space point to its in-plane coordinates.
Points off the plane project ONTO it: the out-of-plane component is
discarded, not reported. Use signed_distance
when the caller needs to know how far off the plane the point was.
Sourcepub fn signed_distance(&self, point: DVec3) -> f64
pub fn signed_distance(&self, point: DVec3) -> f64
Signed distance from the plane, positive along the normal.
Sourcepub fn normal(&self) -> DVec3
pub fn normal(&self) -> DVec3
The right-handed normal, x cross y.
Derived rather than stored: a stored normal is a third value that can disagree with the axes, which is the inconsistency this type exists to prevent.
Sourcepub fn from_normal(
origin: DVec3,
normal: DVec3,
tolerance: Tolerance,
) -> Result<PlaneFrame, FrameError>
pub fn from_normal( origin: DVec3, normal: DVec3, tolerance: Tolerance, ) -> Result<PlaneFrame, FrameError>
Build a frame from a normal, choosing an arbitrary in-plane x axis.
Use when the caller cares about the PLANE but not about which in-plane
direction is x, such as sectioning. When the x direction is meaningful
(a drawing’s horizontal, a wall’s length), pass it explicitly via
new instead of accepting whatever this picks.
§Errors
Returns FrameError when the normal is non-finite or too short
to normalize.
Trait Implementations§
Source§impl Clone for PlaneFrame
impl Clone for PlaneFrame
Source§fn clone(&self) -> PlaneFrame
fn clone(&self) -> PlaneFrame
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PlaneFrame
impl Debug for PlaneFrame
Source§impl PartialEq for PlaneFrame
impl PartialEq for PlaneFrame
impl Copy for PlaneFrame
impl StructuralPartialEq for PlaneFrame
Auto Trait Implementations§
impl Freeze for PlaneFrame
impl RefUnwindSafe for PlaneFrame
impl Send for PlaneFrame
impl Sync for PlaneFrame
impl Unpin for PlaneFrame
impl UnwindSafe for PlaneFrame
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§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