@ac-kit/math-geometry 0.3.0 → 0.5.0

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +177 -0
  2. package/README.md +76 -5
  3. package/dist/_polygon3-cross.d.ts +23 -0
  4. package/dist/_polygon3-cross.d.ts.map +1 -0
  5. package/dist/_polygon3-cross.js +418 -0
  6. package/dist/_polygon3-cross.js.map +1 -0
  7. package/dist/_polyline-simplify.d.ts +11 -0
  8. package/dist/_polyline-simplify.d.ts.map +1 -0
  9. package/dist/_polyline-simplify.js +92 -0
  10. package/dist/_polyline-simplify.js.map +1 -0
  11. package/dist/_triangle3-cross.d.ts +66 -0
  12. package/dist/_triangle3-cross.d.ts.map +1 -0
  13. package/dist/_triangle3-cross.js +405 -0
  14. package/dist/_triangle3-cross.js.map +1 -0
  15. package/dist/convex-hull2.d.ts +26 -0
  16. package/dist/convex-hull2.d.ts.map +1 -0
  17. package/dist/convex-hull2.js +88 -0
  18. package/dist/convex-hull2.js.map +1 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/line2.d.ts +4 -0
  24. package/dist/line2.d.ts.map +1 -1
  25. package/dist/line2.js +26 -5
  26. package/dist/line2.js.map +1 -1
  27. package/dist/mesh/_index-kernels-u16.d.ts +46 -11
  28. package/dist/mesh/_index-kernels-u16.d.ts.map +1 -1
  29. package/dist/mesh/_index-kernels-u16.js +1442 -132
  30. package/dist/mesh/_index-kernels-u16.js.map +1 -1
  31. package/dist/mesh/_index-kernels-u32.d.ts +46 -11
  32. package/dist/mesh/_index-kernels-u32.d.ts.map +1 -1
  33. package/dist/mesh/_index-kernels-u32.js +1442 -132
  34. package/dist/mesh/_index-kernels-u32.js.map +1 -1
  35. package/dist/mesh/mesh3-kernels.d.ts +104 -20
  36. package/dist/mesh/mesh3-kernels.d.ts.map +1 -1
  37. package/dist/mesh/mesh3-kernels.js +123 -25
  38. package/dist/mesh/mesh3-kernels.js.map +1 -1
  39. package/dist/plane3.d.ts +4 -3
  40. package/dist/plane3.d.ts.map +1 -1
  41. package/dist/plane3.js +18 -35
  42. package/dist/plane3.js.map +1 -1
  43. package/dist/polygon2.d.ts +76 -4
  44. package/dist/polygon2.d.ts.map +1 -1
  45. package/dist/polygon2.js +366 -7
  46. package/dist/polygon2.js.map +1 -1
  47. package/dist/polygon3.d.ts +19 -3
  48. package/dist/polygon3.d.ts.map +1 -1
  49. package/dist/polygon3.js +40 -16
  50. package/dist/polygon3.js.map +1 -1
  51. package/dist/polyline2.d.ts +20 -0
  52. package/dist/polyline2.d.ts.map +1 -1
  53. package/dist/polyline2.js +25 -0
  54. package/dist/polyline2.js.map +1 -1
  55. package/dist/polyline3.d.ts +17 -0
  56. package/dist/polyline3.d.ts.map +1 -1
  57. package/dist/polyline3.js +22 -0
  58. package/dist/polyline3.js.map +1 -1
  59. package/dist/predicates2.d.ts +51 -0
  60. package/dist/predicates2.d.ts.map +1 -0
  61. package/dist/predicates2.js +172 -0
  62. package/dist/predicates2.js.map +1 -0
  63. package/dist/quadtree.d.ts +40 -23
  64. package/dist/quadtree.d.ts.map +1 -1
  65. package/dist/quadtree.js +196 -119
  66. package/dist/quadtree.js.map +1 -1
  67. package/dist/segment2.d.ts +6 -1
  68. package/dist/segment2.d.ts.map +1 -1
  69. package/dist/segment2.js +20 -4
  70. package/dist/segment2.js.map +1 -1
  71. package/dist/triangle3.d.ts +20 -1
  72. package/dist/triangle3.d.ts.map +1 -1
  73. package/dist/triangle3.js +38 -18
  74. package/dist/triangle3.js.map +1 -1
  75. package/package.json +8 -8
package/dist/line2.js CHANGED
@@ -1,4 +1,4 @@
1
- import { diffOfProducts } from "@ac-kit/math-scalar";
1
+ import { diffOfProducts, diffOfProductsInPlace } from "@ac-kit/math-scalar";
2
2
  import { geometryConfig } from "./globals.js";
3
3
  /**
4
4
  * Writes the point of the line nearest to `point` into `out`; a line with a
@@ -45,23 +45,42 @@ export function line2ContainsPoint(line, point, tolerance = geometryConfig.defau
45
45
  *
46
46
  * @param tolerance Dimensionless bound on the sine of the angle between the
47
47
  * directions; defaults to `geometryConfig.defaultAngularTolerance`.
48
+ *
49
+ * Allocates nothing when the cross products of the directions and of the
50
+ * offset between the lines stay within `diffOfProductsInPlace`'s range
51
+ * (`2⁻⁹⁶⁹` to `2¹⁰²²` in magnitude, or zero): every coordinate-sized pair.
48
52
  */
49
53
  export function line2IntersectLine2(out, a, b, tolerance = geometryConfig.defaultAngularTolerance) {
50
54
  const dx1 = a[2];
51
55
  const dy1 = a[3];
52
56
  const dx2 = b[2];
53
57
  const dy2 = b[3];
54
- const denominator = diffOfProducts(dx1, dy2, dy1, dx2);
58
+ // the determinants go through a buffer: a double passed to or returned
59
+ // from a call the engine does not inline is boxed
60
+ DETERMINANT_[0] = dx1;
61
+ DETERMINANT_[1] = dy2;
62
+ DETERMINANT_[2] = dy1;
63
+ DETERMINANT_[3] = dx2;
64
+ diffOfProductsInPlace(DETERMINANT_);
65
+ const denominator = DETERMINANT_[0];
55
66
  const scale = Math.sqrt(dx1 * dx1 + dy1 * dy1) * Math.sqrt(dx2 * dx2 + dy2 * dy2);
56
- if (Math.abs(denominator) <= tolerance * scale || Number.isNaN(denominator)) {
67
+ // NaN differs from itself
68
+ if (Math.abs(denominator) <= tolerance * scale ||
69
+ denominator !== denominator) {
57
70
  out[0] = Number.NaN;
58
71
  out[1] = Number.NaN;
59
72
  return false;
60
73
  }
61
- const t = diffOfProducts(b[0] - a[0], dy2, b[1] - a[1], dx2) / denominator;
74
+ DETERMINANT_[0] = b[0] - a[0];
75
+ DETERMINANT_[1] = dy2;
76
+ DETERMINANT_[2] = b[1] - a[1];
77
+ DETERMINANT_[3] = dx2;
78
+ diffOfProductsInPlace(DETERMINANT_);
79
+ const t = DETERMINANT_[0] / denominator;
62
80
  const x = a[0] + dx1 * t;
63
81
  const y = a[1] + dy1 * t;
64
- if (!(Number.isFinite(x) && Number.isFinite(y))) {
82
+ // x − x is 0 for a finite x only
83
+ if (x - x !== 0 || y - y !== 0) {
65
84
  out[0] = Number.NaN;
66
85
  out[1] = Number.NaN;
67
86
  return false;
@@ -70,4 +89,6 @@ export function line2IntersectLine2(out, a, b, tolerance = geometryConfig.defaul
70
89
  out[1] = y;
71
90
  return true;
72
91
  }
92
+ /** The factors of {@link line2IntersectLine2}'s determinants, then each one. */
93
+ const DETERMINANT_ = new Float64Array(4);
73
94
  //# sourceMappingURL=line2.js.map
package/dist/line2.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"line2.js","sourceRoot":"","sources":["../src/line2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAS,EACT,IAAmB,EACnB,KAAmB;IAEnB,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,GACN,aAAa,KAAK,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClE,aAAa,CAAC;IACjB,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI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AC;IACzB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IACzB,iCAAiC;IACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;QACpB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,IAAI,CAAC;AACb,CAAC;AAED,gFAAgF;AAChF,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC"}
@@ -3,7 +3,21 @@ import type { ReadonlyRay3 } from "../ray3-record.js";
3
3
  /**
4
4
  * The `Uint16Array` twin of the area-weighted vertex normals: the public
5
5
  * function checks the lengths and dispatches on the index type once. Writes
6
- * `positions.length` numbers into `out`. O(vertices + triangles).
6
+ * `positions.length` numbers into `out`. Each face adds its cross product,
7
+ * twice its area times its unit normal (`faceCross_`: within 2^−49 of its
8
+ * largest component, zero only for a degenerate face). While every face's
9
+ * product is plain (k = 0, its largest component in [2^−400, 2^402)), the sums
10
+ * are those products' as they come; otherwise a first pass finds, per vertex,
11
+ * the largest product among its faces, and each face adds its product scaled by
12
+ * the power of two that brings that vertex's largest to [1, 2): the weights
13
+ * keep their ratios, nothing overflows, and a vertex whose faces are all tiny
14
+ * beside other vertices' still gets its normal. Each sum keeps a running bound
15
+ * on its rounding errors (Higham, "Accuracy and Stability of Numerical
16
+ * Algorithms", §4.2: within u/(1 − u) of the partial sums' magnitudes, u =
17
+ * 2^−53); a vertex whose bound is not within 2^−50 of its largest component
18
+ * (its faces cancel, or it has very many) is summed again exactly
19
+ * (`exactVertexSums_`). O(vertices + triangles); no allocation once the
20
+ * per-vertex scratch has grown to the largest mesh.
7
21
  */
8
22
  export declare function mesh3VertexNormalsU16(out: Float64Array, positions: Float64Array, indices: Uint16Array): void;
9
23
  /**
@@ -11,20 +25,39 @@ export declare function mesh3VertexNormalsU16(out: Float64Array, positions: Floa
11
25
  * zero vector for a degenerate one. O(triangles).
12
26
  */
13
27
  export declare function mesh3FaceNormalsU16(out: Float64Array, positions: Float64Array, indices: Uint16Array): void;
14
- /** The `Uint16Array` twin of the surface area. O(triangles). */
28
+ /**
29
+ * The `Uint16Array` twin of the surface area: each face's area from its edges
30
+ * and cross product scaled by powers of two (`faceArea_`), so no square
31
+ * overflows or underflows at any size or distance from the origin, rounded once
32
+ * per face and summed exactly: the same number in every face order.
33
+ * O(triangles), no allocation.
34
+ */
15
35
  export declare function mesh3SurfaceAreaU16(positions: Float64Array, indices: Uint16Array): number;
16
36
  /**
17
- * The `Uint16Array` twin of the signed volume, summed from the first triangle's
18
- * first vertex so that a mesh far from the origin, or a vertex no triangle
19
- * uses, loses no digits. O(triangles).
37
+ * The `Uint16Array` twin of the signed volume: six times it is T = `Σ det[a −
38
+ * o, b − o, c − o]` over the faces, o being the frame's anchor (any point gives
39
+ * the same volume for a closed mesh), every coordinate exact. An ordinary mesh
40
+ * is certified by the doubled-precision filter, which proves the rounded T / 6;
41
+ * anywhere else every face's term is summed exactly in a long accumulator
42
+ * ({@link exactSixVolume_}), whatever the magnitudes, and T / 6 is rounded once
43
+ * from it ({@link roundQuotient_}): the same number in every face order and for
44
+ * every rotation of a face's corners, and a vertex no triangle uses is never
45
+ * read. Written to `out[0]`: a double returned from a call the engine does not
46
+ * inline is boxed. O(triangles), no allocation.
20
47
  */
21
- export declare function mesh3VolumeU16(positions: Float64Array, indices: Uint16Array): number;
48
+ export declare function mesh3VolumeU16(out: Float64Array, positions: Float64Array, indices: Uint16Array): void;
22
49
  /**
23
- * The `Uint16Array` twin of the surface centroid, relative to the first
24
- * triangle's first vertex. A zero total area divides zero by zero: `NaN`.
25
- * O(triangles).
50
+ * The `Uint16Array` twin of the surface centroid: `Σ ω (a + b + c) / (3 Σ ω)`,
51
+ * ω each face's doubled area (`faceArea_`, as m · 2^k), both sums exact in long
52
+ * accumulators at any magnitude, their quotient rounded once
53
+ * ({@link roundQuotient_}): the same number in every face order, correctly
54
+ * rounded for those weights at any size or distance from the origin, and a
55
+ * vertex no triangle uses is never read. A zero total area divides zero by
56
+ * zero: `NaN`. With `faithful`, the first stage {@link faithfulCentroid_} runs
57
+ * first and the rest only where it cannot prove its result. O(triangles), no
58
+ * allocation.
26
59
  */
27
- export declare function mesh3CentroidU16(out: Vec3, positions: Float64Array, indices: Uint16Array): void;
60
+ export declare function mesh3CentroidU16(out: Vec3, positions: Float64Array, indices: Uint16Array, faithful?: boolean): void;
28
61
  /**
29
62
  * The `Uint16Array` twin of the nearest ray hit: the triangle index, `−1` for a
30
63
  * miss; `out` is `[t, u, v]`, `NaN` for a miss. O(triangles).
@@ -32,7 +65,9 @@ export declare function mesh3CentroidU16(out: Vec3, positions: Float64Array, ind
32
65
  export declare function mesh3IntersectRay3U16(out: Vec3, ray: ReadonlyRay3, positions: Float64Array, indices: Uint16Array, cullBackFaces: boolean): number;
33
66
  /**
34
67
  * The `Uint16Array` twin of the triangle depths: `z / w` of each triangle's
35
- * centroid under `viewProjection`. O(triangles).
68
+ * centroid under `viewProjection`. A centroid whose coordinates overflow when
69
+ * summed takes halves; one whose transformed z or w overflows is scaled by a
70
+ * power of two first, which leaves `z / w` unchanged. O(triangles).
36
71
  */
37
72
  export declare function mesh3TriangleDepthsU16(out: Float64Array, positions: Float64Array, indices: Uint16Array, viewProjection: ReadonlyMat4x4): void;
38
73
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"_index-kernels-u16.d.ts","sourceRoot":"","sources":["../../src/mesh/_index-kernels-u16.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,IAAI,EAGT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAuDN;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAmBN;AAED,gEAAgE;AAChE,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,MAAM,CAoBR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,MAAM,CA2BR;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CA0CN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,OAAO,GACpB,MAAM,CAuCR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,cAAc,GAC5B,IAAI,CAuBN;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,WAAW,GAChB,IAAI,CAQN"}
1
+ {"version":3,"file":"_index-kernels-u16.d.ts","sourceRoot":"","sources":["../../src/mesh/_index-kernels-u16.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK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