brepjs 18.150.0 → 18.150.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d/lib/ellipseArcFlags.d.ts +20 -0
- package/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{adjacencyFns-Clu4DbkI.cjs → adjacencyFns-B1FEq-7P.cjs} +3 -3
- package/dist/{adjacencyFns-BMgFDWFO.js → adjacencyFns-ChpKOdJX.js} +3 -3
- package/dist/{blueprint-BzDq9Rfb.js → blueprint-Be2V1tdb.js} +66 -10
- package/dist/{blueprint-CdOcvuG4.cjs → blueprint-SQlROOFK.cjs} +71 -9
- package/dist/{blueprintFns-B6zG47o1.cjs → blueprintFns-BcWGUCk3.cjs} +2 -2
- package/dist/{blueprintFns-B0wbS9PN.js → blueprintFns-DpZo8T6u.js} +2 -2
- package/dist/{blueprintSketcher-DeQYScWX.cjs → blueprintSketcher-C9lVrRBr.cjs} +3 -3
- package/dist/{blueprintSketcher-DI_qQhBg.js → blueprintSketcher-HsSFy10k.js} +3 -3
- package/dist/{boolean2D-C-Azd06V.cjs → boolean2D-Bh07EPIS.cjs} +4 -4
- package/dist/{boolean2D-CdDn7AFp.js → boolean2D-CwFJsT_T.js} +4 -4
- package/dist/brepjs.cjs +36 -72
- package/dist/brepjs.js +36 -72
- package/dist/{cameraFns-CdPdw2Ma.cjs → cameraFns-BYBavyGz.cjs} +3 -3
- package/dist/{cameraFns-BqSTuHN2.js → cameraFns-CWS3e1p_.js} +3 -3
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-WICP_RPb.cjs → cornerFinder-B_6OVtcc.cjs} +1 -1
- package/dist/{cornerFinder-CBNgUcWy.js → cornerFinder-D5doC-g3.js} +1 -1
- package/dist/{curveFns-BtXR6kJ7.js → curveFns-CO0dlocY.js} +1 -1
- package/dist/{curveFns-BYcLLDAB.cjs → curveFns-dXPHWXhw.cjs} +1 -1
- package/dist/{drawFns-BAwR4uoC.js → drawFns-CVvt5Hmy.js} +12 -12
- package/dist/{drawFns-CYW65QTr.cjs → drawFns-C_dvmPvb.cjs} +12 -12
- package/dist/{faceFns-B5UiJH4H.cjs → faceFns-9lfp_6de.cjs} +2 -2
- package/dist/{faceFns-BfTHYEiw.js → faceFns-C-SjeGpG.js} +2 -2
- package/dist/{healingFns-DAVYFXVB.js → healingFns-BtrFRoK5.js} +4 -4
- package/dist/{healingFns-ChcvzVB8.cjs → healingFns-D4HAilgL.cjs} +4 -4
- package/dist/{helpers-CvwerZfP.js → helpers-BipNXMsi.js} +6 -6
- package/dist/{helpers-C9PIppuU.cjs → helpers-uUXFl5Pn.cjs} +6 -6
- package/dist/{importFns-Bt9YEImO.cjs → importFns-CCnECEQt.cjs} +2 -2
- package/dist/{importFns-DSY1pI70.js → importFns-lWFKWnCe.js} +2 -2
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/{loftFns-Bl8reWqk.js → loftFns-BNziMKOW.js} +1 -1
- package/dist/{loftFns-CdwKSxw1.cjs → loftFns-DUyKz3r7.cjs} +1 -1
- package/dist/{measureFns-DtiZvj_X.js → measureFns-D9lwC7kw.js} +3 -3
- package/dist/{measureFns-B-UbL3Rw.cjs → measureFns-K2jBIt9p.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-B461Ku2S.cjs → meshFns-D0JF9XF8.cjs} +3 -3
- package/dist/{meshFns-CqJScqWa.js → meshFns-D5_15Njg.js} +3 -3
- package/dist/{occtWasmAdapter-G8mkVxgw.cjs → occtWasmAdapter-BnMFWwNp.cjs} +18 -4
- package/dist/{occtWasmAdapter-Bzx2d8zN.js → occtWasmAdapter-Cu1SW10s.js} +18 -4
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{originTrackingFns-BWA8gv5V.js → originTrackingFns-BZwAfjbF.js} +2 -2
- package/dist/{originTrackingFns-rh_FbN6R.cjs → originTrackingFns-BgWmLwox.cjs} +2 -2
- package/dist/{primitiveFns-BTxppy_Y.cjs → primitiveFns-B_09AGpd.cjs} +4 -4
- package/dist/{primitiveFns-C-p7jKZt.js → primitiveFns-p0NdUf-t.js} +4 -4
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-DEU2yvJU.cjs → refResolveFns-Cin3djM3.cjs} +6 -6
- package/dist/{refResolveFns-BPnjuRUW.js → refResolveFns-Dnc4_49q.js} +6 -6
- package/dist/{shapeFns-s6VgcNkU.js → shapeFns-BZnM8fRy.js} +2 -2
- package/dist/{shapeFns-xApQafn6.cjs → shapeFns-D65fk--y.cjs} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-Dz5JzlYx.cjs → shapeTypes-Dq5ylbmP.cjs} +1 -1
- package/dist/{shapeTypes-D3bntzog.js → shapeTypes-JD6SSVwZ.js} +1 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-B3EZcVNw.cjs → solidBuilders-Bm4P-jGM.cjs} +5 -5
- package/dist/{solidBuilders-FOfRGZq0.js → solidBuilders-CIDWhMT6.js} +5 -5
- package/dist/{surfaceBuilders-Dcf7LRqM.js → surfaceBuilders-BC3swenJ.js} +3 -3
- package/dist/{surfaceBuilders-CVLhWPtB.cjs → surfaceBuilders-CxbTUaok.cjs} +3 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-kwXeudLb.js → textBlueprints-75GTk1vk.js} +7 -7
- package/dist/{textBlueprints-hV1kO8tW.cjs → textBlueprints-D1OMdDIP.cjs} +7 -7
- package/dist/{textMetrics-BlhkYGHT.js → textMetrics-DCBkXf-H.js} +1 -1
- package/dist/{textMetrics-BmN3SBkI.cjs → textMetrics-J2bKijAB.cjs} +1 -1
- package/dist/{threadFns-Dd0C7WLp.cjs → threadFns-9Xvow5fk.cjs} +7 -7
- package/dist/{threadFns-CQErpnNd.js → threadFns-D55B4LJk.js} +7 -7
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-qvptbhqO.js → topologyQueryFns-G6xu8ExU.js} +1 -1
- package/dist/{topologyQueryFns-DzYSYw51.cjs → topologyQueryFns-nT3Ir1y-.cjs} +1 -1
- package/dist/{validityTypes-Beci6AC-.cjs → validityTypes-OvTu-S-y.cjs} +1 -1
- package/dist/{validityTypes-DF2h0WJo.js → validityTypes-seS7aZI9.js} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG F.6.5 endpoint parameterization for elliptical arcs: given the two
|
|
3
|
+
* endpoints, an interior on-arc sample, and the ellipse frame (radii + x-axis
|
|
4
|
+
* rotation), recover which of the candidate arcs the curve traces. Trimmed
|
|
5
|
+
* curve bounds cannot decide this — occt-wasm reports them normalized to
|
|
6
|
+
* [0, 1], not as angles — so the flags must come from geometry.
|
|
7
|
+
*/
|
|
8
|
+
type Pt = readonly [number, number];
|
|
9
|
+
/**
|
|
10
|
+
* Derive elliptical-arc flags from endpoints and an interior on-arc sample:
|
|
11
|
+
* `largeArc` when the traced sweep exceeds half a revolution, `ccw` when the
|
|
12
|
+
* arc runs counterclockwise from `from` to `to`. Returns null when the
|
|
13
|
+
* endpoints coincide (a closed loop or degenerate arc; the caller decides how
|
|
14
|
+
* to emit those).
|
|
15
|
+
*/
|
|
16
|
+
export declare function ellipseArcFlags(from: Pt, to: Pt, onArc: Pt, majorRadius: number, minorRadius: number, xAxisAngle: number): {
|
|
17
|
+
largeArc: boolean;
|
|
18
|
+
ccw: boolean;
|
|
19
|
+
} | null;
|
|
20
|
+
export {};
|
package/dist/2d.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-Dq5ylbmP.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_blueprint = require("./blueprint-
|
|
7
|
-
const require_boolean2D = require("./boolean2D-
|
|
8
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-nT3Ir1y-.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-C9lVrRBr.cjs");
|
|
6
|
+
const require_blueprint = require("./blueprint-SQlROOFK.cjs");
|
|
7
|
+
const require_boolean2D = require("./boolean2D-Bh07EPIS.cjs");
|
|
8
|
+
const require_blueprintFns = require("./blueprintFns-BcWGUCk3.cjs");
|
|
9
9
|
//#region src/core/curve2dHandle.ts
|
|
10
10
|
/**
|
|
11
11
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
package/dist/2d.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { P as createKernelHandle, c as createEdge, q as getKernel2D } from "./shapeTypes-
|
|
1
|
+
import { P as createKernelHandle, c as createEdge, q as getKernel2D } from "./shapeTypes-JD6SSVwZ.js";
|
|
2
2
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
3
|
-
import { T as kernelCallRaw } from "./topologyQueryFns-
|
|
4
|
-
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-
|
|
5
|
-
import {
|
|
6
|
-
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-
|
|
7
|
-
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-
|
|
3
|
+
import { T as kernelCallRaw } from "./topologyQueryFns-G6xu8ExU.js";
|
|
4
|
+
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-HsSFy10k.js";
|
|
5
|
+
import { t as Blueprint, v as Curve2D, x as BoundingBox2d } from "./blueprint-Be2V1tdb.js";
|
|
6
|
+
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-CwFJsT_T.js";
|
|
7
|
+
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-DpZo8T6u.js";
|
|
8
8
|
//#region src/core/curve2dHandle.ts
|
|
9
9
|
/**
|
|
10
10
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_occtWasmAdapter = require("./occtWasmAdapter-
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-Dq5ylbmP.cjs");
|
|
2
|
+
const require_occtWasmAdapter = require("./occtWasmAdapter-BnMFWwNp.cjs");
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-nT3Ir1y-.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as getActiveKernelId, K as getKernel, r as castResultShapeWithKnownType, t as borrowShapeWithKnownType } from "./shapeTypes-
|
|
2
|
-
import { O as isUnsupportedKernelOperationError } from "./occtWasmAdapter-
|
|
3
|
-
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-
|
|
1
|
+
import { G as getActiveKernelId, K as getKernel, r as castResultShapeWithKnownType, t as borrowShapeWithKnownType } from "./shapeTypes-JD6SSVwZ.js";
|
|
2
|
+
import { O as isUnsupportedKernelOperationError } from "./occtWasmAdapter-Cu1SW10s.js";
|
|
3
|
+
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-G6xu8ExU.js";
|
|
4
4
|
import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { K as getKernel, L as registerForCleanup, c as createEdge, p as createWire, q as getKernel2D, z as unregisterFromCleanup } from "./shapeTypes-
|
|
1
|
+
import { K as getKernel, L as registerForCleanup, c as createEdge, p as createWire, q as getKernel2D, z as unregisterFromCleanup } from "./shapeTypes-JD6SSVwZ.js";
|
|
2
2
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
3
3
|
import { E as ok, P as unwrap, d as validationError, g as err, n as computationError } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
6
6
|
import { r as makePlane } from "./planeOps-CQahLrCx.js";
|
|
7
|
-
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-
|
|
8
|
-
import { p as getOrientation } from "./curveFns-
|
|
7
|
+
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-C-SjeGpG.js";
|
|
8
|
+
import { p as getOrientation } from "./curveFns-CO0dlocY.js";
|
|
9
9
|
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
10
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
11
|
-
import { l as add2d, m as normalize2d$1, p as distance2d, t as getSingleFace, v as samePoint, x as subtract2d, y as scalarMultiply2d } from "./helpers-
|
|
10
|
+
import { r as makeFace } from "./surfaceBuilders-BC3swenJ.js";
|
|
11
|
+
import { l as add2d, m as normalize2d$1, p as distance2d, t as getSingleFace, v as samePoint, x as subtract2d, y as scalarMultiply2d } from "./helpers-BipNXMsi.js";
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -528,6 +528,59 @@ var make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
|
|
|
528
528
|
return make2dThreePointArc(startPoint, add2d(scalarMultiply2d(midChordDir, orientedRadius), center), endPoint);
|
|
529
529
|
};
|
|
530
530
|
//#endregion
|
|
531
|
+
//#region src/2d/lib/ellipseArcFlags.ts
|
|
532
|
+
function rotInto(p, phi) {
|
|
533
|
+
const c = Math.cos(phi);
|
|
534
|
+
const s = Math.sin(phi);
|
|
535
|
+
return [c * p[0] + s * p[1], -s * p[0] + c * p[1]];
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Derive elliptical-arc flags from endpoints and an interior on-arc sample:
|
|
539
|
+
* `largeArc` when the traced sweep exceeds half a revolution, `ccw` when the
|
|
540
|
+
* arc runs counterclockwise from `from` to `to`. Returns null when the
|
|
541
|
+
* endpoints coincide (a closed loop or degenerate arc; the caller decides how
|
|
542
|
+
* to emit those).
|
|
543
|
+
*/
|
|
544
|
+
function ellipseArcFlags(from, to, onArc, majorRadius, minorRadius, xAxisAngle) {
|
|
545
|
+
let a = majorRadius;
|
|
546
|
+
let b = minorRadius;
|
|
547
|
+
const f = rotInto(from, xAxisAngle);
|
|
548
|
+
const l = rotInto(to, xAxisAngle);
|
|
549
|
+
const m = rotInto(onArc, xAxisAngle);
|
|
550
|
+
const hx = (f[0] - l[0]) / 2;
|
|
551
|
+
const hy = (f[1] - l[1]) / 2;
|
|
552
|
+
const lam = hx * hx / (a * a) + hy * hy / (b * b);
|
|
553
|
+
if (lam < 1e-18) return null;
|
|
554
|
+
if (lam > 1) {
|
|
555
|
+
const s = Math.sqrt(lam);
|
|
556
|
+
a *= s;
|
|
557
|
+
b *= s;
|
|
558
|
+
}
|
|
559
|
+
const num = a * a * b * b - a * a * hy * hy - b * b * hx * hx;
|
|
560
|
+
const den = a * a * hy * hy + b * b * hx * hx;
|
|
561
|
+
if (den === 0) return null;
|
|
562
|
+
const coef = Math.sqrt(Math.max(0, num / den));
|
|
563
|
+
const mx = (f[0] + l[0]) / 2;
|
|
564
|
+
const my = (f[1] + l[1]) / 2;
|
|
565
|
+
const candidates = [[mx + coef * a * hy / b, my - coef * b * hx / a], [mx - coef * a * hy / b, my + coef * b * hx / a]];
|
|
566
|
+
const residual = (c) => {
|
|
567
|
+
const dx = (m[0] - c[0]) / a;
|
|
568
|
+
const dy = (m[1] - c[1]) / b;
|
|
569
|
+
return Math.abs(dx * dx + dy * dy - 1);
|
|
570
|
+
};
|
|
571
|
+
const center = residual(candidates[0]) <= residual(candidates[1]) ? candidates[0] : candidates[1];
|
|
572
|
+
const theta = (p) => Math.atan2((p[1] - center[1]) / b, (p[0] - center[0]) / a);
|
|
573
|
+
const tau = 2 * Math.PI;
|
|
574
|
+
const tf = theta(f);
|
|
575
|
+
const tm = ((theta(m) - tf) % tau + tau) % tau;
|
|
576
|
+
const tl = ((theta(l) - tf) % tau + tau) % tau;
|
|
577
|
+
const ccw = tm < tl;
|
|
578
|
+
return {
|
|
579
|
+
largeArc: (ccw ? tl : tau - tl) > Math.PI,
|
|
580
|
+
ccw
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
531
584
|
//#region src/2d/lib/svgPath.ts
|
|
532
585
|
/**
|
|
533
586
|
* Convert a 2D curve to an SVG path command string.
|
|
@@ -599,11 +652,14 @@ var adaptedCurveToPathElem = (curve, lastPoint) => {
|
|
|
599
652
|
const ellipseData = k2d.getCurve2dEllipseData(curve.wrapped);
|
|
600
653
|
if (!ellipseData) bug("adaptedCurveToPathElem", "Expected ellipse data");
|
|
601
654
|
const { majorRadius: rx, minorRadius: ry, xAxisAngle, isDirect } = ellipseData;
|
|
602
|
-
const bounds = k2d.getCurve2dBounds(curve.wrapped);
|
|
603
|
-
const paramAngle = (bounds.last - bounds.first) * RAD2DEG;
|
|
604
|
-
const end = paramAngle !== 360 ? endpoint : `${round5(endX)} ${round5(endY + 1e-4)}`;
|
|
605
655
|
const angle = 180 - xAxisAngle * RAD2DEG;
|
|
606
|
-
|
|
656
|
+
const [startX, startY] = curve.firstPoint;
|
|
657
|
+
if (samePoint([startX, startY], [endX, endY])) return `A ${round5(rx)} ${round5(ry)} ${round5(angle)} 1 ${isDirect ? "1" : "0"} ${round5(endX)} ${round5(endY + 1e-4)}`;
|
|
658
|
+
const bounds = k2d.getCurve2dBounds(curve.wrapped);
|
|
659
|
+
const [midX, midY] = curve.value((bounds.first + bounds.last) / 2);
|
|
660
|
+
const flags = ellipseArcFlags([startX, startY], [endX, endY], [midX, midY], rx, ry, xAxisAngle);
|
|
661
|
+
if (!flags) return `L ${endpoint}`;
|
|
662
|
+
return `A ${round5(rx)} ${round5(ry)} ${round5(angle)} ${flags.largeArc ? "1" : "0"} ${flags.ccw ? "1" : "0"} ${endpoint}`;
|
|
607
663
|
}
|
|
608
664
|
bug("adaptedCurveToPathElem", `Unsupported curve type: ${curveType}`);
|
|
609
665
|
};
|
|
@@ -1058,4 +1114,4 @@ var Blueprint = class Blueprint {
|
|
|
1058
1114
|
}
|
|
1059
1115
|
};
|
|
1060
1116
|
//#endregion
|
|
1061
|
-
export { isPoint2D as S,
|
|
1117
|
+
export { isPoint2D as C, removeDuplicatePoints as S, approximateAsSvgCompatibleCurve as _, edgeToCurve as a, normalize2d as b, make2dBezierCurve as c, make2dEllipseArc as d, make2dInerpolatedBSplineCurve as f, approximateAsBSpline as g, make2dThreePointArc as h, curvesAsEdgesOnPlane as i, make2dCircle as l, make2dTangentArc as m, asSVG as n, ellipseArcFlags as o, make2dSegmentCurve as p, viewbox as r, make2dArcFromCenter as s, Blueprint as t, make2dEllipse as u, Curve2D as v, BoundingBox2d as x, deserializeCurve2D as y };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-Dq5ylbmP.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
6
6
|
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
7
|
-
const require_faceFns = require("./faceFns-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
7
|
+
const require_faceFns = require("./faceFns-9lfp_6de.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-dXPHWXhw.cjs");
|
|
9
9
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
10
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
11
|
-
const require_helpers = require("./helpers-
|
|
10
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CxbTUaok.cjs");
|
|
11
|
+
const require_helpers = require("./helpers-uUXFl5Pn.cjs");
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -528,6 +528,59 @@ var make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
|
|
|
528
528
|
return make2dThreePointArc(startPoint, require_helpers.add2d(require_helpers.scalarMultiply2d(midChordDir, orientedRadius), center), endPoint);
|
|
529
529
|
};
|
|
530
530
|
//#endregion
|
|
531
|
+
//#region src/2d/lib/ellipseArcFlags.ts
|
|
532
|
+
function rotInto(p, phi) {
|
|
533
|
+
const c = Math.cos(phi);
|
|
534
|
+
const s = Math.sin(phi);
|
|
535
|
+
return [c * p[0] + s * p[1], -s * p[0] + c * p[1]];
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Derive elliptical-arc flags from endpoints and an interior on-arc sample:
|
|
539
|
+
* `largeArc` when the traced sweep exceeds half a revolution, `ccw` when the
|
|
540
|
+
* arc runs counterclockwise from `from` to `to`. Returns null when the
|
|
541
|
+
* endpoints coincide (a closed loop or degenerate arc; the caller decides how
|
|
542
|
+
* to emit those).
|
|
543
|
+
*/
|
|
544
|
+
function ellipseArcFlags(from, to, onArc, majorRadius, minorRadius, xAxisAngle) {
|
|
545
|
+
let a = majorRadius;
|
|
546
|
+
let b = minorRadius;
|
|
547
|
+
const f = rotInto(from, xAxisAngle);
|
|
548
|
+
const l = rotInto(to, xAxisAngle);
|
|
549
|
+
const m = rotInto(onArc, xAxisAngle);
|
|
550
|
+
const hx = (f[0] - l[0]) / 2;
|
|
551
|
+
const hy = (f[1] - l[1]) / 2;
|
|
552
|
+
const lam = hx * hx / (a * a) + hy * hy / (b * b);
|
|
553
|
+
if (lam < 1e-18) return null;
|
|
554
|
+
if (lam > 1) {
|
|
555
|
+
const s = Math.sqrt(lam);
|
|
556
|
+
a *= s;
|
|
557
|
+
b *= s;
|
|
558
|
+
}
|
|
559
|
+
const num = a * a * b * b - a * a * hy * hy - b * b * hx * hx;
|
|
560
|
+
const den = a * a * hy * hy + b * b * hx * hx;
|
|
561
|
+
if (den === 0) return null;
|
|
562
|
+
const coef = Math.sqrt(Math.max(0, num / den));
|
|
563
|
+
const mx = (f[0] + l[0]) / 2;
|
|
564
|
+
const my = (f[1] + l[1]) / 2;
|
|
565
|
+
const candidates = [[mx + coef * a * hy / b, my - coef * b * hx / a], [mx - coef * a * hy / b, my + coef * b * hx / a]];
|
|
566
|
+
const residual = (c) => {
|
|
567
|
+
const dx = (m[0] - c[0]) / a;
|
|
568
|
+
const dy = (m[1] - c[1]) / b;
|
|
569
|
+
return Math.abs(dx * dx + dy * dy - 1);
|
|
570
|
+
};
|
|
571
|
+
const center = residual(candidates[0]) <= residual(candidates[1]) ? candidates[0] : candidates[1];
|
|
572
|
+
const theta = (p) => Math.atan2((p[1] - center[1]) / b, (p[0] - center[0]) / a);
|
|
573
|
+
const tau = 2 * Math.PI;
|
|
574
|
+
const tf = theta(f);
|
|
575
|
+
const tm = ((theta(m) - tf) % tau + tau) % tau;
|
|
576
|
+
const tl = ((theta(l) - tf) % tau + tau) % tau;
|
|
577
|
+
const ccw = tm < tl;
|
|
578
|
+
return {
|
|
579
|
+
largeArc: (ccw ? tl : tau - tl) > Math.PI,
|
|
580
|
+
ccw
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
531
584
|
//#region src/2d/lib/svgPath.ts
|
|
532
585
|
/**
|
|
533
586
|
* Convert a 2D curve to an SVG path command string.
|
|
@@ -599,11 +652,14 @@ var adaptedCurveToPathElem = (curve, lastPoint) => {
|
|
|
599
652
|
const ellipseData = k2d.getCurve2dEllipseData(curve.wrapped);
|
|
600
653
|
if (!ellipseData) require_bug.bug("adaptedCurveToPathElem", "Expected ellipse data");
|
|
601
654
|
const { majorRadius: rx, minorRadius: ry, xAxisAngle, isDirect } = ellipseData;
|
|
602
|
-
const bounds = k2d.getCurve2dBounds(curve.wrapped);
|
|
603
|
-
const paramAngle = (bounds.last - bounds.first) * require_constants.RAD2DEG;
|
|
604
|
-
const end = paramAngle !== 360 ? endpoint : `${round5(endX)} ${round5(endY + 1e-4)}`;
|
|
605
655
|
const angle = 180 - xAxisAngle * require_constants.RAD2DEG;
|
|
606
|
-
|
|
656
|
+
const [startX, startY] = curve.firstPoint;
|
|
657
|
+
if (require_helpers.samePoint([startX, startY], [endX, endY])) return `A ${round5(rx)} ${round5(ry)} ${round5(angle)} 1 ${isDirect ? "1" : "0"} ${round5(endX)} ${round5(endY + 1e-4)}`;
|
|
658
|
+
const bounds = k2d.getCurve2dBounds(curve.wrapped);
|
|
659
|
+
const [midX, midY] = curve.value((bounds.first + bounds.last) / 2);
|
|
660
|
+
const flags = ellipseArcFlags([startX, startY], [endX, endY], [midX, midY], rx, ry, xAxisAngle);
|
|
661
|
+
if (!flags) return `L ${endpoint}`;
|
|
662
|
+
return `A ${round5(rx)} ${round5(ry)} ${round5(angle)} ${flags.largeArc ? "1" : "0"} ${flags.ccw ? "1" : "0"} ${endpoint}`;
|
|
607
663
|
}
|
|
608
664
|
require_bug.bug("adaptedCurveToPathElem", `Unsupported curve type: ${curveType}`);
|
|
609
665
|
};
|
|
@@ -1112,6 +1168,12 @@ Object.defineProperty(exports, "edgeToCurve", {
|
|
|
1112
1168
|
return edgeToCurve;
|
|
1113
1169
|
}
|
|
1114
1170
|
});
|
|
1171
|
+
Object.defineProperty(exports, "ellipseArcFlags", {
|
|
1172
|
+
enumerable: true,
|
|
1173
|
+
get: function() {
|
|
1174
|
+
return ellipseArcFlags;
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1115
1177
|
Object.defineProperty(exports, "isPoint2D", {
|
|
1116
1178
|
enumerable: true,
|
|
1117
1179
|
get: function() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
2
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
3
|
-
const require_blueprint = require("./blueprint-
|
|
2
|
+
const require_blueprintSketcher = require("./blueprintSketcher-C9lVrRBr.cjs");
|
|
3
|
+
const require_blueprint = require("./blueprint-SQlROOFK.cjs");
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
2
|
-
import { i as CompoundBlueprint } from "./blueprintSketcher-
|
|
3
|
-
import { t as Blueprint } from "./blueprint-
|
|
2
|
+
import { i as CompoundBlueprint } from "./blueprintSketcher-HsSFy10k.js";
|
|
3
|
+
import { t as Blueprint } from "./blueprint-Be2V1tdb.js";
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-Dq5ylbmP.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
6
|
-
const require_helpers = require("./helpers-
|
|
7
|
-
const require_blueprint = require("./blueprint-
|
|
6
|
+
const require_helpers = require("./helpers-uUXFl5Pn.cjs");
|
|
7
|
+
const require_blueprint = require("./blueprint-SQlROOFK.cjs");
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { K as getKernel, q as getKernel2D } from "./shapeTypes-
|
|
1
|
+
import { K as getKernel, q as getKernel2D } from "./shapeTypes-JD6SSVwZ.js";
|
|
2
2
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
3
3
|
import { E as ok, P as unwrap, g as err, n as computationError, s as safeIndex, x as isOk } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
6
|
-
import { _ as rotate2d, d as cartesianToPolar, f as crossProduct2d, g as polarToCartesian, h as polarAngle2d, l as add2d, p as distance2d, v as samePoint, x as subtract2d, y as scalarMultiply2d } from "./helpers-
|
|
7
|
-
import {
|
|
6
|
+
import { _ as rotate2d, d as cartesianToPolar, f as crossProduct2d, g as polarToCartesian, h as polarAngle2d, l as add2d, p as distance2d, v as samePoint, x as subtract2d, y as scalarMultiply2d } from "./helpers-BipNXMsi.js";
|
|
7
|
+
import { C as isPoint2D, b as normalize2d, c as make2dBezierCurve, d as make2dEllipseArc, g as approximateAsBSpline, h as make2dThreePointArc, l as make2dCircle, m as make2dTangentArc, n as asSVG, p as make2dSegmentCurve, r as viewbox, s as make2dArcFromCenter, t as Blueprint, v as Curve2D, x as BoundingBox2d } from "./blueprint-Be2V1tdb.js";
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
2
2
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
3
3
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
4
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_helpers = require("./helpers-
|
|
7
|
-
const require_blueprint = require("./blueprint-
|
|
4
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CxbTUaok.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-C9lVrRBr.cjs");
|
|
6
|
+
const require_helpers = require("./helpers-uUXFl5Pn.cjs");
|
|
7
|
+
const require_blueprint = require("./blueprint-SQlROOFK.cjs");
|
|
8
8
|
//#region src/2d/blueprints/cannedBlueprints.ts
|
|
9
9
|
/**
|
|
10
10
|
* Create a regular polygon blueprint inscribed in a circle of the given radius.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
2
2
|
import { P as unwrap, s as safeIndex } from "./errors-MHLiNE-C.js";
|
|
3
3
|
import { r as lastOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
4
|
-
import { v as zip } from "./surfaceBuilders-
|
|
5
|
-
import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-
|
|
6
|
-
import { f as crossProduct2d, o as PRECISION_INTERSECTION, v as samePoint$1, x as subtract2d } from "./helpers-
|
|
7
|
-
import {
|
|
4
|
+
import { v as zip } from "./surfaceBuilders-BC3swenJ.js";
|
|
5
|
+
import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-HsSFy10k.js";
|
|
6
|
+
import { f as crossProduct2d, o as PRECISION_INTERSECTION, v as samePoint$1, x as subtract2d } from "./helpers-BipNXMsi.js";
|
|
7
|
+
import { S as removeDuplicatePoints, p as make2dSegmentCurve, t as Blueprint } from "./blueprint-Be2V1tdb.js";
|
|
8
8
|
//#region src/2d/blueprints/cannedBlueprints.ts
|
|
9
9
|
/**
|
|
10
10
|
* Create a regular polygon blueprint inscribed in a circle of the given radius.
|
package/dist/brepjs.cjs
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
3
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
4
|
-
const require_occtWasmAdapter = require("./occtWasmAdapter-
|
|
3
|
+
const require_shapeTypes = require("./shapeTypes-Dq5ylbmP.cjs");
|
|
4
|
+
const require_occtWasmAdapter = require("./occtWasmAdapter-BnMFWwNp.cjs");
|
|
5
5
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
6
6
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
7
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
8
|
-
const require_validityTypes = require("./validityTypes-
|
|
7
|
+
const require_topologyQueryFns = require("./topologyQueryFns-nT3Ir1y-.cjs");
|
|
8
|
+
const require_validityTypes = require("./validityTypes-OvTu-S-y.cjs");
|
|
9
9
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
10
10
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
11
11
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
12
12
|
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
13
|
-
const require_faceFns = require("./faceFns-
|
|
14
|
-
const require_originTrackingFns = require("./originTrackingFns-
|
|
15
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
16
|
-
const require_primitiveFns = require("./primitiveFns-
|
|
17
|
-
const require_shapeFns = require("./shapeFns-
|
|
18
|
-
const require_curveFns = require("./curveFns-
|
|
19
|
-
const require_meshFns = require("./meshFns-
|
|
13
|
+
const require_faceFns = require("./faceFns-9lfp_6de.cjs");
|
|
14
|
+
const require_originTrackingFns = require("./originTrackingFns-BgWmLwox.cjs");
|
|
15
|
+
const require_solidBuilders = require("./solidBuilders-Bm4P-jGM.cjs");
|
|
16
|
+
const require_primitiveFns = require("./primitiveFns-B_09AGpd.cjs");
|
|
17
|
+
const require_shapeFns = require("./shapeFns-D65fk--y.cjs");
|
|
18
|
+
const require_curveFns = require("./curveFns-dXPHWXhw.cjs");
|
|
19
|
+
const require_meshFns = require("./meshFns-D0JF9XF8.cjs");
|
|
20
20
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
21
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
22
|
-
const require_healingFns = require("./healingFns-
|
|
23
|
-
const require_threadFns = require("./threadFns-
|
|
24
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
25
|
-
const require_helpers = require("./helpers-
|
|
26
|
-
const require_blueprint = require("./blueprint-
|
|
27
|
-
const require_drawFns = require("./drawFns-
|
|
28
|
-
const require_measureFns = require("./measureFns-
|
|
29
|
-
const require_cornerFinder = require("./cornerFinder-
|
|
30
|
-
const require_boolean2D = require("./boolean2D-
|
|
31
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
32
|
-
const require_importFns = require("./importFns-
|
|
33
|
-
const require_loftFns = require("./loftFns-
|
|
34
|
-
const require_textBlueprints = require("./textBlueprints-
|
|
35
|
-
const require_refResolveFns = require("./refResolveFns-
|
|
36
|
-
const require_adjacencyFns = require("./adjacencyFns-
|
|
37
|
-
const require_cameraFns = require("./cameraFns-
|
|
38
|
-
const require_textMetrics = require("./textMetrics-
|
|
21
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CxbTUaok.cjs");
|
|
22
|
+
const require_healingFns = require("./healingFns-D4HAilgL.cjs");
|
|
23
|
+
const require_threadFns = require("./threadFns-9Xvow5fk.cjs");
|
|
24
|
+
const require_blueprintSketcher = require("./blueprintSketcher-C9lVrRBr.cjs");
|
|
25
|
+
const require_helpers = require("./helpers-uUXFl5Pn.cjs");
|
|
26
|
+
const require_blueprint = require("./blueprint-SQlROOFK.cjs");
|
|
27
|
+
const require_drawFns = require("./drawFns-C_dvmPvb.cjs");
|
|
28
|
+
const require_measureFns = require("./measureFns-K2jBIt9p.cjs");
|
|
29
|
+
const require_cornerFinder = require("./cornerFinder-B_6OVtcc.cjs");
|
|
30
|
+
const require_boolean2D = require("./boolean2D-Bh07EPIS.cjs");
|
|
31
|
+
const require_blueprintFns = require("./blueprintFns-BcWGUCk3.cjs");
|
|
32
|
+
const require_importFns = require("./importFns-CCnECEQt.cjs");
|
|
33
|
+
const require_loftFns = require("./loftFns-DUyKz3r7.cjs");
|
|
34
|
+
const require_textBlueprints = require("./textBlueprints-D1OMdDIP.cjs");
|
|
35
|
+
const require_refResolveFns = require("./refResolveFns-Cin3djM3.cjs");
|
|
36
|
+
const require_adjacencyFns = require("./adjacencyFns-B1FEq-7P.cjs");
|
|
37
|
+
const require_cameraFns = require("./cameraFns-BYBavyGz.cjs");
|
|
38
|
+
const require_textMetrics = require("./textMetrics-J2bKijAB.cjs");
|
|
39
39
|
const require_workerPool = require("./workerPool-D30NsiIW.cjs");
|
|
40
40
|
//#region src/kernel/types.ts
|
|
41
41
|
/** Check if the kernel supports hidden-line-removal projection. */
|
|
@@ -4754,51 +4754,15 @@ function threePointsToArc(from, mid, to) {
|
|
|
4754
4754
|
clockwise
|
|
4755
4755
|
}));
|
|
4756
4756
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
const s = Math.sin(phi);
|
|
4760
|
-
return [c * p[0] + s * p[1], -s * p[0] + c * p[1]];
|
|
4761
|
-
}
|
|
4762
|
-
/** Endpoint-parametrized ellipse-arc flags via SVG F.6.5 candidate centers,
|
|
4763
|
-
* disambiguated by an on-arc interior sample. */
|
|
4757
|
+
/** Endpoint-parametrized ellipse-arc flags via SVG F.6.5 candidate centers
|
|
4758
|
+
* (shared with the SVG emitter), disambiguated by an on-arc interior sample. */
|
|
4764
4759
|
function ellipseArcSegment(from, to, mid, frame) {
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
const f = rotInto(from, phi);
|
|
4768
|
-
const l = rotInto(to, phi);
|
|
4769
|
-
const m = rotInto(mid, phi);
|
|
4770
|
-
const hx = (f[0] - l[0]) / 2;
|
|
4771
|
-
const hy = (f[1] - l[1]) / 2;
|
|
4772
|
-
const lam = hx * hx / (a * a) + hy * hy / (b * b);
|
|
4773
|
-
if (lam > 1) {
|
|
4774
|
-
const s = Math.sqrt(lam);
|
|
4775
|
-
a *= s;
|
|
4776
|
-
b *= s;
|
|
4777
|
-
}
|
|
4778
|
-
const num = a * a * b * b - a * a * hy * hy - b * b * hx * hx;
|
|
4779
|
-
const den = a * a * hy * hy + b * b * hx * hx;
|
|
4780
|
-
if (den < 1e-12) return fail("ellipse: coincident endpoints");
|
|
4781
|
-
const coef = Math.sqrt(Math.max(0, num / den));
|
|
4782
|
-
const mx = (f[0] + l[0]) / 2;
|
|
4783
|
-
const my = (f[1] + l[1]) / 2;
|
|
4784
|
-
const candidates = [[mx + coef * a * hy / b, my - coef * b * hx / a], [mx - coef * a * hy / b, my + coef * b * hx / a]];
|
|
4785
|
-
const residual = (c) => {
|
|
4786
|
-
const dx = (m[0] - c[0]) / a;
|
|
4787
|
-
const dy = (m[1] - c[1]) / b;
|
|
4788
|
-
return Math.abs(dx * dx + dy * dy - 1);
|
|
4789
|
-
};
|
|
4790
|
-
const center = residual(candidates[0]) <= residual(candidates[1]) ? candidates[0] : candidates[1];
|
|
4791
|
-
const theta = (p) => Math.atan2((p[1] - center[1]) / b, (p[0] - center[0]) / a);
|
|
4792
|
-
const tau = 2 * Math.PI;
|
|
4793
|
-
const tf = theta(f);
|
|
4794
|
-
const tm = ((theta(m) - tf) % tau + tau) % tau;
|
|
4795
|
-
const tl = ((theta(l) - tf) % tau + tau) % tau;
|
|
4796
|
-
const ccw = tm < tl;
|
|
4797
|
-
const sweep = ccw ? tl : tau - tl;
|
|
4760
|
+
const flags = require_blueprint.ellipseArcFlags(from, to, mid, frame.a, frame.b, frame.phi);
|
|
4761
|
+
if (!flags) return fail("ellipse: coincident endpoints");
|
|
4798
4762
|
return require_errors.ok(ellipseArcTo(to, [frame.a, frame.b], {
|
|
4799
|
-
rotation: phi * 180 / Math.PI,
|
|
4800
|
-
largeArc:
|
|
4801
|
-
clockwise: !ccw
|
|
4763
|
+
rotation: frame.phi * 180 / Math.PI,
|
|
4764
|
+
largeArc: flags.largeArc,
|
|
4765
|
+
clockwise: !flags.ccw
|
|
4802
4766
|
}));
|
|
4803
4767
|
}
|
|
4804
4768
|
/** A closed CIRCLE/ELLIPSE curve becomes two half segments between antipodal
|