mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-15 21:05:22 +01:00
organizing math module - extracting distance
This commit is contained in:
parent
cdd7d90856
commit
63edda21d9
21 changed files with 99 additions and 93 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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: []};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// : {
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue