Table of Contents

Struct Tolerance

Namespace
GeometryHelper
Assembly
GeometryHelper.dll

Tolerance used for geometric comparisons.

Every comparison in this library that can be affected by floating point error takes a tolerance, and every such method has an overload without one that reads Global. Neither library compares coordinates with ==.

Global is one setting shared by both libraries. Changing it for a drawing in the plane changes it for a model in space as well.

Make one with a constructor, or take Default or Global. new Tolerance() is not the default tolerance: like default(Tolerance) it runs no constructor and has every threshold at 0, under which only an exact match is equal and a face out of flat by rounding alone is refused.

public readonly struct Tolerance : IEquatable<Tolerance>
Implements
Inherited Members

Constructors

Tolerance(double, double)

Initializes a tolerance instance with thresholds for points and vectors, using the default angular and planar thresholds.

Tolerance(double, double, double)

Initializes a tolerance instance with thresholds for points, vectors and angles. The planar threshold follows equalPoint, since coplanarity is measured as a distance.

Tolerance(double, double, double, double)

Initializes a tolerance instance with thresholds for points, vectors, angles and coplanarity.

Fields

DefaultEqualAngleRad

Default tolerance when comparing angles for parallelism / perpendicularity, in radians (1 degree in radians).

DefaultEqualPlanar

Default distance threshold for deciding whether a set of points lies on a common plane: a hundredth of a millimetre in a model in millimetres, the same as DefaultEqualPoint.

DefaultEqualPoint

Default tolerance when comparing points: a hundredth of a millimetre in a model in millimetres.

DefaultEqualVector

Default tolerance when comparing vectors.

Properties

Default

Gets the default tolerance: DefaultEqualPoint, DefaultEqualVector, DefaultEqualAngleRad and DefaultEqualPlanar together.

EqualAngleRad

Angular threshold to consider two directions / lines as parallel or perpendicular, in radians.

EqualPlanar

Distance threshold to consider a point as lying on a plane, in drawing units.

This is separate from EqualPoint because coplanarity is checked far from the reference point: a polygon several metres across turns a hundredth of a degree of tilt into a deviation of nearly a millimetre, so the threshold that decides whether two points coincide is the wrong one to decide whether a face is flat.

EqualPoint

Distance threshold to consider two points as coincident, in drawing units.

EqualVector

Threshold to consider two vectors as equal.

Global

Tolerance applied for overloads without explicit tolerance. It starts as Default.

Methods

Equals(Tolerance)

Compares two tolerance instances exactly.

Equals(object)

Compares with an arbitrary object.

GetHashCode()

Hash code built from thresholds.

ToString()

Represents the thresholds as a string.

Use(Tolerance)

Makes a tolerance the one every overload without a tolerance uses on this thread, until the returned scope is disposed.

Operators

operator ==(Tolerance, Tolerance)

Compares two Tolerance instances for equality.

operator !=(Tolerance, Tolerance)

Compares two Tolerance instances for inequality.