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).
Uses double precision to match the sketch solver’s coordinates.
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
impl 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 Forget for PlaneFrame
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.