pub struct Location { /* private fields */ }Expand description
A placement: a chain of (datum, power) pairs.
Applied left to right, so the first entry is the outermost transform. An empty chain is the identity.
Powers are integers, so a datum applied twice costs one entry rather than two, and its inverse is the same entry with the sign flipped. Equality and hashing are structural: two locations agree when their chains match entry for entry. Deliberately not a comparison of the composed transforms; that would be a tolerance question, and the answer would depend on rounding rather than on what the model says.
Implementations§
Source§impl Location
impl Location
Sourcepub fn powered(datum: DatumId, power: i32) -> Self
pub fn powered(datum: DatumId, power: i32) -> Self
A placement of one datum, applied power times.
A power of zero gives the identity; a negative power gives the inverse.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Whether this is the identity.
Sourcepub fn ends_with(&self, inner: &Self) -> bool
pub fn ends_with(&self, inner: &Self) -> bool
Whether this placement is inner with further placements outside
it: inner’s chain is this chain’s tail.
Sourcepub fn then(&self, inner: &Self) -> Self
pub fn then(&self, inner: &Self) -> Self
This placement followed by inner.
outer.then(inner) applies inner first, then outer, the same order
as transform composition, so a sub-shape’s placement composed with its
parent’s reads the way the tree does.
Adjacent entries naming the same datum are merged by adding their
powers, and an entry whose power reaches zero is dropped. That keeps a
chain from growing without bound as a placement is composed and undone
repeatedly, and it is what makes a.then(a.inverted()) come out exactly
equal to the identity rather than merely close to it.
Sourcepub fn inverted(&self) -> Self
pub fn inverted(&self) -> Self
The inverse placement.
Exact: the chain reverses and every power negates. No matrix is
inverted, so l.then(&l.inverted()) is the identity structurally, not
approximately.
Sourcepub fn composed(&self, store: &DatumStore) -> OgeomResult<Transform>
pub fn composed(&self, store: &DatumStore) -> OgeomResult<Transform>
The composed transform.
§Errors
OgeomError::Dangling if the chain names a
datum the store does not hold, and
OgeomError::Numeric if a negative power
requires inverting a degenerate transform.
Sourcepub fn preserves_handedness(&self, store: &DatumStore) -> OgeomResult<bool>
pub fn preserves_handedness(&self, store: &DatumStore) -> OgeomResult<bool>
Whether the composed transform preserves handedness.
A shape placed by a handedness-reversing location has to have its orientation flipped to stay consistent, or a mirrored solid ends up inside out.
§Errors
Sourcepub fn is_same_placement(
&self,
other: &Self,
store: &DatumStore,
tol: Tolerances,
) -> OgeomResult<bool>
pub fn is_same_placement( &self, other: &Self, store: &DatumStore, tol: Tolerances, ) -> OgeomResult<bool>
Sourcepub fn kind(&self, store: &DatumStore) -> OgeomResult<TransformKind>
pub fn kind(&self, store: &DatumStore) -> OgeomResult<TransformKind>
Trait Implementations§
impl Eq for Location
impl StructuralPartialEq for Location
Auto Trait Implementations§
impl Freeze for Location
impl RefUnwindSafe for Location
impl Send for Location
impl Sync for Location
impl Unpin for Location
impl UnsafeUnpin for Location
impl UnwindSafe for Location
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.