pub struct Tolerance {
pub linear: f64,
pub angular: f64,
pub relative: f64,
}Expand description
Tolerance thresholds for geometric comparisons.
Fields§
§linear: f64Absolute tolerance for linear (distance) comparisons.
angular: f64Absolute tolerance for angular (radian) comparisons.
relative: f64Relative tolerance as a fraction of the larger operand.
Used by approx_eq to scale comparisons:
|a - b| <= max(linear, relative * max(|a|, |b|)).
Implementations§
Source§impl Tolerance
impl Tolerance
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Sensible defaults for CAD geometry.
Linear: 1e-7, angular: 1e-12, relative: 1e-10.
Sourcepub const fn loose() -> Self
pub const fn loose() -> Self
A looser tolerance for visualization or rough checks.
Linear: 1e-4, angular: 1e-8, relative: 1e-6.
Sourcepub const fn tight() -> Self
pub const fn tight() -> Self
A tighter tolerance for high-precision operations.
Linear: 1e-10, angular: 1e-15, relative: 1e-14.
Sourcepub fn approx_eq(self, a: f64, b: f64) -> bool
pub fn approx_eq(self, a: f64, b: f64) -> bool
Scale-aware approximate equality.
Returns true when |a - b| <= max(linear, relative * max(|a|, |b|)).
This ensures comparisons remain meaningful at any coordinate magnitude.
Sourcepub fn approx_eq_abs(self, a: f64, b: f64) -> bool
pub fn approx_eq_abs(self, a: f64, b: f64) -> bool
Purely absolute approximate equality (ignores relative).
Use this when comparing values that are not coordinates, e.g.
parameter-space values in [0, 1] where relative scaling is wrong.
Sourcepub fn parametric(self, derivative_mag: f64) -> f64
pub fn parametric(self, derivative_mag: f64) -> f64
Convert the linear tolerance to parameter space given the magnitude of a surface derivative (or curve tangent).
The parametric tolerance is linear / derivative_magnitude, so a
surface with ||∂S/∂u|| = 1000 and linear tolerance 1e-7 gives
parametric tolerance 1e-10.
Clamps to [1e-15, 0.1] to prevent degeneracy.
Trait Implementations§
impl Copy for Tolerance
Source§impl<'de> Deserialize<'de> for Tolerance
impl<'de> Deserialize<'de> for Tolerance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Tolerance
Auto Trait Implementations§
impl Forget for Tolerance
impl Freeze for Tolerance
impl Move for Tolerance
impl RefUnwindSafe for Tolerance
impl Send for Tolerance
impl Sync for Tolerance
impl Unpin for Tolerance
impl UnsafeUnpin for Tolerance
impl UnwindSafe for Tolerance
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more