pub struct Tolerance(_);Expand description
A tolerance value
A tolerance value is used during approximation. It defines the maximum allowed deviation of the approximation from the actual shape.
The Tolerance type enforces that the tolerance value is always larger than
zero, which is an attribute that the approximation code relies on.
Failing From/Into implementation
The From/Into implementations of tolerance are fallible, which goes
against the explicit mandate of those traits, as stated in their
documentation.
A fallible Into provides a lot of convenience in test code. Since said
documentation doesn’t provide any actual reasoning for this requirement, I’m
feeling free to just ignore it.
Implementations§
source§impl Tolerance
impl Tolerance
sourcepub fn from_scalar(scalar: impl Into<Scalar>) -> Result<Self, InvalidTolerance>
pub fn from_scalar(scalar: impl Into<Scalar>) -> Result<Self, InvalidTolerance>
Construct a Tolerance from a Scalar
Returns an error, if the passed scalar is not larger than zero.
sourcepub fn inner(&self) -> Scalar
pub fn inner(&self) -> Scalar
Return the Scalar that defines the tolerance
Examples found in repository?
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
pub fn for_circle<const D: usize>(
circle: &Circle<D>,
tolerance: impl Into<Tolerance>,
) -> Self {
let radius = circle.a().magnitude();
let num_vertices_to_approx_full_circle = Scalar::max(
Scalar::PI
/ (Scalar::ONE - (tolerance.into().inner() / radius)).acos(),
3.,
)
.ceil();
let increment = Scalar::TAU / num_vertices_to_approx_full_circle;
Self { increment }
}Trait Implementations§
source§impl Ord for Tolerance
impl Ord for Tolerance
source§impl PartialEq<Tolerance> for Tolerance
impl PartialEq<Tolerance> for Tolerance
source§impl PartialOrd<Tolerance> for Tolerance
impl PartialOrd<Tolerance> for Tolerance
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for Tolerance
impl Eq for Tolerance
impl StructuralEq for Tolerance
impl StructuralPartialEq for Tolerance
Auto Trait Implementations§
impl RefUnwindSafe for Tolerance
impl Send for Tolerance
impl Sync for Tolerance
impl Unpin for Tolerance
impl UnwindSafe for Tolerance
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§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.