Skip to main content

PlaneFrame

Struct PlaneFrame 

Source
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

Source

pub fn xy() -> Self

The world XY plane (identity frame): u → +x, v → +y, normal +z.

Source

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).

Source

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).

Source

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 = n

A 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.

Source

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.

Source

pub fn to_world(&self, u: f64, v: f64) -> [f64; 3]

Map a plane (u, v) coordinate to world [x, y, z].

Source

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

Source§

fn clone(&self) -> PlaneFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for PlaneFrame

Source§

impl Debug for PlaneFrame

Source§

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

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

impl Default for PlaneFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for PlaneFrame

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,