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 fn new(
origin: Point3,
x: Vec3,
y: Vec3,
tolerance: Tolerance,
) -> Result<Self, FrameError>
pub fn new( origin: Point3, x: Vec3, y: Vec3, tolerance: Tolerance, ) -> Result<Self, 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: Point3) -> Point2
pub fn project(&self, point: Point3) -> Point2
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: Point3) -> Scalar
pub fn signed_distance(&self, point: Point3) -> Scalar
Signed distance from the plane, positive along the normal.
Sourcepub fn normal(&self) -> Vec3
pub fn normal(&self) -> Vec3
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: Point3,
normal: Vec3,
tolerance: Tolerance,
) -> Result<Self, FrameError>
pub fn from_normal( origin: Point3, normal: Vec3, tolerance: Tolerance, ) -> Result<Self, 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 more