@weasel-js/geom 1.7.3 → 1.8.1
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/README.md +1 -0
- package/dist/3d/index.d.ts +1 -1
- package/dist/3d/index.js +7 -12
- package/dist/3d/index.js.map +1 -1
- package/dist/{chunk-TXEGHCJ4.js → chunk-YQADYJJ7.js} +9 -3
- package/dist/chunk-YQADYJJ7.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -13
- package/dist/index.js.map +1 -1
- package/dist/nd/index.d.ts +30 -0
- package/dist/nd/index.js +3 -0
- package/dist/nd/index.js.map +1 -0
- package/package.json +5 -1
- package/dist/chunk-TXEGHCJ4.js.map +0 -1
- package/dist/portCurve-BBr7eHAL.d.ts +0 -15
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cubic control points that make a curve leave a port along its normal and
|
|
3
|
+
* arrive at the next against that port's normal — what makes a routed edge read
|
|
4
|
+
* as plugged into a box rather than aimed at it.
|
|
5
|
+
*
|
|
6
|
+
* The rule is stated once, over loose components, and published as is from
|
|
7
|
+
* `./nd`; the 2D barrel and `./3d` each wrap it in their own currency. Every
|
|
8
|
+
* operation here is closed on the plane z = 0, so a planar problem answered
|
|
9
|
+
* through the 3D wrapper returns the same numbers as through the 2D one, not an
|
|
10
|
+
* approximation of them.
|
|
11
|
+
*/
|
|
12
|
+
/** How far a control point reaches toward the other end, as a fraction of the
|
|
13
|
+
* straight-line distance between the two. */
|
|
14
|
+
declare const PORT_REACH = 0.4;
|
|
15
|
+
/**
|
|
16
|
+
* `[c1, c2]` for the cubic from `a` to `b`.
|
|
17
|
+
*
|
|
18
|
+
* A null normal falls back to a plain lerp along the chord, which is what makes
|
|
19
|
+
* an unported waypoint curve smoothly instead of kinking. The two ends are not
|
|
20
|
+
* symmetric: `outNormal` points the way the curve departs, while `inNormal`
|
|
21
|
+
* points out of the receiving port, so `c2` is pushed *along* it to arrive
|
|
22
|
+
* against it.
|
|
23
|
+
*/
|
|
24
|
+
declare function portControls(a: readonly number[], b: readonly number[], outNormal: readonly number[] | null | undefined, inNormal: readonly number[] | null | undefined, reach?: number): [number[], number[]];
|
|
25
|
+
/** A port curve sampled into `samples` points, excluding its start. */
|
|
26
|
+
declare function portCurvePoints(a: readonly number[], b: readonly number[], outNormal: readonly number[] | null | undefined, inNormal: readonly number[] | null | undefined, samples: number, reach?: number): number[][];
|
|
27
|
+
/** A cubic evaluated at `t`, component-wise, in whatever dimension it was given. */
|
|
28
|
+
declare function cubicAt(p0: readonly number[], p1: readonly number[], p2: readonly number[], p3: readonly number[], t: number): number[];
|
|
29
|
+
|
|
30
|
+
export { PORT_REACH, cubicAt, portControls, portCurvePoints };
|
package/dist/nd/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/geom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Pure geometry kernel for @weasel-js/core: affine, box, curve, polyline, the Path command stream and its math, and easing curves in 2D. Dependency-free core; curve representations in ./curves, tessellation in ./tessellate (earcut), polygon booleans and path splitting in ./booleans (polygon-clipping), vectors, quaternions, 4x4 matrices and ray intersection in ./3d.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"import": "./dist/3d/index.js",
|
|
22
22
|
"types": "./dist/3d/index.d.ts"
|
|
23
23
|
},
|
|
24
|
+
"./nd": {
|
|
25
|
+
"import": "./dist/nd/index.js",
|
|
26
|
+
"types": "./dist/nd/index.d.ts"
|
|
27
|
+
},
|
|
24
28
|
"./curves": {
|
|
25
29
|
"import": "./dist/curves/index.js",
|
|
26
30
|
"types": "./dist/curves/index.d.ts"
|
|
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AA,EACU;AACV,EAAA,MAAM,IAAI,CAAA,GAAI,CAAA;AACd,EAAA,MAAM,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAClB,EAAA,MAAM,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA;AACtB,EAAA,MAAM,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA;AACtB,EAAA,MAAM,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAClB,EAAA,MAAM,MAAgB,EAAC;AACvB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,CAAG,QAAQ,CAAA,EAAA,EAAK;AAClC,IAAA,GAAA,CAAI,KAAK,CAAA,GAAI,EAAA,CAAG,CAAC,CAAA,GAAK,IAAI,EAAA,CAAG,CAAC,CAAA,GAAK,CAAA,GAAI,GAAG,CAAC,CAAA,GAAK,CAAA,GAAI,EAAA,CAAG,CAAC,CAAE,CAAA;AAAA,EAC5D;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-TXEGHCJ4.js","sourcesContent":["/**\n * The cubic control points that make a curve leave a port along its normal and\n * arrive at the next against that port's normal — what makes a routed edge read\n * as plugged into a box rather than aimed at it.\n *\n * The rule is stated once, over loose components, and the 2D barrel and `./3d`\n * each wrap it in their own currency. Every operation here is closed on the\n * plane z = 0, so a planar problem answered through the 3D wrapper returns the\n * same numbers as through the 2D one, not an approximation of them.\n */\n\n/** How far a control point reaches toward the other end, as a fraction of the\n * straight-line distance between the two. */\nexport const PORT_REACH = 0.4;\n\n/**\n * `[c1, c2]` for the cubic from `a` to `b`.\n *\n * A null normal falls back to a plain lerp along the chord, which is what makes\n * an unported waypoint curve smoothly instead of kinking. The two ends are not\n * symmetric: `outNormal` points the way the curve departs, while `inNormal`\n * points out of the receiving port, so `c2` is pushed *along* it to arrive\n * against it.\n */\nexport function portControls(\n a: readonly number[],\n b: readonly number[],\n outNormal: readonly number[] | null | undefined,\n inNormal: readonly number[] | null | undefined,\n reach: number = PORT_REACH,\n): [number[], number[]] {\n let sum = 0;\n for (let i = 0; i < a.length; i++) {\n const d = b[i]! - a[i]!;\n sum += d * d;\n }\n const span = Math.sqrt(sum) * reach;\n\n const c1: number[] = [];\n const c2: number[] = [];\n for (let i = 0; i < a.length; i++) {\n const ai = a[i]!;\n const bi = b[i]!;\n c1.push(outNormal == null ? ai + (bi - ai) * reach : ai + outNormal[i]! * span);\n c2.push(inNormal == null ? bi - (bi - ai) * reach : bi + inNormal[i]! * span);\n }\n return [c1, c2];\n}\n\n/** A cubic evaluated at `t`, component-wise, in whatever dimension it was given. */\nexport function cubicAt(\n p0: readonly number[],\n p1: readonly number[],\n p2: readonly number[],\n p3: readonly number[],\n t: number,\n): number[] {\n const u = 1 - t;\n const a = u * u * u;\n const b = 3 * u * u * t;\n const c = 3 * u * t * t;\n const d = t * t * t;\n const out: number[] = [];\n for (let i = 0; i < p0.length; i++) {\n out.push(a * p0[i]! + b * p1[i]! + c * p2[i]! + d * p3[i]!);\n }\n return out;\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cubic control points that make a curve leave a port along its normal and
|
|
3
|
-
* arrive at the next against that port's normal — what makes a routed edge read
|
|
4
|
-
* as plugged into a box rather than aimed at it.
|
|
5
|
-
*
|
|
6
|
-
* The rule is stated once, over loose components, and the 2D barrel and `./3d`
|
|
7
|
-
* each wrap it in their own currency. Every operation here is closed on the
|
|
8
|
-
* plane z = 0, so a planar problem answered through the 3D wrapper returns the
|
|
9
|
-
* same numbers as through the 2D one, not an approximation of them.
|
|
10
|
-
*/
|
|
11
|
-
/** How far a control point reaches toward the other end, as a fraction of the
|
|
12
|
-
* straight-line distance between the two. */
|
|
13
|
-
declare const PORT_REACH = 0.4;
|
|
14
|
-
|
|
15
|
-
export { PORT_REACH as P };
|