@turbox3d/math
Version:
Large-scale graphics application math library
40 lines • 1.37 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
export var TOLERANCE = 1E-6;
export var TOLERANCE_HALF = TOLERANCE * 0.5;
export var TOLERANCE_SQUARE = TOLERANCE * TOLERANCE;
export var TOLERANCE_SAGITTA = 1;
export var Tolerance = /*#__PURE__*/function () {
function Tolerance(cosTol, distTol, numTol) {
_classCallCheck(this, Tolerance);
this.cosTol = cosTol || Tolerance.COS_TOL;
this.distTol = distTol || Tolerance.DIST_TOL;
this.numTol = numTol || Tolerance.NUM_TOL;
}
/**
* set cosTol by given angle
* @param angle
* @param isRadian true means the angle is radian, false means the angle is degree
*/
return _createClass(Tolerance, [{
key: "setCosTolByAngle",
value: function setCosTolByAngle(angle, isRadian) {
var flag = isRadian ? 1 : Math.PI / 180;
this.cosTol = 1 - Math.cos(angle * flag);
}
}, {
key: "clone",
value: function clone() {
return new Tolerance(this.cosTol, this.distTol, this.numTol);
}
}], [{
key: "setGlobal",
value: function setGlobal(cosTol, distTol, numTol) {
Tolerance.global = new Tolerance(cosTol, distTol, numTol);
}
}]);
}();
Tolerance.COS_TOL = 1e-6;
Tolerance.DIST_TOL = 1e-6;
Tolerance.NUM_TOL = 1e-6;
Tolerance.global = new Tolerance();