diff --git a/modules/math/commons.ts b/modules/math/commons.ts index 8084ba74..78da0279 100644 --- a/modules/math/commons.ts +++ b/modules/math/commons.ts @@ -1,52 +1,14 @@ import Vector from 'math/vector'; import BBox from '../../web/app/math/bbox' import * as vec from 'math/vec'; -import {perp2d} from "math/vec"; +import {perp2d} from 'math/vec'; import {eqTol} from "../../web/app/brep/geom/tolerance"; import {IDENTITY_BASIS3} from "math/basis"; +import {distance, distanceSquared3, distanceSquaredAB3, distanceSquaredANegB3} from "math/distance"; export const TOLERANCE = 1E-6; export const TOLERANCE_SQ = TOLERANCE * TOLERANCE; -export function distanceAB(a, b) { - return distance(a.x, a.y, b.x, b.y); -} - -export function distance(x1, y1, x2, y2) { - var dx = x1 - x2; - var dy = y1 - y2; - return Math.sqrt(dx * dx + dy * dy); -} - -export function distanceAB3(a, b) { - return distance3(a.x, a.y, a.z, b.x, b.y, b.z); -} - -export function distance3(x1, y1, z1, x2, y2, z2) { - return Math.sqrt(distanceSquared3(x1, y1, z1, x2, y2, z2)); -} - -export function distanceSquaredAB3(a, b) { - return distanceSquared3(a.x, a.y, a.z, b.x, b.y, b.z); -} - -export function distanceSquaredANegB3(a, b) { - return distanceSquared3(a.x, a.y, a.z, -b.x, -b.y, -b.z); -} - - -export function distanceSquared3(x1, y1, z1, x2, y2, z2) { - var dx = x1 - x2; - var dy = y1 - y2; - var dz = z1 - z2; - return dx * dx + dy * dy + dz * dz; -} - -export function distanceSquared(x1, y1, x2, y2) { - const dx = x1 - x2; - const dy = y1 - y2; - return dx * dx + dy * dy; -} export function circleFromPoints(p1, p2, p3) { var center = new Vector(); diff --git a/modules/math/distance.ts b/modules/math/distance.ts index e69de29b..60ff5d69 100644 --- a/modules/math/distance.ts +++ b/modules/math/distance.ts @@ -0,0 +1,38 @@ +export function distanceAB(a, b) { + return distance(a.x, a.y, b.x, b.y); +} + +export function distance(x1, y1, x2, y2) { + var dx = x1 - x2; + var dy = y1 - y2; + return Math.sqrt(dx * dx + dy * dy); +} + +export function distanceAB3(a, b) { + return distance3(a.x, a.y, a.z, b.x, b.y, b.z); +} + +export function distance3(x1, y1, z1, x2, y2, z2) { + return Math.sqrt(distanceSquared3(x1, y1, z1, x2, y2, z2)); +} + +export function distanceSquaredAB3(a, b) { + return distanceSquared3(a.x, a.y, a.z, b.x, b.y, b.z); +} + +export function distanceSquaredANegB3(a, b) { + return distanceSquared3(a.x, a.y, a.z, -b.x, -b.y, -b.z); +} + +export function distanceSquared3(x1, y1, z1, x2, y2, z2) { + var dx = x1 - x2; + var dy = y1 - y2; + var dz = z1 - z2; + return dx * dx + dy * dy + dz * dz; +} + +export function distanceSquared(x1, y1, x2, y2) { + const dx = x1 - x2; + const dy = y1 - y2; + return dx * dx + dy * dy; +} \ No newline at end of file diff --git a/web/app/brep/debug/debugger/utils.jsx b/web/app/brep/debug/debugger/utils.jsx index 44db4cf3..498504dc 100644 --- a/web/app/brep/debug/debugger/utils.jsx +++ b/web/app/brep/debug/debugger/utils.jsx @@ -3,8 +3,8 @@ import { AQUA, BLACK, BLUE, cycleColor, DETECTED_EDGE, DISCARDED_EDGE, GREEN, RED, SALMON, WHITE, YELLOW } from "./colors"; -import {distanceAB3} from "../../../../../modules/math/commons"; import Section from "./section"; +import {distanceAB3} from "../../../../../modules/math/distance"; export function getFacesViewObjects(group3d, category, context, out, faces) { forEach(faces, getFaceViewObjects.bind(null, group3d, category, context, out)); diff --git a/web/app/brep/geom/tolerance.ts b/web/app/brep/geom/tolerance.ts index 9d786fbe..9139ced6 100644 --- a/web/app/brep/geom/tolerance.ts +++ b/web/app/brep/geom/tolerance.ts @@ -1,4 +1,5 @@ -import {areEqual, areNegVectorsEqual, areVectorsEqual, areVectorsEqual3, distanceSquared3} from 'math/commons'; +import {areEqual, areNegVectorsEqual, areVectorsEqual, areVectorsEqual3} from 'math/commons'; +import {distanceSquared3} from "math/distance"; export const TOLERANCE = 1e-3; export const TOLERANCE_SQ = TOLERANCE * TOLERANCE; diff --git a/web/app/cad/legacy/mesh/revolve.js b/web/app/cad/legacy/mesh/revolve.js index 309b75c1..75aafdc8 100644 --- a/web/app/cad/legacy/mesh/revolve.js +++ b/web/app/cad/legacy/mesh/revolve.js @@ -3,6 +3,7 @@ import * as math from '../../../../../modules/math/commons' import {createShared} from '../../cad-utils' import {TriangulatePolygons} from '../../tess/triangulation'; import {Matrix3} from "../../../../../modules/math/matrix"; +import {distanceAB3} from "../../../../../modules/math/distance"; function Group(derivedFrom) { this.polygons = []; @@ -16,10 +17,10 @@ export default function revolve(polygons, axisSegment, angle, resolution) { const polygon = [pOrig[p], pOrig[q]]; //skip point if they are on the axis of revolving - if (!math.equal(0, math.distanceAB3(pOrig[q], pRot[q]))) { + if (!math.equal(0, distanceAB3(pOrig[q], pRot[q]))) { polygon.push(pRot[q]); } - if (!math.equal(0, math.distanceAB3(pOrig[p], pRot[p]))) { + if (!math.equal(0, distanceAB3(pOrig[p], pRot[p]))) { polygon.push(pRot[p]); } if (polygon.length < 3) { @@ -75,10 +76,10 @@ export function revolveToTriangles(polygons, axisSegment, angle, resolution, tri //add initial polygon let lids = revolveIterator(polygons, axisSegment, angle, resolution, (pOrig, pRot, p, q, r, id, i, length) => { //skip point if they are on the axis of revolving - if (!math.equal(0, math.distanceAB3(pOrig[q], pRot[q]))) { + if (!math.equal(0, distanceAB3(pOrig[q], pRot[q]))) { out.push( [pOrig[p], pOrig[q], pRot[q]] ); } - if (!math.equal(0, math.distanceAB3(pOrig[p], pRot[p]))) { + if (!math.equal(0, distanceAB3(pOrig[p], pRot[p]))) { out.push( [ pRot[q], pRot[p], pOrig[p]] ); } let last = i === length - 1 @@ -136,7 +137,7 @@ export function revolveIterator(polygons, axisSegment, angle, resolution, callba function addIfNonZero(out, seg) { - if (!math.equal(0, math.distanceAB3(seg[0], seg[1]))) { + if (!math.equal(0, distanceAB3(seg[0], seg[1]))) { out.push(seg); } } diff --git a/web/app/cad/legacy/mesh/workbench.js b/web/app/cad/legacy/mesh/workbench.js index ad10a29c..395f3507 100644 --- a/web/app/cad/legacy/mesh/workbench.js +++ b/web/app/cad/legacy/mesh/workbench.js @@ -5,6 +5,7 @@ import {HashTable} from '../../../utils/hashmap' import {Mesh} from '../mesh' import revolve from './revolve' import {Triangulate} from '../../tess/triangulation' +import {distanceAB3} from "../../../../../modules/math/distance"; export function sortPolygons(polygons) { function Loop(polygon) { @@ -494,7 +495,7 @@ function splitTwoSegments(a, b) { function attract(vectors, precision) { var eq = math.areEqual(); - var dist = math.distanceAB3; + var dist = distanceAB3; vectors = vectors.slice(); for (var i = 0; i < vectors.length; i++) { var v1 = vectors[i]; diff --git a/web/app/cad/sketch/sketchBoundaries.js b/web/app/cad/sketch/sketchBoundaries.js index 465d8d78..b49c6d64 100644 --- a/web/app/cad/sketch/sketchBoundaries.js +++ b/web/app/cad/sketch/sketchBoundaries.js @@ -1,9 +1,10 @@ -import {areEqual, circleFromPoints, distanceAB, radiusOfCurvature, TOLERANCE} from '../../../../modules/math/commons'; +import {areEqual, circleFromPoints, radiusOfCurvature, TOLERANCE} from '../../../../modules/math/commons'; import * as vec from 'math/vec'; import {iteratePath} from '../cad-utils'; import NurbsCurve from '../../brep/geom/curves/nurbsCurve'; import {veqXYZ} from '../../brep/geom/tolerance'; import curveTess, {curveTessParams} from '../../brep/geom/impl/curve/curve-tess'; +import {distanceAB} from "../../../../modules/math/distance"; export function getSketchBoundaries(sceneFace) { const boundary = {lines: [], arcs: [], circles: [], nurbses: []}; diff --git a/web/app/cad/sketch/sketchModel.js b/web/app/cad/sketch/sketchModel.js index 056bfa7e..71f8b2e7 100644 --- a/web/app/cad/sketch/sketchModel.js +++ b/web/app/cad/sketch/sketchModel.js @@ -3,10 +3,11 @@ import BrepCurve from '../../brep/geom/curves/brepCurve'; import NurbsCurve from '../../brep/geom/curves/nurbsCurve'; import {Point} from '../../brep/geom/point' import {LUT} from '../../math/bezier-cubic' -import {distanceAB, isCCW, makeAngle0_360} from '../../../../modules/math/commons' +import {isCCW, makeAngle0_360} from '../../../../modules/math/commons' import {normalizeCurveEnds} from '../../brep/geom/impl/nurbs-ext'; import Vector, {AXIS, ORIGIN} from '../../../../modules/math/vector'; import CSys from "../../../../modules/math/csys"; +import {distanceAB} from "../../../../modules/math/distance"; const RESOLUTION = 20; diff --git a/web/app/sketcher/constr/ANConstraints.ts b/web/app/sketcher/constr/ANConstraints.ts index 1280180e..6db6848d 100644 --- a/web/app/sketcher/constr/ANConstraints.ts +++ b/web/app/sketcher/constr/ANConstraints.ts @@ -1,5 +1,5 @@ import {Param} from '../shapes/param'; -import {DEG_RAD, distanceAB, makeAngle0_360} from "math/commons"; +import {DEG_RAD, makeAngle0_360} from "math/commons"; import {COS_FN, Polynomial, POW_1_FN, POW_2_FN, POW_3_FN, SIN_FN} from "./polynomial"; import {cubicBezierDer1, cubicBezierDer2, cubicBezierPoint} from "../../brep/geom/curves/bezierCubic"; @@ -37,6 +37,7 @@ import {ISolveStage, SolvableObject} from "./solvableObject"; import {SketchObject} from "../shapes/sketch-object"; import {IconType} from "react-icons"; import {ConstraintAnnotation} from "./constraintAnnotation"; +import {distanceAB} from "math/distance"; export const ConstraintDefinitions // : { diff --git a/web/app/sketcher/constraints.js b/web/app/sketcher/constraints.js index a29d0172..1a72d3da 100644 --- a/web/app/sketcher/constraints.js +++ b/web/app/sketcher/constraints.js @@ -1,6 +1,6 @@ import {Ref} from './shapes/ref'; -import * as math from '../../../modules/math/commons'; import Vector from '../../../modules/math/vector'; +import {distanceAB} from "../../../modules/math/distance"; class AbstractConstraint { @@ -444,7 +444,7 @@ Constraints.RR.prototype.getObjects = function() { Constraints.LL = function(line1, line2) { this.line1 = line1; this.line2 = line2; - this.length = new Ref(math.distanceAB(line1.a, line1.b)); + this.length = new Ref(distanceAB(line1.a, line1.b)); }; Constraints.LL.prototype.NAME = 'LL'; @@ -810,7 +810,7 @@ Constraints.CurveTangent.prototype.getObjects = function() { Constraints.PointInMiddle = function(point, line) { this.point = point; this.line = line; - this.length = new Ref(math.distanceAB(line.a, line.b) / 2); + this.length = new Ref(distanceAB(line.a, line.b) / 2); }; Constraints.PointInMiddle.prototype.NAME = 'PointInMiddle'; @@ -852,7 +852,7 @@ Constraints.PointInMiddle.prototype.getObjects = function() { Constraints.Symmetry = function(point, line) { this.point = point; this.line = line; - this.length = new Ref(math.distanceAB(line.a, line.b) / 2); + this.length = new Ref(distanceAB(line.a, line.b) / 2); }; Constraints.Symmetry.prototype.NAME = 'Symmetry'; diff --git a/web/app/sketcher/shapes/arc.ts b/web/app/sketcher/shapes/arc.ts index 6fceefaa..12dfa36c 100644 --- a/web/app/sketcher/shapes/arc.ts +++ b/web/app/sketcher/shapes/arc.ts @@ -1,10 +1,11 @@ import * as math from 'math/commons'; +import {makeAngle0_360} from 'math/commons'; import Vector from 'math/vector'; import {SketchObject, SketchObjectSerializationData} from './sketch-object'; import {Param} from "./param"; import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints"; -import {makeAngle0_360} from "math/commons"; import {EndPoint, SketchPointSerializationData} from "./point"; +import {distance} from "math/distance"; export class Arc extends SketchObject { @@ -66,11 +67,11 @@ export class Arc extends SketchObject { } distanceA() { - return math.distance(this.a.x, this.a.y, this.c.x, this.c.y); + return distance(this.a.x, this.a.y, this.c.x, this.c.y); } distanceB() { - return math.distance(this.b.x, this.b.y, this.c.x, this.c.y); + return distance(this.b.x, this.b.y, this.c.x, this.c.y); } calcStartAng() { @@ -145,11 +146,11 @@ export class Arc extends SketchObject { var isInsideSector = this.isPointInsideSector(aim.x, aim.y); if (isInsideSector) { - return Math.abs(math.distance(aim.x, aim.y, this.c.x, this.c.y) - this.radiusForDrawing()); + return Math.abs(distance(aim.x, aim.y, this.c.x, this.c.y) - this.radiusForDrawing()); } else { return Math.min( - math.distance(aim.x, aim.y, this.a.x, this.a.y), - math.distance(aim.x, aim.y, this.b.x, this.b.y) + distance(aim.x, aim.y, this.a.x, this.a.y), + distance(aim.x, aim.y, this.b.x, this.b.y) ); } } diff --git a/web/app/sketcher/shapes/circle.js b/web/app/sketcher/shapes/circle.js index 474097d0..f56c14f5 100644 --- a/web/app/sketcher/shapes/circle.js +++ b/web/app/sketcher/shapes/circle.js @@ -1,7 +1,7 @@ -import * as math from '../../../../modules/math/commons'; import {SketchObject} from './sketch-object' import {Param} from "./param"; import {EndPoint} from "./point"; +import {distance} from "../../../../modules/math/distance"; export const MIN_RADIUS = 100; @@ -39,7 +39,7 @@ export class Circle extends SketchObject { } normalDistance(aim) { - return Math.abs(math.distance(aim.x, aim.y, this.c.x, this.c.y) - this.r.get()); + return Math.abs(distance(aim.x, aim.y, this.c.x, this.c.y) - this.r.get()); } copy() { diff --git a/web/app/sketcher/shapes/dim.js b/web/app/sketcher/shapes/dim.js index f54f3fe9..7d1f1870 100644 --- a/web/app/sketcher/shapes/dim.js +++ b/web/app/sketcher/shapes/dim.js @@ -1,13 +1,17 @@ -import * as math from '../../../../modules/math/commons' +import { + DEG_RAD, + lineLineIntersection2d, + makeAngle0_360, + pointToLineSignedDistance +} from '../../../../modules/math/commons' import * as vec from 'math/vec' -import {DEG_RAD, lineLineIntersection2d, makeAngle0_360, pointToLineSignedDistance} from '../../../../modules/math/commons' import Vector from 'math/vector'; import {Styles} from "../styles"; import {TextHelper} from "./textHelper"; import {isInstanceOf} from "../actions/matchUtils"; import {Arc} from "./arc"; import {SketchObject} from "./sketch-object"; -import {ConstraintAnnotation} from "../constr/constraintAnnotation"; +import {distance, distanceAB} from "../../../../modules/math/distance"; const ARROW_W_PX = 15; const ARROW_H_PX = 4; @@ -79,7 +83,7 @@ export class LinearDimension extends Dimension { let _vx = - (_by - _ay); let _vy = _bx - _ax; - const d = math.distance(_ax, _ay, _bx, _by); + const d = distance(_ax, _ay, _bx, _by); //normalize let _vxn = _vx / d; @@ -116,7 +120,7 @@ export class LinearDimension extends Dimension { startA = this.b; startB = this.a; - const d = math.distanceAB(a, b); + const d = distanceAB(a, b); let _vx = - (b.y - a.y); let _vy = b.x - a.x; @@ -548,7 +552,7 @@ export class AngleBetweenDimension extends Dimension { let arrRy = cy + off*(arrRyV); - const availableArea = math.distance(arrLx, arrLy, arrRx, arrRy); + const availableArea = distance(arrLx, arrLy, arrRx, arrRy); const modelTextWidth = this.textHelper.modelTextWidth; @@ -696,11 +700,11 @@ export class AngleBetweenDimension extends Dimension { const isInsideSector = isPointInsideSector(aim.x, aim.y); if (isInsideSector) { - return Math.abs(math.distance(aim.x, aim.y, cx, cy) - rad); + return Math.abs(distance(aim.x, aim.y, cx, cy) - rad); } else { return Math.min( - math.distance(aim.x, aim.y, ax, ay), - math.distance(aim.x, aim.y, bx, by) + distance(aim.x, aim.y, ax, ay), + distance(aim.x, aim.y, bx, by) ); } } diff --git a/web/app/sketcher/shapes/ellipse.js b/web/app/sketcher/shapes/ellipse.js index 61ee971c..6ff5c48b 100644 --- a/web/app/sketcher/shapes/ellipse.js +++ b/web/app/sketcher/shapes/ellipse.js @@ -1,8 +1,7 @@ import {SketchObject} from './sketch-object' - -import * as math from '../../../../modules/math/commons'; import {Param} from "./param"; import {EndPoint} from "./point"; +import {distance} from "../../../../modules/math/distance"; export class Ellipse extends SketchObject { @@ -74,7 +73,7 @@ export class Ellipse extends SketchObject { let x = point.x - this.centerX; let y = point.y - this.centerY; const angle = Math.atan2(y, x) - this.rotation; - const radius = math.distance(0, 0, x, y); + const radius = distance(0, 0, x, y); x = radius * Math.cos(angle); y = radius * Math.sin(angle); return {x, y, angle, radius}; @@ -128,7 +127,7 @@ function readFormatV1(id, data) { const cx = data.ep1.x + (data.ep2.x - data.ep1.x) * 0.5; const cy = data.ep1.y + (data.ep2.y - data.ep1.y) * 0.5; - const rx = math.distance(data.ep1.x, data.ep1.y, data.ep2.x, data.ep2.y) * 0.5; + const rx = distance(data.ep1.x, data.ep1.y, data.ep2.x, data.ep2.y) * 0.5; const ry = data.r; const rot = Math.atan2(data.ep2.y - data.ep1.y, data.ep2.x - data.ep1.x); diff --git a/web/app/sketcher/shapes/elliptical-arc.js b/web/app/sketcher/shapes/elliptical-arc.js index 4e448726..536deda5 100644 --- a/web/app/sketcher/shapes/elliptical-arc.js +++ b/web/app/sketcher/shapes/elliptical-arc.js @@ -4,6 +4,7 @@ import * as math from '../../../../modules/math/commons'; import {swap} from '../../utils/utils' import {EndPoint} from "./point"; import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints"; +import {distance} from "../../../../modules/math/distance"; export class EllipticalArc extends Ellipse { @@ -88,7 +89,7 @@ function readFormatV1(id, data) { const cx = data.ep1.x + (data.ep2.x - data.ep1.x) * 0.5; const cy = data.ep1.y + (data.ep2.y - data.ep1.y) * 0.5; - const rx = math.distance(data.ep1.x, data.ep1.y, data.ep2.x, data.ep2.y) * 0.5; + const rx = distance(data.ep1.x, data.ep1.y, data.ep2.x, data.ep2.y) * 0.5; const ry = data.r; const rot = Math.atan2(data.ep2.y - data.ep1.y, data.ep2.x - data.ep1.x); diff --git a/web/app/sketcher/shapes/segment.ts b/web/app/sketcher/shapes/segment.ts index 6288e0ec..f25bce10 100644 --- a/web/app/sketcher/shapes/segment.ts +++ b/web/app/sketcher/shapes/segment.ts @@ -5,6 +5,7 @@ import {DEG_RAD, makeAngle0_360} from 'math/commons' import {Param} from "./param"; import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints"; import {EndPoint, SketchPointSerializationData} from "./point"; +import {distanceAB} from "math/distance"; export class Segment extends SketchObject { @@ -79,7 +80,7 @@ export class Segment extends SketchObject { } recoverIfNecessary() { - if (math.distanceAB(this.a, this.b) > math.TOLERANCE) { + if (distanceAB(this.a, this.b) > math.TOLERANCE) { return false; } else { const recoverLength = 100; diff --git a/web/app/sketcher/tools/arc.js b/web/app/sketcher/tools/arc.js index e0dee219..afcbbd3a 100644 --- a/web/app/sketcher/tools/arc.js +++ b/web/app/sketcher/tools/arc.js @@ -1,8 +1,7 @@ import {Arc} from '../shapes/arc' -import {EndPoint} from '../shapes/point' import {Tool} from './tool' import Vector from 'math/vector'; -import * as math from '../../../../modules/math/commons'; +import {distance} from "../../../../modules/math/distance"; export class AddArcTool extends Tool { @@ -94,7 +93,7 @@ export class AddArcTool extends Tool { } radiusOfFirstPoint() { - return math.distance(this.arc.a.x, this.arc.a.y, this.arc.c.x, this.arc.c.y); + return distance(this.arc.a.x, this.arc.a.y, this.arc.c.x, this.arc.c.y); } processCommand(command) { diff --git a/web/app/sketcher/tools/circle.js b/web/app/sketcher/tools/circle.js index 20a68b9d..7cf025d4 100644 --- a/web/app/sketcher/tools/circle.js +++ b/web/app/sketcher/tools/circle.js @@ -1,7 +1,6 @@ import {Tool} from './tool' -import * as math from '../../../../modules/math/commons'; -import {EndPoint} from '../shapes/point' import {Circle} from '../shapes/circle' +import {distance} from "../../../../modules/math/distance"; export class EditCircleTool extends Tool { constructor(viewer) { @@ -20,7 +19,7 @@ export class EditCircleTool extends Tool { mousemove(e) { var p = this.viewer.screenToModel(e); if (this.circle != null) { - var r = math.distance(p.x, p.y, this.circle.c.x, this.circle.c.y); + var r = distance(p.x, p.y, this.circle.c.x, this.circle.c.y); this.circle.r.set(r); if (!Tool.dumbMode(e)) { this.solveRequest(true); diff --git a/web/app/sketcher/tools/dim.js b/web/app/sketcher/tools/dim.js index 4b0bb457..817b839a 100644 --- a/web/app/sketcher/tools/dim.js +++ b/web/app/sketcher/tools/dim.js @@ -12,8 +12,8 @@ import {DragTool} from "./drag"; import {isInstanceOf} from "../actions/matchUtils"; import {Segment} from "../shapes/segment"; import {DEFAULT_SEARCH_BUFFER} from "../viewer2d"; -import {distance} from "../../../../modules/math/commons"; import {_negate, cross2d} from "math/vec"; +import {distance} from "../../../../modules/math/distance"; export class AddDimTool extends Tool { diff --git a/web/app/sketcher/tools/drag.js b/web/app/sketcher/tools/drag.js index 899f91c7..717defc5 100644 --- a/web/app/sketcher/tools/drag.js +++ b/web/app/sketcher/tools/drag.js @@ -1,6 +1,6 @@ import {Tool} from './tool' -import * as math from 'math/commons' import {toast} from "react-toastify"; +import {distance} from "../../../../modules/math/distance"; export class DragTool extends Tool { @@ -62,7 +62,7 @@ export class DragTool extends Tool { } this.viewer.refresh(); this.viewer.toolManager.releaseControl(); - let traveled = math.distance(this.origin.x, this.origin.y, e.offsetX, e.offsetY); + let traveled = distance(this.origin.x, this.origin.y, e.offsetX, e.offsetY); if (traveled >= 10) { this.viewer.historyManager.lightCheckpoint(10); } diff --git a/web/app/sketcher/tools/fillet.js b/web/app/sketcher/tools/fillet.js index 654a5cd3..6b126d39 100644 --- a/web/app/sketcher/tools/fillet.js +++ b/web/app/sketcher/tools/fillet.js @@ -1,14 +1,10 @@ import Vector from 'math/vector'; -import {Styles} from '../styles' import * as fetch from '../fetchers' -import * as math from '../../../../modules/math/commons' -import {EndPoint} from '../shapes/point' import {Arc} from '../shapes/arc' -import {Constraints} from '../parametric' import {Tool} from './tool' -import {isInstanceOf} from "../actions/matchUtils"; import {Segment} from "../shapes/segment"; import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints"; +import {distanceAB} from "../../../../modules/math/distance"; export class FilletTool extends Tool { @@ -37,7 +33,7 @@ export class FilletTool extends Tool { a = point1.parent.a; b = point1.parent.b; } - const d = math.distanceAB(a, b); + const d = distanceAB(a, b); const k = 4 / 5; b.x = a.x + (b.x - a.x) * k; b.y = a.y + (b.y - a.y) * k;