Struct PlaneFrame

Source
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

Source

pub const fn ground() -> PlaneFrame

The z = 0 ground plane with the world x and y axes.

Source

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.

Source

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.

Source

pub fn lift(&self, point: DVec2) -> DVec3

Map in-plane coordinates back to model space.

Source

pub fn signed_distance(&self, point: DVec3) -> f64

Signed distance from the plane, positive along the normal.

Source

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.

Source

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.

Source

pub const fn origin(&self) -> DVec3

The frame origin.

Source

pub const fn x_axis(&self) -> DVec3

The in-plane axis mapped to the planar x coordinate.

Source

pub const fn y_axis(&self) -> DVec3

The in-plane axis mapped to the planar y coordinate.

Trait Implementations§

Source§

impl Clone for PlaneFrame

Source§

fn clone(&self) -> PlaneFrame

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PlaneFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PlaneFrame

Source§

fn eq(&self, other: &PlaneFrame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PlaneFrame

Source§

impl StructuralPartialEq for PlaneFrame

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,