@thi.ng/geom 8.1.38 → 8.1.40

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-04-01T21:42:04Z
3
+ - **Last updated**: 2025-04-16T11:11:14Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -11,6 +11,20 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
11
11
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
12
12
  and/or version bumps of transitive dependencies.
13
13
 
14
+ ### [8.1.39](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@8.1.39) (2025-04-16)
15
+
16
+ #### 🩹 Bug fixes
17
+
18
+ - update `asCubic()` for some 3D shapes ([5abc2aa](https://github.com/thi-ng/umbrella/commit/5abc2aa))
19
+ - update `polygon3`, `polyline3`, `quad3`, `tri3` impls to exclude "break" & "hobby" conversion modes
20
+ (these modes are currently not supported in 3D)
21
+ - add/update docs
22
+ - update sphere/sphere `intersects()` impl ([43f4059](https://github.com/thi-ng/umbrella/commit/43f4059))
23
+
24
+ #### ♻️ Refactoring
25
+
26
+ - minor internal optimizations (vector ops) ([c51b0de](https://github.com/thi-ng/umbrella/commit/c51b0de))
27
+
14
28
  ### [8.1.22](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@8.1.22) (2025-01-14)
15
29
 
16
30
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -451,7 +451,7 @@ For Node.js REPL:
451
451
  const geom = await import("@thi.ng/geom");
452
452
  ```
453
453
 
454
- Package sizes (brotli'd, pre-treeshake): ESM: 17.42 KB
454
+ Package sizes (brotli'd, pre-treeshake): ESM: 17.48 KB
455
455
 
456
456
  ## Dependencies
457
457
 
package/api/aabb.d.ts CHANGED
@@ -9,9 +9,9 @@ export declare class AABB implements AABBLike, IHiccupShape3<AABB> {
9
9
  constructor(pos?: Vec, size?: number | Vec, attribs?: Attribs | undefined);
10
10
  copy(): AABB;
11
11
  withAttribs(attribs: Attribs): AABB;
12
- min(): Vec;
13
- max(): Vec;
12
+ min(): Vec<number>;
13
+ max(): Vec<number>;
14
14
  offset(offset: number): this;
15
- toHiccup(): (string | Vec | Attribs | undefined)[];
15
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
16
16
  }
17
17
  //# sourceMappingURL=aabb.d.ts.map
package/api/apc.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare abstract class APC implements IClear, PCLike {
10
10
  abstract copy(): APC;
11
11
  abstract copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): APC;
12
12
  abstract withAttribs(attribs: Attribs): APC;
13
- [Symbol.iterator](): Generator<Vec, void, unknown>;
13
+ [Symbol.iterator](): Generator<Vec<number>, void, unknown>;
14
14
  clear(): void;
15
15
  }
16
16
  //# sourceMappingURL=apc.d.ts.map
package/api/arc.d.ts CHANGED
@@ -15,9 +15,9 @@ export declare class Arc implements IHiccupShape2<Arc>, IHiccupPathSegment {
15
15
  copy(): Arc;
16
16
  withAttribs(attribs: Attribs): Arc;
17
17
  equiv(o: any): boolean;
18
- pointAt(t: number, out?: Vec): Vec;
19
- pointAtTheta(theta: number, out?: Vec): Vec;
20
- toHiccup(): (string | Attribs | (HiccupPathSegment | (string | Vec)[])[] | undefined)[];
18
+ pointAt(t: number, out?: Vec): Vec<number>;
19
+ pointAtTheta(theta: number, out?: Vec): Vec<number>;
20
+ toHiccup(): (string | Attribs | (HiccupPathSegment | (string | Vec<number>)[])[] | undefined)[];
21
21
  toHiccupPathSegments(): HiccupPathSegment[];
22
22
  }
23
23
  //# sourceMappingURL=arc.d.ts.map
package/api/arc.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  pointAt as arcPointAt,
4
4
  pointAtTheta as arcPointAtTheta
5
5
  } from "@thi.ng/geom-arc/point-at";
6
- import { set } from "@thi.ng/vectors/set";
6
+ import { set2 } from "@thi.ng/vectors/set";
7
7
  import { __copyAttribs } from "../internal/copy.js";
8
8
  class Arc {
9
9
  constructor(pos, r, axis, start, end, xl = false, cw = false, attribs) {
@@ -20,8 +20,8 @@ class Arc {
20
20
  dim = 2;
21
21
  copy() {
22
22
  return new Arc(
23
- set([], this.pos),
24
- set([], this.r),
23
+ set2([], this.pos),
24
+ set2([], this.r),
25
25
  this.axis,
26
26
  this.start,
27
27
  this.end,
package/api/bpatch.d.ts CHANGED
@@ -36,7 +36,7 @@ export declare class BPatch extends APC implements IHiccupShape2<BPatch> {
36
36
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): BPatch;
37
37
  withAttribs(attribs: Attribs): BPatch;
38
38
  edges(): VecPair[];
39
- unmapPoint(uv: ReadonlyVec, out?: Vec): Vec;
39
+ unmapPoint(uv: ReadonlyVec, out?: Vec): Vec<number>;
40
40
  toHiccup(): any[];
41
41
  }
42
42
  //# sourceMappingURL=bpatch.d.ts.map
package/api/circle.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Circle implements IHiccupShape2<Circle> {
9
9
  constructor(pos?: Vec, r?: number, attribs?: Attribs | undefined);
10
10
  copy(): Circle;
11
11
  withAttribs(attribs: Attribs): Circle;
12
- toHiccup(): (string | number | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | number | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=circle.d.ts.map
package/api/cubic.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Cubic extends APC implements IHiccupShape2<Cubic>, IHiccupP
9
9
  copy(): Cubic;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Cubic;
11
11
  withAttribs(attribs: Attribs): Cubic;
12
- toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
12
+ toHiccup(): (string | Attribs | (string | Vec<number>)[][] | undefined)[];
13
13
  toHiccupPathSegments(): HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=cubic.d.ts.map
package/api/cubic3.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Cubic3 extends APC implements IHiccupShape3<Cubic3>, IHiccu
9
9
  copy(): Cubic3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Cubic3;
11
11
  withAttribs(attribs: Attribs): Cubic3;
12
- toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
12
+ toHiccup(): (string | Attribs | (string | Vec<number>)[][] | undefined)[];
13
13
  toHiccupPathSegments(): HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=cubic3.d.ts.map
package/api/ellipse.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Ellipse implements IHiccupShape2<Ellipse> {
9
9
  constructor(pos?: Vec, r?: number | Vec, attribs?: Attribs | undefined);
10
10
  copy(): Ellipse;
11
11
  withAttribs(attribs: Attribs): Ellipse;
12
- toHiccup(): (string | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=ellipse.d.ts.map
package/api/line.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Line extends APC implements IHiccupShape2<Line>, IHiccupPat
9
9
  copy(): Line;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Line;
11
11
  withAttribs(attribs: Attribs): Line;
12
- toHiccup(): (string | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
13
13
  toHiccupPathSegments(): import("../api.js").HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=line.d.ts.map
package/api/line3.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Line3 extends APC implements IHiccupShape3<Line3>, IHiccupP
9
9
  copy(): Line3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Line3;
11
11
  withAttribs(attribs: Attribs): Line3;
12
- toHiccup(): (string | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
13
13
  toHiccupPathSegments(): HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=line3.d.ts.map
package/api/plane.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Plane implements IHiccupShape3<Plane> {
9
9
  constructor(normal?: Vec, w?: number, attribs?: Attribs | undefined);
10
10
  copy(): Plane;
11
11
  withAttribs(attribs: Attribs): Plane;
12
- toHiccup(): (string | number | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | number | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=plane.d.ts.map
package/api/points.d.ts CHANGED
@@ -8,6 +8,6 @@ export declare class Points extends APC implements IHiccupShape2<Points> {
8
8
  copy(): Points;
9
9
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Points;
10
10
  withAttribs(attribs: Attribs): Points;
11
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
11
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
12
12
  }
13
13
  //# sourceMappingURL=points.d.ts.map
package/api/points3.d.ts CHANGED
@@ -8,6 +8,6 @@ export declare class Points3 extends APC implements IHiccupShape3<Points3> {
8
8
  copy(): Points3;
9
9
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Points3;
10
10
  withAttribs(attribs: Attribs): Points3;
11
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
11
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
12
12
  }
13
13
  //# sourceMappingURL=points3.d.ts.map
package/api/polygon.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Polygon extends APC implements IHiccupShape2<Polygon> {
9
9
  copy(): Polygon;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polygon;
11
11
  withAttribs(attribs: Attribs): Polygon;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=polygon.d.ts.map
package/api/polygon3.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Polygon3 extends APC implements IHiccupShape3<Polygon3> {
9
9
  copy(): Polygon3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polygon3;
11
11
  withAttribs(attribs: Attribs): Polygon3;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=polygon3.d.ts.map
package/api/polyline.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Polyline extends APC implements IHiccupShape2<Polyline>, IH
9
9
  copy(): Polyline;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polyline;
11
11
  withAttribs(attribs: Attribs): Polyline;
12
- toHiccup(): (string | Vec[] | {
12
+ toHiccup(): (string | Vec<number>[] | {
13
13
  fill: string;
14
14
  __samples?: Partial<import("../api.js").SamplingOpts> | number;
15
15
  __prec?: number;
@@ -9,7 +9,7 @@ export declare class Polyline3 extends APC implements IHiccupShape3<Polyline3>,
9
9
  copy(): Polyline3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polyline3;
11
11
  withAttribs(attribs: Attribs): Polyline3;
12
- toHiccup(): (string | Vec[] | {
12
+ toHiccup(): (string | Vec<number>[] | {
13
13
  fill: string;
14
14
  __samples?: Partial<import("../api.js").SamplingOpts> | number;
15
15
  __prec?: number;
package/api/quad.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Quad extends APC implements IHiccupShape2<Quad> {
9
9
  copy(): Quad;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quad;
11
11
  withAttribs(attribs: Attribs): Quad;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=quad.d.ts.map
package/api/quad3.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Quad3 extends APC implements IHiccupShape3<Quad3> {
9
9
  copy(): Quad3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quad3;
11
11
  withAttribs(attribs: Attribs): Quad3;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=quad3.d.ts.map
@@ -9,7 +9,7 @@ export declare class Quadratic extends APC implements IHiccupShape2<Quadratic>,
9
9
  copy(): Quadratic;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quadratic;
11
11
  withAttribs(attribs: Attribs): Quadratic;
12
- toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
12
+ toHiccup(): (string | Attribs | (string | Vec<number>)[][] | undefined)[];
13
13
  toHiccupPathSegments(): HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=quadratic.d.ts.map
@@ -9,7 +9,7 @@ export declare class Quadratic3 extends APC implements IHiccupShape3<Quadratic3>
9
9
  copy(): Quadratic3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quadratic3;
11
11
  withAttribs(attribs: Attribs): Quadratic3;
12
- toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
12
+ toHiccup(): (string | Attribs | (string | Vec<number>)[][] | undefined)[];
13
13
  toHiccupPathSegments(): HiccupPathSegment[];
14
14
  }
15
15
  //# sourceMappingURL=quadratic3.d.ts.map
package/api/ray.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Ray implements IHiccupShape2<Ray> {
9
9
  constructor(pos: Vec, dir: Vec, attribs?: Attribs | undefined);
10
10
  copy(): Ray;
11
11
  withAttribs(attribs: Attribs): Ray;
12
- toHiccup(): (string | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=ray.d.ts.map
package/api/ray3.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Ray3 implements IHiccupShape3<Ray3> {
9
9
  constructor(pos: Vec, dir: Vec, attribs?: Attribs | undefined);
10
10
  copy(): Ray3;
11
11
  withAttribs(attribs: Attribs): Ray3;
12
- toHiccup(): (string | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=ray3.d.ts.map
package/api/rect.d.ts CHANGED
@@ -9,9 +9,9 @@ export declare class Rect implements AABBLike, IHiccupShape2<Rect> {
9
9
  constructor(pos?: Vec, size?: number | Vec, attribs?: Attribs | undefined);
10
10
  copy(): Rect;
11
11
  withAttribs(attribs: Attribs): Rect;
12
- min(): Vec;
13
- max(): Vec;
12
+ min(): Vec<number>;
13
+ max(): Vec<number>;
14
14
  offset(offset: number): this;
15
- toHiccup(): (string | number | Vec | Attribs | undefined)[];
15
+ toHiccup(): (string | number | Vec<number> | Attribs | undefined)[];
16
16
  }
17
17
  //# sourceMappingURL=rect.d.ts.map
package/api/sphere.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Sphere implements IHiccupShape3<Sphere> {
9
9
  constructor(pos?: Vec, r?: number, attribs?: Attribs | undefined);
10
10
  copy(): Sphere;
11
11
  withAttribs(attribs: Attribs): Sphere;
12
- toHiccup(): (string | number | Vec | Attribs | undefined)[];
12
+ toHiccup(): (string | number | Vec<number> | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=sphere.d.ts.map
package/api/triangle.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class Triangle extends APC implements IHiccupShape2<Triangle> {
9
9
  copy(): Triangle;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Triangle;
11
11
  withAttribs(attribs: Attribs): Triangle;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=triangle.d.ts.map
@@ -9,6 +9,6 @@ export declare class Triangle3 extends APC implements IHiccupShape3<Triangle3> {
9
9
  copy(): Triangle3;
10
10
  copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Triangle3;
11
11
  withAttribs(attribs: Attribs): Triangle3;
12
- toHiccup(): (string | Vec[] | Attribs | undefined)[];
12
+ toHiccup(): (string | Vec<number>[] | Attribs | undefined)[];
13
13
  }
14
14
  //# sourceMappingURL=triangle3.d.ts.map
package/api.d.ts CHANGED
@@ -168,10 +168,10 @@ export interface CubicOpts {
168
168
  *
169
169
  * - `default`: Original vertices are used control points (see
170
170
  * [`closedCubicFromControlPoints`](https://docs.thi.ng/umbrella/geom-splines/functions/closedCubicFromControlPoints.html))
171
- * - `break`: Original vertices are used as curve points, tangents are
172
- * computed automatically (see
171
+ * - `break`: 2D only. Original vertices are used as curve points, tangents
172
+ * are computed automatically (see
173
173
  * [`closedCubicFromBreakPoints`](https://docs.thi.ng/umbrella/geom-splines/functions/closedCubicFromBreakPoints.html))
174
- * - `hobby`: Use John Hobby's interpolation algorithm (see
174
+ * - `hobby`: 2D only. Use John Hobby's interpolation algorithm (see
175
175
  * [`cubicHobby2`](https://docs.thi.ng/umbrella/geom-splines/functions/cubicHobby2.html))
176
176
  */
177
177
  mode: "default" | "break" | "hobby";
package/as-cubic.d.ts CHANGED
@@ -53,14 +53,14 @@ export type AsCubicFn = {
53
53
  * - {@link Group3} (only used for eligible children)
54
54
  * - {@link ComplexPolygon}
55
55
  * - {@link Polygon}
56
- * - {@link Polygon3}
56
+ * - {@link Polygon3} (no support for mode: "break" or "hobby")
57
57
  * - {@link Polyline}
58
- * - {@link Polyline3}
58
+ * - {@link Polyline3} (no support for mode: "break" or "hobby")
59
59
  * - {@link Quad}
60
- * - {@link Quad3}
60
+ * - {@link Quad3} (no support for mode: "break" or "hobby")
61
61
  * - {@link Rect}
62
62
  * - {@link Triangle}
63
- * - {@link Triangle3}
63
+ * - {@link Triangle3} (no support for mode: "break" or "hobby")
64
64
  *
65
65
  * @param shape
66
66
  * @param opts
package/as-cubic.js CHANGED
@@ -30,7 +30,8 @@ const asCubic = defmulti(
30
30
  quad: "poly",
31
31
  quad3: "poly3",
32
32
  rect: "$aspoly",
33
- tri: "poly"
33
+ tri: "poly",
34
+ tri3: "poly3"
34
35
  },
35
36
  {
36
37
  $aspoly: ($, opts) => asCubic(asPolygon($)[0], opts),
@@ -98,8 +99,7 @@ const asCubic = defmulti(
98
99
  hobby: (pts, scale) => cubicHobby2(pts, true, scale)
99
100
  }),
100
101
  poly3: ($, opts) => __polyCubic(Cubic3, $, opts, {
101
- default: closedCubicFromControlPoints,
102
- break: closedCubicFromBreakPoints
102
+ default: closedCubicFromControlPoints
103
103
  }),
104
104
  polyline: ($, opts) => __polyCubic(Cubic, $, opts, {
105
105
  default: openCubicFromControlPoints,
@@ -107,8 +107,7 @@ const asCubic = defmulti(
107
107
  hobby: (pts, scale) => cubicHobby2(pts, false, scale)
108
108
  }),
109
109
  polyline3: ($, opts) => __polyCubic(Cubic3, $, opts, {
110
- default: openCubicFromControlPoints,
111
- break: openCubicFromBreakPoints
110
+ default: openCubicFromControlPoints
112
111
  }),
113
112
  quadratic: ({ points: [a, b, c], attribs }, opts) => [
114
113
  cubicFromQuadratic(a, b, c, __attribs(opts, attribs))
package/bounds.js CHANGED
@@ -9,8 +9,8 @@ import { iterator1 } from "@thi.ng/transducers/iterator";
9
9
  import { map } from "@thi.ng/transducers/map";
10
10
  import { mapcat } from "@thi.ng/transducers/mapcat";
11
11
  import { addN2 } from "@thi.ng/vectors/addn";
12
- import { max } from "@thi.ng/vectors/max";
13
- import { min } from "@thi.ng/vectors/min";
12
+ import { max2 } from "@thi.ng/vectors/max";
13
+ import { min2 } from "@thi.ng/vectors/min";
14
14
  import { mul2 } from "@thi.ng/vectors/mul";
15
15
  import { mulN2 } from "@thi.ng/vectors/muln";
16
16
  import { sub2 } from "@thi.ng/vectors/sub";
@@ -70,7 +70,7 @@ const bounds = defmulti(
70
70
  const res = __collBounds($.children, bounds);
71
71
  return res ? new Rect(...res).offset(margin) : void 0;
72
72
  },
73
- line: ({ points: [a, b] }, margin = 0) => rectFromMinMaxWithMargin(min([], a, b), max([], a, b), margin),
73
+ line: ({ points: [a, b] }, margin = 0) => rectFromMinMaxWithMargin(min2([], a, b), max2([], a, b), margin),
74
74
  path: (path, margin = 0) => {
75
75
  const $segmentGeo = (segments) => iterator1(
76
76
  comp(
@@ -8,5 +8,5 @@ import type { IShape } from "./api.js";
8
8
  * @param shape
9
9
  * @param out
10
10
  */
11
- export declare const centroidOfBounds: (shape: IShape, out?: Vec) => import("@thi.ng/api").Maybe<Vec>;
11
+ export declare const centroidOfBounds: (shape: IShape, out?: Vec) => import("@thi.ng/api").Maybe<Vec<number>>;
12
12
  //# sourceMappingURL=centroid-of-bounds.d.ts.map
package/circle.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { circumCenter2 } from "@thi.ng/geom-poly-utils/circumcenter";
2
- import { dist } from "@thi.ng/vectors/dist";
2
+ import { dist2 } from "@thi.ng/vectors/dist";
3
3
  import { mixN2 } from "@thi.ng/vectors/mixn";
4
4
  import { Circle } from "./api/circle.js";
5
5
  import { __argsVN } from "./internal/args.js";
6
6
  function circle(...args) {
7
7
  return new Circle(...__argsVN(args));
8
8
  }
9
- const circleFrom2Points = (a, b, attribs) => new Circle(mixN2([], a, b, 0.5), dist(a, b) / 2, attribs);
9
+ const circleFrom2Points = (a, b, attribs) => new Circle(mixN2([], a, b, 0.5), dist2(a, b) / 2, attribs);
10
10
  const circleFrom3Points = (a, b, c, attribs) => {
11
11
  const o = circumCenter2(a, b, c);
12
- return o ? new Circle(o, dist(a, o), attribs) : void 0;
12
+ return o ? new Circle(o, dist2(a, o), attribs) : void 0;
13
13
  };
14
14
  export {
15
15
  circle,
@@ -27,5 +27,5 @@ export declare const __argsVV: (args: any[]) => any[];
27
27
  * @internal
28
28
  */
29
29
  export declare const __argsVN: (args: any[]) => any[];
30
- export declare const __asVec: (x: number | Vec, size?: number) => any[] | Vec;
30
+ export declare const __asVec: (x: number | Vec, size?: number) => any[] | Vec<number>;
31
31
  //# sourceMappingURL=args.d.ts.map
@@ -10,7 +10,7 @@ import type { AABBLike, IShape } from "../api.js";
10
10
  * @param shapes - input shapes
11
11
  * @param bounds - bbox function
12
12
  */
13
- export declare const __collBounds: (shapes: IShape[], bounds: Fn<IShape, Maybe<AABBLike>>) => import("@thi.ng/vectors").Vec[] | undefined;
13
+ export declare const __collBounds: (shapes: IShape[], bounds: Fn<IShape, Maybe<AABBLike>>) => import("@thi.ng/vectors").Vec<number>[] | undefined;
14
14
  /**
15
15
  * Takes the position and size vectors of 2 {@link AABBLike}s and returns
16
16
  * 2-tuple of `[pos,size]` of their union bounds.
@@ -3,9 +3,9 @@ import type { MatOpMV, ReadonlyMat } from "@thi.ng/matrices";
3
3
  import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
4
4
  import type { IShape2, IShape3, PathSegment, PathSegment2, TransformVertexFn } from "../api.js";
5
5
  /** @internal */
6
- export declare const __transformedPoints: (pts: ReadonlyVec[], mat: ReadonlyMat, op?: MatOpMV) => Vec[];
6
+ export declare const __transformedPoints: (pts: ReadonlyVec[], mat: ReadonlyMat, op?: MatOpMV) => Vec<number>[];
7
7
  /** @internal */
8
- export declare const __transformedPointsWith: (pts: ReadonlyVec[], fn: TransformVertexFn, op?: MatOpMV) => Vec[];
8
+ export declare const __transformedPointsWith: (pts: ReadonlyVec[], fn: TransformVertexFn, op?: MatOpMV) => Vec<number>[];
9
9
  type SegmentShapeMap<T extends PathSegment> = T extends PathSegment2 ? IShape2 : IShape3;
10
10
  /** @internal */
11
11
  export declare const __segmentTransformer: <S extends PathSegment>(txGeo: FnU<SegmentShapeMap<S>>, txPoint: FnU<Vec>) => (segments: S[]) => S[];
package/intersects.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { defmulti } from "@thi.ng/defmulti/defmulti";
2
- import { intersectCircleCircle } from "@thi.ng/geom-isec/circle-circle";
2
+ import {
3
+ intersectCircleCircle,
4
+ testCircleCircle
5
+ } from "@thi.ng/geom-isec/circle-circle";
3
6
  import { intersectLineLine } from "@thi.ng/geom-isec/line-line";
4
7
  import { intersectLinePolylineAll } from "@thi.ng/geom-isec/line-poly";
5
8
  import { intersectPlanePlane } from "@thi.ng/geom-isec/plane-plane";
@@ -29,8 +32,7 @@ const intersects = defmulti(
29
32
  "ray-line": "ray-polyline",
30
33
  "ray3-sphere": "ray3-circle",
31
34
  "ray-quad": "ray-poly",
32
- "ray-tri": "ray-poly",
33
- "sphere-sphere": "circle-circle"
35
+ "ray-tri": "ray-poly"
34
36
  },
35
37
  {
36
38
  "aabb-aabb": (a, b) => ({
@@ -94,6 +96,9 @@ const intersects = defmulti(
94
96
  }),
95
97
  "rect-rect": (a, b) => ({
96
98
  type: testRectRect(a.pos, a.size, b.pos, b.size) ? IntersectionType.INTERSECT : IntersectionType.NONE
99
+ }),
100
+ "sphere-sphere": (a, b) => ({
101
+ type: testCircleCircle(a.pos, b.pos, a.r, b.r) ? IntersectionType.INTERSECT : IntersectionType.NONE
97
102
  })
98
103
  }
99
104
  );
@@ -26,5 +26,5 @@ export declare const invertCircle: (c: Circle, ref: Circle) => Circle;
26
26
  * @param p
27
27
  * @param ref
28
28
  */
29
- export declare const invertCirclePoint: (p: ReadonlyVec, ref: Circle) => import("@thi.ng/vectors").Vec;
29
+ export declare const invertCirclePoint: (p: ReadonlyVec, ref: Circle) => import("@thi.ng/vectors").Vec<number>;
30
30
  //# sourceMappingURL=invert-circle.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/geom",
3
- "version": "8.1.38",
3
+ "version": "8.1.40",
4
4
  "description": "Functional, polymorphic API for 2D geometry types & SVG generation",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -40,38 +40,38 @@
40
40
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@thi.ng/adjacency": "^3.0.34",
44
- "@thi.ng/api": "^8.11.25",
45
- "@thi.ng/arrays": "^2.10.22",
46
- "@thi.ng/checks": "^3.7.5",
47
- "@thi.ng/defmulti": "^3.0.65",
48
- "@thi.ng/equiv": "^2.1.81",
49
- "@thi.ng/errors": "^2.5.31",
50
- "@thi.ng/geom-arc": "^2.1.173",
51
- "@thi.ng/geom-clip-line": "^2.3.130",
52
- "@thi.ng/geom-clip-poly": "^2.1.172",
53
- "@thi.ng/geom-closest-point": "^2.1.168",
54
- "@thi.ng/geom-hull": "^2.1.168",
55
- "@thi.ng/geom-isec": "^4.0.40",
56
- "@thi.ng/geom-poly-utils": "^3.0.40",
57
- "@thi.ng/geom-resample": "^3.0.40",
58
- "@thi.ng/geom-splines": "^2.3.40",
59
- "@thi.ng/geom-subdiv-curve": "^3.0.40",
60
- "@thi.ng/geom-tessellate": "^3.0.40",
61
- "@thi.ng/hiccup": "^5.3.10",
62
- "@thi.ng/hiccup-svg": "^5.4.28",
63
- "@thi.ng/math": "^5.11.25",
64
- "@thi.ng/matrices": "^2.4.40",
65
- "@thi.ng/object-utils": "^1.1.21",
66
- "@thi.ng/random": "^4.1.16",
67
- "@thi.ng/strings": "^3.9.10",
68
- "@thi.ng/transducers": "^9.2.25",
69
- "@thi.ng/vectors": "^7.13.1"
43
+ "@thi.ng/adjacency": "^3.0.35",
44
+ "@thi.ng/api": "^8.11.26",
45
+ "@thi.ng/arrays": "^2.10.23",
46
+ "@thi.ng/checks": "^3.7.6",
47
+ "@thi.ng/defmulti": "^3.0.66",
48
+ "@thi.ng/equiv": "^2.1.82",
49
+ "@thi.ng/errors": "^2.5.32",
50
+ "@thi.ng/geom-arc": "^2.1.175",
51
+ "@thi.ng/geom-clip-line": "^2.3.132",
52
+ "@thi.ng/geom-clip-poly": "^2.1.174",
53
+ "@thi.ng/geom-closest-point": "^2.1.170",
54
+ "@thi.ng/geom-hull": "^2.1.170",
55
+ "@thi.ng/geom-isec": "^4.0.42",
56
+ "@thi.ng/geom-poly-utils": "^3.0.42",
57
+ "@thi.ng/geom-resample": "^3.0.42",
58
+ "@thi.ng/geom-splines": "^2.3.42",
59
+ "@thi.ng/geom-subdiv-curve": "^3.0.42",
60
+ "@thi.ng/geom-tessellate": "^3.0.42",
61
+ "@thi.ng/hiccup": "^5.3.11",
62
+ "@thi.ng/hiccup-svg": "^5.4.30",
63
+ "@thi.ng/math": "^5.11.26",
64
+ "@thi.ng/matrices": "^3.0.1",
65
+ "@thi.ng/object-utils": "^1.1.22",
66
+ "@thi.ng/random": "^4.1.17",
67
+ "@thi.ng/strings": "^3.9.11",
68
+ "@thi.ng/transducers": "^9.2.26",
69
+ "@thi.ng/vectors": "^8.0.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "esbuild": "^0.25.2",
73
- "typedoc": "^0.28.1",
74
- "typescript": "^5.8.2"
73
+ "typedoc": "^0.28.2",
74
+ "typescript": "^5.8.3"
75
75
  },
76
76
  "keywords": [
77
77
  "2d",
@@ -533,5 +533,5 @@
533
533
  "tag": "geometry",
534
534
  "year": 2013
535
535
  },
536
- "gitHead": "c88a589f33207b02a43172313b38ea09571265f1\n"
536
+ "gitHead": "69080248c98f9555642384aed76a0431e9f44835\n"
537
537
  }
package/path-builder.d.ts CHANGED
@@ -62,8 +62,8 @@ export declare class PathBuilder<P extends IPath<any>, S extends P["segments"][0
62
62
  quadraticChainTo(p: Vec, relative?: boolean): this;
63
63
  arcTo(p: Vec, r: Vec, xaxis: number, xl: boolean, clockwise: boolean, relative?: boolean): this;
64
64
  close(): this;
65
- protected updateCurrent(p: Vec, relative: boolean): Vec;
66
- protected absPoint(p: Vec, relative: boolean): Vec;
65
+ protected updateCurrent(p: Vec, relative: boolean): Vec<number>;
66
+ protected absPoint(p: Vec, relative: boolean): Vec<number>;
67
67
  protected addHVLine(p: number, i: number, relative: boolean): void;
68
68
  protected addCubic(cp1: Vec, cp2: Vec, p: Vec, relative: boolean): void;
69
69
  protected addQuadratic(cp: Vec, p: Vec, relative: boolean): void;
package/rect.js CHANGED
@@ -2,7 +2,7 @@ import { centroid } from "@thi.ng/geom-poly-utils/centroid";
2
2
  import { SQRT2_2, SQRT3 } from "@thi.ng/math/api";
3
3
  import { add2 } from "@thi.ng/vectors/add";
4
4
  import { ZERO2 } from "@thi.ng/vectors/api";
5
- import { dist } from "@thi.ng/vectors/dist";
5
+ import { dist2 } from "@thi.ng/vectors/dist";
6
6
  import { maddN2 } from "@thi.ng/vectors/maddn";
7
7
  import { max2 } from "@thi.ng/vectors/max";
8
8
  import { min2 } from "@thi.ng/vectors/min";
@@ -45,7 +45,7 @@ function inscribedSquareHex(...args) {
45
45
  if (args.length === 1) {
46
46
  const pts = args[0].points;
47
47
  pos = centroid(pts);
48
- l = dist(pts[0], pts[1]);
48
+ l = dist2(pts[0], pts[1]);
49
49
  } else {
50
50
  [pos, l] = args;
51
51
  }
package/scatter.d.ts CHANGED
@@ -16,5 +16,5 @@ import type { IShape } from "./api.js";
16
16
  * @param rnd
17
17
  * @param out
18
18
  */
19
- export declare const scatter: (shape: IShape, num: number, rnd?: IRandom, out?: Vec[]) => Vec[] | undefined;
19
+ export declare const scatter: (shape: IShape, num: number, rnd?: IRandom, out?: Vec[]) => Vec<number>[] | undefined;
20
20
  //# sourceMappingURL=scatter.d.ts.map
package/sphere.js CHANGED
@@ -1,11 +1,11 @@
1
- import { dist } from "@thi.ng/vectors/dist";
1
+ import { dist3 } from "@thi.ng/vectors/dist";
2
2
  import { mixN3 } from "@thi.ng/vectors/mixn";
3
3
  import { Sphere } from "./api/sphere.js";
4
4
  import { __argsVN } from "./internal/args.js";
5
5
  function sphere(...args) {
6
6
  return new Sphere(...__argsVN(args));
7
7
  }
8
- const sphereFrom2Points = (a, b, attribs) => new Sphere(mixN3([], a, b, 0.5), dist(a, b) / 2, attribs);
8
+ const sphereFrom2Points = (a, b, attribs) => new Sphere(mixN3([], a, b, 0.5), dist3(a, b) / 2, attribs);
9
9
  export {
10
10
  sphere,
11
11
  sphereFrom2Points
package/subdiv-curve.d.ts CHANGED
@@ -55,7 +55,7 @@ export type SubdivCurveFn = {
55
55
  *
56
56
  * - {@link SUBDIV_CHAIKIN}
57
57
  * - {@link SUBDIV_CUBIC}
58
- * - {@link SUBDIV_DISPLACE} (higher order kernel)
58
+ * - {@link SUBDIV_DISPLACE} (2D only, higher order kernel)
59
59
  * - {@link SUBDIV_DLG}
60
60
  * - {@link SUBDIV_MID}
61
61
  * - {@link SUBDIV_THIRDS}
package/vertices.d.ts CHANGED
@@ -59,5 +59,5 @@ export declare const vertices: MultiFn1O<IShape, number | Partial<SamplingOpts>,
59
59
  *
60
60
  * @param shape -
61
61
  */
62
- export declare const ensureVertices: (shape: IShape | Vec[]) => Vec[];
62
+ export declare const ensureVertices: (shape: IShape | Vec[]) => Vec<number>[];
63
63
  //# sourceMappingURL=vertices.d.ts.map
package/warp-points.d.ts CHANGED
@@ -33,7 +33,7 @@ import type { Rect } from "./api/rect.js";
33
33
  * @param src
34
34
  * @param out
35
35
  */
36
- export declare const warpPoint: (p: ReadonlyVec, dest: IShape, src: IShape, out?: Vec) => Vec;
36
+ export declare const warpPoint: (p: ReadonlyVec, dest: IShape, src: IShape, out?: Vec) => Vec<number>;
37
37
  /**
38
38
  * Array version of {@link warpPoint}, transferring all points in the array from
39
39
  * world space to the local space of `dest` via the local space of `src`.
@@ -47,6 +47,6 @@ export declare const warpPoint: (p: ReadonlyVec, dest: IShape, src: IShape, out?
47
47
  * @param src
48
48
  * @param out
49
49
  */
50
- export declare const warpPoints: (pts: ReadonlyVec[], dest: IShape, src: IShape, out?: Vec[]) => Vec[];
51
- export declare const warpPointsBPatch: (pts: ReadonlyVec[], dest: BPatch, src?: Rect, out?: Vec[]) => Vec[];
50
+ export declare const warpPoints: (pts: ReadonlyVec[], dest: IShape, src: IShape, out?: Vec[]) => Vec<number>[];
51
+ export declare const warpPointsBPatch: (pts: ReadonlyVec[], dest: BPatch, src?: Rect, out?: Vec[]) => Vec<number>[];
52
52
  //# sourceMappingURL=warp-points.d.ts.map