organizing math module - commons functions

This commit is contained in:
Val Erastov (xibyte) 2020-07-18 22:18:03 -07:00
parent 025f4a94a8
commit 841ce331a4
52 changed files with 56 additions and 56 deletions

View file

@ -1,8 +1,8 @@
import Vector from 'math/vector';
import BBox from './bbox'
import BBox from '../../web/app/math/bbox'
import * as vec from 'math/vec';
import {perp2d} from "math/vec";
import {eqTol} from "../brep/geom/tolerance";
import {eqTol} from "../../web/app/brep/geom/tolerance";
export const TOLERANCE = 1E-6;
export const TOLERANCE_SQ = TOLERANCE * TOLERANCE;

View file

@ -1,4 +1,4 @@
import {clamp} from "../../web/app/math/math";
import {clamp} from "math/commons";
export default class Vector {

View file

@ -1,5 +1,5 @@
import * as vec from 'math/vec';
import {perpendicularVector} from '../../../web/app/math/math';
import {perpendicularVector} from '../../math/commons';
import {Face3, Geometry, Vector3} from 'three';
export function createMeshLineGeometry(points, width) {

View file

@ -1,6 +1,6 @@
import * as sketcher_utils from '../utils/sketcherUtils'
import {genSerpinskiImpl} from '../../../web/app/utils/genSerpinski';
import {distance} from '../../../web/app/math/math';
import {distance} from 'math/commons';
export function createSubjectFromInPlaceSketcher(ctx) {
return createSketcherTPI(ctx.services.sketcher.inPlaceEditor.sketcherAppContext);

View file

@ -5,7 +5,7 @@ import BrepCurve from './geom/curves/brepCurve';
import {Plane} from './geom/impl/plane';
import {BasisForPlane} from 'math/l3space';
import * as cad_utils from '../cad/cad-utils';
import * as math from '../math/math';
import * as math from '../../../modules/math/commons';
import {createBoundingSurface} from './brep-builder';
import NurbsSurface from './geom/surfaces/nurbsSurface';
import {BrepSurface} from './geom/surfaces/brepSurface';

View file

@ -3,7 +3,7 @@ import {
AQUA, BLACK, BLUE, cycleColor, DETECTED_EDGE, DISCARDED_EDGE, GREEN, RED, SALMON, WHITE,
YELLOW
} from "./colors";
import {distanceAB3} from "../../../math/math";
import {distanceAB3} from "../../../../../modules/math/commons";
import Section from "./section";
export function getFacesViewObjects(group3d, category, context, out, faces) {

View file

@ -1,6 +1,6 @@
import NurbsCurve from "./nurbsCurve";
import {Vec3} from 'math/l3space'
import {areEqual} from '../../../math/math'
import {areEqual} from 'math/commons'
import {eqSqTol, ueq, veq, veq3, veqNeg} from "../tolerance";
import curveIntersect from "../impl/curve/curves-isec";

View file

@ -1,5 +1,5 @@
import * as vec from 'math/vec';
import {perpendicularVector} from '../../../math/math';
import {perpendicularVector} from '../../../../../modules/math/commons';
export function frenetFrame(D1, D2) {
let T = vec.normalize(D1);

View file

@ -1,6 +1,6 @@
import * as vec from "math/vec";
import {TOLERANCE, TOLERANCE_SQ} from '../../tolerance';
import * as math from '../../../../math/math'
import * as math from '../../../../../../modules/math/commons'
import {fmin_bfgs} from "../../../../math/optim";
export default function curveIntersect(curve1, curve2, isecRange1, isecRange2, tesselator) {

View file

@ -1,5 +1,5 @@
import * as vec from "math/vec";
import * as math from '../../../math/math'
import * as math from 'math/commons'
import {eqEps, TOLERANCE, TOLERANCE_01, TOLERANCE_SQ} from '../tolerance';
import {fmin_bfgs} from "../../../math/optim";
import {Vec3} from "math/l3space";

View file

@ -1,4 +1,4 @@
import {areEqual, areNegVectorsEqual, areVectorsEqual, areVectorsEqual3, distanceSquared3} from '../../math/math';
import {areEqual, areNegVectorsEqual, areVectorsEqual, areVectorsEqual3, distanceSquared3} from 'math/commons';
export const TOLERANCE = 1e-3;
export const TOLERANCE_SQ = TOLERANCE * TOLERANCE;

View file

@ -1,4 +1,4 @@
import * as math from '../math/math'
import * as math from '../../../modules/math/commons'
import {Edge} from './topo/edge'
export default function({curve, start}) {

View file

@ -4,7 +4,7 @@ import {Loop} from '../topo/loop';
import {Shell} from '../topo/shell';
import {Vertex} from '../topo/vertex';
import {evolveFace} from './evolve-face'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {eqTol, TOLERANCE, ueq, veq, veqNeg} from '../geom/tolerance';
import CadError from "../../utils/errors";
import {createBoundingSurface} from "../brep-builder";

View file

@ -1,7 +1,7 @@
import {Face} from '../topo/face';
import {Vertex} from '../topo/vertex';
import Vector from 'math/vector';
import {isCCW} from '../../math/math';
import {isCCW} from '../../../../modules/math/commons';
import PIP from '../../cad/tess/pip';
export function evolveFace(originFace, loops) {

View file

@ -1,6 +1,6 @@
import {TopoObject} from './topo-object'
import * as math from '../../math/math'
import * as math from 'math/commons'
import {Face} from "./face";
import {BrepSurface} from "../geom/surfaces/brepSurface";
import {HalfEdge} from "./edge";

View file

@ -1,5 +1,5 @@
import libtess from 'libtess'
import {area} from "../../math/math";
import {area} from "../../../../modules/math/commons";
export default function pickPointInside2dPolygon(polygon) {
function vertexCallback(data, tr) {

View file

@ -4,7 +4,7 @@ import {eqTol} from "../../../brep/geom/tolerance";
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
import {Plane} from './../../../brep/geom/impl/plane';
import {AssemblyDOF, ModificationResponse} from "./assemblyDOF";
import {areEqual, clamp, DEG_RAD, lineLineIntersection2d, lineLineIntersection} from "../../../math/math";
import {areEqual, clamp, DEG_RAD, lineLineIntersection2d, lineLineIntersection} from "math/commons";
import {ConflictDOF} from "./conflictDOF";
import {PPPPDOF} from "./PPPPDOF";
import {EdgeAlignConstraint} from "../constraints/edgeAlign";

View file

@ -4,7 +4,7 @@ import {eqTol} from "../../../brep/geom/tolerance";
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
import {Plane} from './../../../brep/geom/impl/plane';
import {ANGULAR_ALLOWANCE, AssemblyDOF, ModificationResponse} from "./assemblyDOF";
import {areEqual, clamp, DEG_RAD} from "../../../math/math";
import {areEqual, clamp, DEG_RAD} from "math/commons";
import {ConflictDOF} from "./conflictDOF";
import {PPPPDOF} from "./PPPPDOF";
import {EdgeAlignConstraint} from "../constraints/edgeAlign";

View file

@ -1,7 +1,7 @@
import Vector from "math/vector";
import {FaceTouchAlignConstraint} from "../constraints/faceTouchAlign";
import {EdgeAlignConstraint} from "../constraints/edgeAlign";
import {DEG_RAD} from "../../../math/math";
import {DEG_RAD} from "math/commons";
import {Matrix3} from "math/matrix";
export const ANGULAR_ALLOWANCE = 10 * DEG_RAD;

View file

@ -1,6 +1,6 @@
import Vector from 'math/vector';
import BBox from '../math/bbox'
import * as math from '../math/math'
import * as math from '../../../modules/math/commons'
import {MeshSceneSolid} from './scene/wrappers/meshSceneObject'
import {Matrix3} from 'math/matrix';

View file

@ -1,4 +1,4 @@
import * as math from '../../../math/math'
import * as math from '../../../../../modules/math/commons'
import {enclose} from '../../../brep/brep-enclose'
import {BooleanOperation, combineShells} from '../booleanOperation'
import {Matrix3} from 'math/matrix';

View file

@ -2,7 +2,7 @@ import schema from './rotateDatumOpSchema';
import {MDatum} from '../../../model/mdatum';
import RotateDatumWizard from './RotateDatumWizard';
import {ORIGIN} from '../../../../../../modules/math/l3space';
import {DEG_RAD} from '../../../../math/math';
import {DEG_RAD} from '../../../../../../modules/math/commons';
import {Matrix3} from "../../../../../../modules/math/matrix";

View file

@ -1,5 +1,5 @@
import {createMeshGeometry} from 'scene/geoms';
import {DEG_RAD} from '../../../math/math';
import {DEG_RAD} from '../../../../../modules/math/commons';
import {revolveToTriangles} from '../../legacy/mesh/revolve';
let cache = {};

View file

@ -1,5 +1,5 @@
import Vector from 'math/vector';
import * as math from '../../../math/math'
import * as math from '../../../../../modules/math/commons'
import {createShared} from '../../cad-utils'
import {TriangulatePolygons} from '../../tess/triangulation';
import {Matrix3} from "../../../../../modules/math/matrix";

View file

@ -1,6 +1,6 @@
import Vector from 'math/vector';
import * as cad_utils from '../../cad-utils'
import * as math from '../../../math/math'
import * as math from '../../../../../modules/math/commons'
import {HashTable} from '../../../utils/hashmap'
import {Mesh} from '../mesh'
import revolve from './revolve'

View file

@ -4,7 +4,7 @@ import brepTess from '../../tess/brep-tess';
import tessellateSurface from '../../../brep/geom/surfaces/surfaceTess';
import {setAttribute} from '../../../../../modules/scene/objectData';
import * as vec from 'math/vec';
import {perpendicularVector} from '../../../math/math';
import {perpendicularVector} from '../../../../../modules/math/commons';
const SMOOTH_RENDERING = true;

View file

@ -1,4 +1,4 @@
import {areEqual, circleFromPoints, distanceAB, radiusOfCurvature, TOLERANCE} from '../../math/math';
import {areEqual, circleFromPoints, distanceAB, radiusOfCurvature, TOLERANCE} from '../../../../modules/math/commons';
import * as vec from 'math/vec';
import {iteratePath} from '../cad-utils';
import NurbsCurve from '../../brep/geom/curves/nurbsCurve';

View file

@ -3,7 +3,7 @@ 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 '../../math/math'
import {distanceAB, isCCW, makeAngle0_360} from '../../../../modules/math/commons'
import {normalizeCurveEnds} from '../../brep/geom/impl/nurbs-ext';
import Vector from '../../../../modules/math/vector';
import {AXIS, ORIGIN} from '../../../../modules/math/l3space';

View file

@ -1,6 +1,6 @@
import * as sm from './sketchModel'
import {Graph} from '../../math/graph'
import * as math from '../../math/math'
import * as math from '../../../../modules/math/commons'
import {HashTable} from '../../utils/hashmap'
import Joints from '../../../../modules/gems/joints';
import sketchObjectGlobalId from './sketchObjectGlobalId';

View file

@ -1,5 +1,5 @@
import pip from "./pip";
import {isCCW} from "../../math/math";
import {isCCW} from "../../../../modules/math/commons";
export default function(loops) {
const loops = loops.map(loop => new NestedLoop(loop));

View file

@ -1,4 +1,4 @@
import {areEqual} from "../../math/math";
import {areEqual} from "../../../../modules/math/commons";
export default function(outerLoop, innerLoops, tol) {

View file

@ -1,5 +1,5 @@
import numeric from 'numeric';
import {_vec, _matrix} from './math'
import {_vec, _matrix} from '../../../modules/math/commons'
const SUCCESS = 1, ITER_LIMIT = 2, SMALL_DELTA = 3, SMALL_STEP = 4, DIVERGENCE = 5, INVALID_STATE = 6;

View file

@ -1,5 +1,5 @@
import {fillArray} from '../utils/utils'
import * as math from './math'
import * as math from '../../../modules/math/commons'
/** @constructor */
function QR(matrix) {

View file

@ -1,5 +1,5 @@
import {Param} from '../shapes/param';
import {DEG_RAD, distanceAB, makeAngle0_360} from "../../math/math";
import {DEG_RAD, distanceAB, 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";

View file

@ -1,4 +1,4 @@
import {sq} from "../../math/math";
import {sq} from "../../../../modules/math/commons";
export function greaterThanConstraint(val) {
const K = 100;

View file

@ -1,4 +1,4 @@
import {sq} from "../../math/math";
import {sq} from "../../../../modules/math/commons";
export function R_Equal(params, [value]) {

View file

@ -1,5 +1,5 @@
import {Ref} from './shapes/ref';
import * as math from '../math/math';
import * as math from '../../../modules/math/commons';
import Vector from '../../../modules/math/vector';
class AbstractConstraint {

View file

@ -1,9 +1,9 @@
import * as math from '../../math/math';
import * as math 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/math";
import {makeAngle0_360} from "math/commons";
import {EndPoint, SketchPointSerializationData} from "./point";
export class Arc extends SketchObject {

View file

@ -4,7 +4,7 @@ import {LUT} from '../../math/bezier-cubic'
import {ConvexHull2D} from '../../math/convex-hull'
import * as draw_utils from '../shapes/draw-utils'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {EndPoint} from "./point";

View file

@ -1,4 +1,4 @@
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {SketchObject} from './sketch-object'
import {Param} from "./param";
import {EndPoint} from "./point";

View file

@ -1,6 +1,6 @@
import * as math from '../../math/math'
import * as math from '../../../../modules/math/commons'
import * as vec from 'math/vec'
import {DEG_RAD, lineLineIntersection2d, makeAngle0_360, pointToLineSignedDistance} from '../../math/math'
import {DEG_RAD, lineLineIntersection2d, makeAngle0_360, pointToLineSignedDistance} from '../../../../modules/math/commons'
import Vector from 'math/vector';
import {Styles} from "../styles";
import {TextHelper} from "./textHelper";

View file

@ -1,6 +1,6 @@
import {SketchObject} from './sketch-object'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {Param} from "./param";
import {EndPoint} from "./point";

View file

@ -1,6 +1,6 @@
import {Ellipse} from './ellipse'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {swap} from '../../utils/utils'
import {EndPoint} from "./point";
import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";

View file

@ -1,7 +1,7 @@
import {SketchObject, SketchObjectSerializationData} from './sketch-object'
import Vector from 'math/vector';
import * as math from '../../math/math'
import {DEG_RAD, makeAngle0_360} from '../../math/math'
import * as math from 'math/commons'
import {DEG_RAD, makeAngle0_360} from 'math/commons'
import {Param} from "./param";
import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";
import {EndPoint, SketchPointSerializationData} from "./point";

View file

@ -1,4 +1,4 @@
import {_270, _90, makeAngle0_360, pointToLineSignedDistance} from "../../math/math";
import {_270, _90, makeAngle0_360, pointToLineSignedDistance} from "../../../../modules/math/commons";
import {_negate} from "math/vec";
export class TextHelper {

View file

@ -2,7 +2,7 @@ import {Arc} from '../shapes/arc'
import {EndPoint} from '../shapes/point'
import {Tool} from './tool'
import Vector from 'math/vector';
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
export class AddArcTool extends Tool {

View file

@ -3,7 +3,7 @@ import {EndPoint} from '../shapes/point'
import {BezierCurve} from '../shapes/bezier-curve'
import {Constraints} from '../parametric'
import Vector from 'math/vector';
import * as math from '../../math/math'
import * as math from '../../../../modules/math/commons'
import {AlgNumConstraint, ConstraintDefinitions} from "../constr/ANConstraints";
export class BezierCurveTool extends Tool {

View file

@ -1,5 +1,5 @@
import {Tool} from './tool'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import {EndPoint} from '../shapes/point'
import {Circle} from '../shapes/circle'

View file

@ -12,7 +12,7 @@ import {DragTool} from "./drag";
import {isInstanceOf} from "../actions/matchUtils";
import {Segment} from "../shapes/segment";
import {DEFAULT_SEARCH_BUFFER} from "../viewer2d";
import {distance} from "../../math/math";
import {distance} from "../../../../modules/math/commons";
import {_negate, cross2d} from "math/vec";
export class AddDimTool extends Tool {

View file

@ -1,6 +1,6 @@
import {Tool} from './tool'
import {optim} from '../../math/optim'
import * as math from '../../math/math'
import * as math from '../../../../modules/math/commons'
import {toast} from "react-toastify";
export class DragTool extends Tool {

View file

@ -1,7 +1,7 @@
import Vector from 'math/vector';
import {Styles} from '../styles'
import * as fetch from '../fetchers'
import * as math from '../../math/math'
import * as math from '../../../../modules/math/commons'
import {EndPoint} from '../shapes/point'
import {Arc} from '../shapes/arc'
import {Constraints} from '../parametric'

View file

@ -1,6 +1,6 @@
import {LoopPickTool} from './loop-pick'
import {Constraints} from '../parametric'
import * as math from '../../math/math';
import * as math from '../../../../modules/math/commons';
import Vector from 'math/vector';
import {swap} from '../../utils/utils'
import {EndPoint} from '../shapes/point'