@ac-kit/math-geometry 0.4.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 (46) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +37 -6
  3. package/dist/_polyline-simplify.d.ts +11 -0
  4. package/dist/_polyline-simplify.d.ts.map +1 -0
  5. package/dist/_polyline-simplify.js +92 -0
  6. package/dist/_polyline-simplify.js.map +1 -0
  7. package/dist/_triangle3-cross.d.ts.map +1 -1
  8. package/dist/_triangle3-cross.js +16 -7
  9. package/dist/_triangle3-cross.js.map +1 -1
  10. package/dist/convex-hull2.d.ts +26 -0
  11. package/dist/convex-hull2.d.ts.map +1 -0
  12. package/dist/convex-hull2.js +88 -0
  13. package/dist/convex-hull2.js.map +1 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/mesh/_index-kernels-u16.d.ts +21 -28
  19. package/dist/mesh/_index-kernels-u16.d.ts.map +1 -1
  20. package/dist/mesh/_index-kernels-u16.js +892 -363
  21. package/dist/mesh/_index-kernels-u16.js.map +1 -1
  22. package/dist/mesh/_index-kernels-u32.d.ts +21 -28
  23. package/dist/mesh/_index-kernels-u32.d.ts.map +1 -1
  24. package/dist/mesh/_index-kernels-u32.js +892 -363
  25. package/dist/mesh/_index-kernels-u32.js.map +1 -1
  26. package/dist/mesh/mesh3-kernels.d.ts +73 -29
  27. package/dist/mesh/mesh3-kernels.d.ts.map +1 -1
  28. package/dist/mesh/mesh3-kernels.js +92 -34
  29. package/dist/mesh/mesh3-kernels.js.map +1 -1
  30. package/dist/polygon2.d.ts +22 -0
  31. package/dist/polygon2.d.ts.map +1 -1
  32. package/dist/polygon2.js +69 -0
  33. package/dist/polygon2.js.map +1 -1
  34. package/dist/polyline2.d.ts +20 -0
  35. package/dist/polyline2.d.ts.map +1 -1
  36. package/dist/polyline2.js +25 -0
  37. package/dist/polyline2.js.map +1 -1
  38. package/dist/polyline3.d.ts +17 -0
  39. package/dist/polyline3.d.ts.map +1 -1
  40. package/dist/polyline3.js +22 -0
  41. package/dist/polyline3.js.map +1 -1
  42. package/dist/predicates2.d.ts +51 -0
  43. package/dist/predicates2.d.ts.map +1 -0
  44. package/dist/predicates2.js +172 -0
  45. package/dist/predicates2.js.map +1 -0
  46. package/package.json +8 -8
@@ -34,37 +34,30 @@ export declare function mesh3FaceNormalsU16(out: Float64Array, positions: Float6
34
34
  */
35
35
  export declare function mesh3SurfaceAreaU16(positions: Float64Array, indices: Uint16Array): number;
36
36
  /**
37
- * The `Uint16Array` twin of the signed volume: six times it is `Σ (a − o) · ((b
38
- * − a) × (c − a))` over the faces, o being the frame's anchor (any point gives
39
- * the same volume for a closed mesh). The sum is a determinant per face, so
40
- * each axis may take its own power-of-two scale: the frame brings every axis's
41
- * extent below 1, then a first pass over the faces bounds their terms and one
42
- * common power of two brings the largest near 2^1000, so that no product
43
- * overflows and small faces keep their digits, however thin, wide or far from
44
- * the origin the mesh is. Each face's term is then written as exact products:
45
- * `a − o` as TwoSum's pair, the cross product as an expansion (each component
46
- * two products and their rounding errors, Ogita, Rump & Oishi's TwoProduct),
47
- * and the whole summed exactly (`PreciseSum`). With the face-local edge
48
- * differences exact, which they are wherever a face is small beside its
49
- * distance from the origin (Sterbenz), the result is six times the volume
50
- * rounded once, then divided by 6: the same number in every face order and at
51
- * every offset, and a vertex no triangle uses is never read. A term below about
52
- * 2^−1900 of the largest may lose digits to the subnormal range; so may a
53
- * volume that small beside the largest term. O(triangles), no allocation.
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.
54
47
  */
55
- export declare function mesh3VolumeU16(positions: Float64Array, indices: Uint16Array): number;
48
+ export declare function mesh3VolumeU16(out: Float64Array, positions: Float64Array, indices: Uint16Array): void;
56
49
  /**
57
- * The `Uint16Array` twin of the surface centroid: `o + Σ A · (a + b + c − 3o) /
58
- * 3` over `Σ A`, o being the frame's anchor and A each face's doubled area
59
- * (`faceArea_`), scaled by one power of two that brings the largest near 1, so
60
- * no weight overflows and only one below 2^−1070 of the largest is lost. Every
61
- * corner minus o is TwoSum's exact pair scaled into the frame per axis, every
62
- * product split exactly (TwoProduct) and every sum exact (`PreciseSum`), so the
63
- * result is the same in every face order, nothing overflows at any size or
64
- * distance from the origin, and a vertex no triangle uses is never read. A zero
65
- * total area divides zero by zero: `NaN`. O(triangles), no allocation.
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.
66
59
  */
67
- 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;
68
61
  /**
69
62
  * The `Uint16Array` twin of the nearest ray hit: the triangle index, `−1` for a
70
63
  * miss; `out` is `[t, u, v]`, `NaN` for a miss. O(triangles).
@@ -1 +1 @@
1
- {"version":3,"file":"_index-kernels-u16.d.ts","sourceRoot":"","sources":["../../src/mesh/_index-kernels-u16.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,IAAI,EAGT,MAAM,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiFtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAkFN;AAgPD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAmBN;AAuND;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,MAAM,CA0BR;AA+JD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,MAAM,CAqGR;AA4CD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAoFN;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;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,cAAc,GAC5B,IAAI,CAuDN;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,IAAI,EAGT,MAAM,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiEtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAkFN;AAgPD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAmBN;AAgOD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,MAAM,CA0BR;AAyVD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,GAClB,IAAI,CAgDN;AAigBD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,QAAQ,UAAQ,GACd,IAAI,CAqCN;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;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,cAAc,GAC5B,IAAI,CAuDN;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,WAAW,GAChB,IAAI,CAQN"}