pub struct PlaneFrame {
pub origin: [f64; 3],
pub x_axis: [f64; 3],
pub y_axis: [f64; 3],
pub z_axis: [f64; 3],
}Expand description
An orthonormal placement frame for a sketch plane — origin + in-plane x/y
axes + the z normal, all in world space (f64). A plane (u, v) coordinate
maps to world origin + u·x + v·y (via to_world).
Mirrors the kernel’s feature_pipeline::Frame shape; kept local (and f64) so
the sketch module stays self-contained and matches the solver’s double-precision
coordinates. Later slices resolve this from the sketch’s plane reference (a
DATUM/PLANE frame or a face frame); S0 uses the XY plane.
Fields§
§origin: [f64; 3]§x_axis: [f64; 3]§y_axis: [f64; 3]§z_axis: [f64; 3]Implementations§
Source§impl PlaneFrame
impl PlaneFrame
Sourcepub fn xz() -> Self
pub fn xz() -> Self
The world XZ base plane (datum.rs normal (0, -1, 0)), resolved through
the same worldUp convention the kernel uses (see from_normal).
Sourcepub fn yz() -> Self
pub fn yz() -> Self
The world YZ base plane (datum.rs normal (1, 0, 0)), resolved through
the same worldUp convention the kernel uses (see from_normal).
Sourcepub fn from_normal(origin: [f64; 3], normal: [f64; 3]) -> Self
pub fn from_normal(origin: [f64; 3], normal: [f64; 3]) -> Self
Derive an orthonormal frame from an origin + plane normal, a faithful
port of feature_pipeline::Frame::from_origin_normal — the kernel’s SINGLE
source of truth for how a plane reference becomes in-plane axes:
refUp = |n·(0,1,0)| > 0.9 ? (1,0,0) : (0,1,0)
x = norm(refUp × n); y = norm(n × x); z = nA degenerate (zero / non-finite) normal — or a normal collinear with the
picked refUp — returns the XY identity axes (at origin) rather than
erroring, so callers always get a usable frame.
Sourcepub fn from_basis_json(basis: &Value) -> Self
pub fn from_basis_json(basis: &Value) -> Self
Read a persisted persistentData.basis object ({origin, x, y, z}, each a
[x, y, z] array) into a frame, mirroring the kernel’s persisted_basis_frame
(features/sketch.rs). Missing keys default to the identity components, so a
partial / absent basis still yields a usable XY-ish frame.
Sourcepub fn to_world(&self, u: f64, v: f64) -> [f64; 3]
pub fn to_world(&self, u: f64, v: f64) -> [f64; 3]
Map a plane (u, v) coordinate to world [x, y, z].
Sourcepub fn to_uv(&self, world: [f64; 3]) -> (f64, f64)
pub fn to_uv(&self, world: [f64; 3]) -> (f64, f64)
Project a world point onto the plane’s (u, v) frame — the inverse of
to_world. With orthonormal axes this is plain dot
products against the offset from the origin (d = world − origin;
u = d·x_axis, v = d·y_axis); a point off the plane projects orthogonally
(its normal component is dropped). Mirrors the previous sketcher’s
world→UV projection.
Trait Implementations§
Source§impl Clone for PlaneFrame
impl Clone for PlaneFrame
Source§fn clone(&self) -> PlaneFrame
fn clone(&self) -> PlaneFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PlaneFrame
Source§impl Debug for PlaneFrame
impl Debug for PlaneFrame
Source§impl Default for PlaneFrame
impl Default for PlaneFrame
Source§impl PartialEq for PlaneFrame
impl PartialEq 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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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