From 240c217438f2159c92adc565134d298b7455a93a Mon Sep 17 00:00:00 2001 From: "Val Erastov (xibyte)" Date: Sun, 19 Jul 2020 22:51:52 -0700 Subject: [PATCH] euclidean module organizing --- modules/geom/euclidean.ts | 9 ++++----- modules/geom/tolerance.ts | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/geom/euclidean.ts b/modules/geom/euclidean.ts index 6c435164..20579d9e 100644 --- a/modules/geom/euclidean.ts +++ b/modules/geom/euclidean.ts @@ -1,9 +1,8 @@ -import BBox from "../math/bbox"; +import BBox from "math/bbox"; -import {TOLERANCE} from "math/equality"; import * as vec from "math/vec"; import {perp2d} from "math/vec"; -import {eqTol} from "geom/tolerance"; +import {TIGHT_TOLERANCE, eqTol} from "geom/tolerance"; import {distance} from "math/distance"; import {IDENTITY_BASIS3} from "math/basis"; import Vector from "math/vector"; @@ -15,7 +14,7 @@ export function circleFromPoints(p1, p2, p3) { var cd = (offset - p3.x * p3.x - p3.y * p3.y) / 2.0; var det = (p1.x - p2.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p2.y); - if (Math.abs(det) < TOLERANCE) { + if (Math.abs(det) < 1e-6) { return null; } @@ -68,7 +67,7 @@ export function polygonOffsetByDelta(polygon, delta) { } export function isPointInsidePolygon(inPt, inPolygon) { - var EPSILON = TOLERANCE; + var EPSILON = TIGHT_TOLERANCE; var polyLen = inPolygon.length; diff --git a/modules/geom/tolerance.ts b/modules/geom/tolerance.ts index d64cf4dd..3481a3f3 100644 --- a/modules/geom/tolerance.ts +++ b/modules/geom/tolerance.ts @@ -13,6 +13,7 @@ export const TOLERANCE_01 = TOLERANCE * 1e-2; export const TOLERANCE_01_SQ = TOLERANCE * TOLERANCE; export const NUMERICAL_SOLVE_TOL = 1e-8; +export const TIGHT_TOLERANCE = 1e-6; export function eqTol(a, b) { return areEqual(a, b, TOLERANCE);