tolerance.resolve

The tolerance an operation uses: the caller’s when given, else the default for the input box.

GeometricSince 0.3.0

Usage

TypeScript
Tolerance.resolve(tol: number | Tolerance | undefined, box: BBox): Tolerance

Parameters

  • tolnumber | Tolerance | undefined

    The caller’s tolerance: a bare number is an absolute distance with the default angle; a Tolerance is used as given; undefined means use the default. Required. In model.

  • boxBBox

    The bounding box of the operation’s inputs, for the default. Required. In model.

Returns

A number goes through Tolerance.explicit; a Tolerance object is returned unchanged; undefined gives Tolerance.forBox(box). source says which branch was taken.

Guarantees

  • a number tol gives Tolerance.explicit(tol) (deep equality)
  • undefined gives Tolerance.forBox(box) (deep equality, source === 'bbox')
  • a Tolerance object is returned as the same object (===)

Use instead

  • tolerance.forBox: you want the default and there is no caller tolerance to honour

Example

TypeScript
Tolerance.resolve(0.5, BBox.empty).absolute // → 0.5
Tolerance.resolve(undefined, BBox.ofPoints([Point3.origin, Point3.of(3, 4, 0)])).source // → 'bbox'

See also