pub struct Frame { /* private fields */ }Expand description
A local coordinate system in space.
The z direction is primary: it is the axis of revolution for a cylinder,
the normal of a plane, the axis of a circle. x fixes where parameterization
starts. y is derived and always consistent with the handedness.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(
origin: Point,
z: Direction,
x_reference: Direction,
tol: Tolerances,
) -> OgeomResult<Self>
pub fn new( origin: Point, z: Direction, x_reference: Direction, tol: Tolerances, ) -> OgeomResult<Self>
A right-handed frame from an origin, a primary direction and a reference for the first axis.
x_reference need not be perpendicular to z: its component along z
is removed. It must not be parallel to z, since then there is nothing
left to orient by.
§Errors
OgeomError::Construction if z and
x_reference are parallel.
Sourcepub fn about(origin: Point, z: Direction) -> Self
pub fn about(origin: Point, z: Direction) -> Self
A right-handed frame with an arbitrary but deterministic first axis.
For geometry with rotational symmetry (a sphere, a full circle), the
choice of x is immaterial, and requiring the caller to invent one is
noise.
Sourcepub fn from_axes(
origin: Point,
x: Direction,
y: Direction,
z: Direction,
tol: Tolerances,
) -> OgeomResult<Self>
pub fn from_axes( origin: Point, x: Direction, y: Direction, z: Direction, tol: Tolerances, ) -> OgeomResult<Self>
A frame from three directions given explicitly.
Handedness is inferred from the triple product rather than asserted.
§Errors
OgeomError::Construction if the three
are not mutually perpendicular within tol.angular(), or if they are
coplanar.
Sourcepub const fn z(&self) -> Direction
pub const fn z(&self) -> Direction
The primary direction: the normal of a plane, the axis of a cylinder.
Sourcepub const fn handedness(&self) -> Handedness
pub const fn handedness(&self) -> Handedness
This frame’s handedness.
Sourcepub const fn with_origin(&self, origin: Point) -> Self
pub const fn with_origin(&self, origin: Point) -> Self
This frame moved to a new origin.
Sourcepub const fn with_z_reversed(&self) -> Self
pub const fn with_z_reversed(&self) -> Self
This frame with the primary direction reversed.
x is kept, so y must flip to preserve handedness; reversing a
plane’s normal should not silently turn its parameterization inside out.
Sourcepub fn to_local(&self, p: Point) -> Point
pub fn to_local(&self, p: Point) -> Point
Local coordinates of a point given in world coordinates.
Sourcepub fn to_world(&self, p: Point) -> Point
pub fn to_world(&self, p: Point) -> Point
World coordinates of a point given in this frame’s local coordinates.
Sourcepub fn vector_to_local(&self, v: Vector) -> Vector
pub fn vector_to_local(&self, v: Vector) -> Vector
Local components of a world-space vector. Unaffected by the origin.
Sourcepub fn vector_to_world(&self, v: Vector) -> Vector
pub fn vector_to_world(&self, v: Vector) -> Vector
World components of a vector given in local coordinates.
Sourcepub fn is_equal(&self, other: &Self, tol: Tolerances) -> bool
pub fn is_equal(&self, other: &Self, tol: Tolerances) -> bool
Whether two frames agree in origin and all three directions.
Sourcepub fn signed_distance_to_plane(&self, p: Point) -> f64
pub fn signed_distance_to_plane(&self, p: Point) -> f64
The signed distance from p to this frame’s XY plane, positive on the
side the primary direction points to.
Trait Implementations§
impl Copy for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.