@bitbybit-dev/base 1.6.1 → 1.7.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 (192) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +36 -7
  3. package/lib/api/inputs/base-inputs.js +10 -0
  4. package/lib/api/inputs/color-inputs.d.ts +54 -1
  5. package/lib/api/inputs/color-inputs.js +73 -1
  6. package/lib/api/inputs/frame-inputs.d.ts +2 -1
  7. package/lib/api/inputs/frame-inputs.js +2 -1
  8. package/lib/api/inputs/io-inputs.d.ts +527 -59
  9. package/lib/api/inputs/io-inputs.js +432 -40
  10. package/lib/api/inputs/line-inputs.d.ts +17 -0
  11. package/lib/api/inputs/line-inputs.js +15 -0
  12. package/lib/api/inputs/math-inputs.d.ts +62 -0
  13. package/lib/api/inputs/math-inputs.js +82 -0
  14. package/lib/api/inputs/mesh-inputs.d.ts +16 -0
  15. package/lib/api/inputs/mesh-inputs.js +14 -0
  16. package/lib/api/inputs/transforms-inputs.d.ts +76 -0
  17. package/lib/api/inputs/transforms-inputs.js +85 -0
  18. package/lib/api/kernel-calls/index.d.ts +1 -0
  19. package/lib/api/kernel-calls/index.js +1 -0
  20. package/lib/api/kernel-calls/settings.d.ts +82 -0
  21. package/lib/api/kernel-calls/settings.js +123 -0
  22. package/lib/api/recipes/surface-mesh.d.ts +2 -1
  23. package/lib/api/recipes/surface-mesh.js +5 -3
  24. package/lib/api/resolved-inputs/index.d.ts +32 -2
  25. package/lib/api/services/base-bitbybit.d.ts +12 -0
  26. package/lib/api/services/base-bitbybit.js +19 -3
  27. package/lib/api/services/color.d.ts +36 -2
  28. package/lib/api/services/color.js +60 -11
  29. package/lib/api/services/helpers/color/color-forms.constants.d.ts +10 -0
  30. package/lib/api/services/helpers/color/color-forms.constants.js +10 -0
  31. package/lib/api/services/helpers/color/color-forms.d.ts +3 -0
  32. package/lib/api/services/helpers/color/color-forms.js +27 -0
  33. package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
  34. package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
  35. package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
  36. package/lib/api/services/helpers/color/css-colors.js +61 -0
  37. package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
  38. package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
  39. package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
  40. package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
  41. package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
  42. package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
  43. package/lib/api/services/helpers/curves/conic-arcs.d.ts +24 -0
  44. package/lib/api/services/helpers/curves/conic-arcs.js +85 -0
  45. package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
  46. package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
  47. package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
  48. package/lib/api/services/helpers/curves/nurbs.js +10 -9
  49. package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
  50. package/lib/api/services/helpers/files/drawing/drawing-budget.js +24 -0
  51. package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
  52. package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
  53. package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
  54. package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
  55. package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
  56. package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
  57. package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
  58. package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -0
  59. package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
  60. package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
  61. package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +17 -0
  62. package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -0
  63. package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
  64. package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
  65. package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
  66. package/lib/api/services/helpers/files/dxf/dxf-generator.js +81 -523
  67. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
  68. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +81 -0
  69. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
  70. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
  71. package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +69 -0
  72. package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
  73. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +71 -0
  74. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
  75. package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
  76. package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
  77. package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
  78. package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -0
  79. package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
  80. package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
  81. package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +9 -0
  82. package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
  83. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
  84. package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -1
  85. package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
  86. package/lib/api/services/helpers/files/file-bytes.js +15 -0
  87. package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
  88. package/lib/api/services/helpers/files/ground-axes.js +4 -0
  89. package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
  90. package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
  91. package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
  92. package/lib/api/services/helpers/files/stl-axes.js +22 -0
  93. package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
  94. package/lib/api/services/helpers/files/stl-types.js +1 -0
  95. package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
  96. package/lib/api/services/helpers/files/stl.constants.js +11 -0
  97. package/lib/api/services/helpers/files/stl.d.ts +3 -0
  98. package/lib/api/services/helpers/files/stl.js +93 -0
  99. package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
  100. package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
  101. package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
  102. package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
  103. package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
  104. package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
  105. package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
  106. package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
  107. package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
  108. package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
  109. package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
  110. package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
  111. package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
  112. package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
  113. package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
  114. package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
  115. package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
  116. package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
  117. package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
  118. package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
  119. package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
  120. package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
  121. package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
  122. package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
  123. package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
  124. package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
  125. package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
  126. package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
  127. package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
  128. package/lib/api/services/helpers/files/svg/svg-strokes.js +108 -0
  129. package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
  130. package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
  131. package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
  132. package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
  133. package/lib/api/services/helpers/files/svg/svg-writer.d.ts +16 -0
  134. package/lib/api/services/helpers/files/svg/svg-writer.js +153 -0
  135. package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
  136. package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
  137. package/lib/api/services/helpers/files/svg/svg.constants.d.ts +13 -0
  138. package/lib/api/services/helpers/files/svg/svg.constants.js +13 -0
  139. package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
  140. package/lib/api/services/helpers/files/work-budget.js +26 -0
  141. package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
  142. package/lib/api/services/helpers/geometry/affine2.js +18 -0
  143. package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
  144. package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
  145. package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
  146. package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
  147. package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
  148. package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
  149. package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
  150. package/lib/api/services/helpers/geometry/quaternions.constants.d.ts +3 -0
  151. package/lib/api/services/helpers/geometry/quaternions.constants.js +3 -0
  152. package/lib/api/services/helpers/geometry/quaternions.d.ts +14 -0
  153. package/lib/api/services/helpers/geometry/quaternions.js +71 -0
  154. package/lib/api/services/helpers/geometry/scalars.constants.d.ts +1 -0
  155. package/lib/api/services/helpers/geometry/scalars.constants.js +1 -0
  156. package/lib/api/services/helpers/geometry/scalars.d.ts +3 -0
  157. package/lib/api/services/helpers/geometry/scalars.js +29 -1
  158. package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
  159. package/lib/api/services/helpers/geometry/vectors.js +6 -0
  160. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +1 -0
  161. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +1 -0
  162. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +1 -0
  163. package/lib/api/services/helpers/mesh/mesh-proximity.js +40 -40
  164. package/lib/api/services/io/drawing.d.ts +170 -0
  165. package/lib/api/services/io/drawing.js +212 -0
  166. package/lib/api/services/io/dxf.d.ts +134 -0
  167. package/lib/api/services/io/dxf.js +167 -0
  168. package/lib/api/services/io/index.d.ts +4 -0
  169. package/lib/api/services/io/index.js +4 -0
  170. package/lib/api/services/io/io.d.ts +14 -0
  171. package/lib/api/services/io/io.js +15 -0
  172. package/lib/api/services/io/svg.d.ts +64 -0
  173. package/lib/api/services/io/svg.js +102 -0
  174. package/lib/api/services/line.d.ts +17 -0
  175. package/lib/api/services/line.js +20 -1
  176. package/lib/api/services/math.d.ts +35 -0
  177. package/lib/api/services/math.js +56 -1
  178. package/lib/api/services/mesh.d.ts +17 -0
  179. package/lib/api/services/mesh.js +27 -1
  180. package/lib/api/services/point.d.ts +4 -1
  181. package/lib/api/services/point.js +9 -4
  182. package/lib/api/services/recipes.d.ts +3 -0
  183. package/lib/api/services/recipes.js +4 -1
  184. package/lib/api/services/text.d.ts +4 -1
  185. package/lib/api/services/text.js +8 -3
  186. package/lib/api/services/transforms.d.ts +119 -1
  187. package/lib/api/services/transforms.js +158 -30
  188. package/package.json +1 -1
  189. package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
  190. package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
  191. package/lib/api/services/io.d.ts +0 -9
  192. package/lib/api/services/io.js +0 -10
@@ -0,0 +1,96 @@
1
+ import { angleOfCosine } from "./scalars";
2
+ import { cross2 } from "./vectors";
3
+ const FULL_TURN = 2 * Math.PI;
4
+ const turnBetween = (ux, uy, vx, vy) => {
5
+ const angle = angleOfCosine((ux * vx + uy * vy) / Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy)));
6
+ return ux * vy - uy * vx < 0 ? -angle : angle;
7
+ };
8
+ export const ellipseArcOfEndpoints2 = (from, to, radiusX, radiusY, xAxisRotation, largeArc, sweep) => {
9
+ let rx = Math.abs(radiusX);
10
+ let ry = Math.abs(radiusY);
11
+ if ((from[0] === to[0] && from[1] === to[1]) || rx === 0 || ry === 0) {
12
+ return undefined;
13
+ }
14
+ const cosPhi = Math.cos(xAxisRotation);
15
+ const sinPhi = Math.sin(xAxisRotation);
16
+ const dx = (from[0] - to[0]) / 2;
17
+ const dy = (from[1] - to[1]) / 2;
18
+ const x1p = cosPhi * dx + sinPhi * dy;
19
+ const y1p = -sinPhi * dx + cosPhi * dy;
20
+ const lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);
21
+ if (lambda > 1) {
22
+ const s = Math.sqrt(lambda);
23
+ rx *= s;
24
+ ry *= s;
25
+ }
26
+ const rx2 = rx * rx;
27
+ const ry2 = ry * ry;
28
+ const num = rx2 * ry2 - rx2 * y1p * y1p - ry2 * x1p * x1p;
29
+ const den = rx2 * y1p * y1p + ry2 * x1p * x1p;
30
+ const size = den === 0 ? 0 : Math.sqrt(Math.max(0, num / den));
31
+ const factor = largeArc === sweep ? -size : size;
32
+ const cxp = (factor * rx * y1p) / ry;
33
+ const cyp = (-factor * ry * x1p) / rx;
34
+ const startAngle = turnBetween(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
35
+ let deltaAngle = turnBetween((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
36
+ if (!sweep && deltaAngle > 0) {
37
+ deltaAngle -= FULL_TURN;
38
+ }
39
+ if (sweep && deltaAngle < 0) {
40
+ deltaAngle += FULL_TURN;
41
+ }
42
+ return {
43
+ center: [cosPhi * cxp - sinPhi * cyp + (from[0] + to[0]) / 2, sinPhi * cxp + cosPhi * cyp + (from[1] + to[1]) / 2],
44
+ rx,
45
+ ry,
46
+ xAxisRotation,
47
+ startAngle,
48
+ deltaAngle,
49
+ };
50
+ };
51
+ export const affineEllipseArc2 = (matrix, arc) => {
52
+ const [a, b, c, d, tx, ty] = matrix;
53
+ const cosP = Math.cos(arc.xAxisRotation);
54
+ const sinP = Math.sin(arc.xAxisRotation);
55
+ const r00 = cosP * arc.rx;
56
+ const r10 = sinP * arc.rx;
57
+ const r01 = -sinP * arc.ry;
58
+ const r11 = cosP * arc.ry;
59
+ const m00 = a * r00 + c * r10;
60
+ const m10 = b * r00 + d * r10;
61
+ const m01 = a * r01 + c * r11;
62
+ const m11 = b * r01 + d * r11;
63
+ const e = (m00 + m11) / 2;
64
+ const f = (m00 - m11) / 2;
65
+ const g = (m10 + m01) / 2;
66
+ const h = (m10 - m01) / 2;
67
+ const q = Math.hypot(e, h);
68
+ const r = Math.hypot(f, g);
69
+ const sx = q + r;
70
+ const sy = Math.abs(q - r);
71
+ const theta = (Math.atan2(h, e) + Math.atan2(g, f)) / 2;
72
+ const cosT = Math.cos(theta);
73
+ const sinT = Math.sin(theta);
74
+ const imageAngle = (angle) => {
75
+ const px = m00 * Math.cos(angle) + m01 * Math.sin(angle);
76
+ const py = m10 * Math.cos(angle) + m11 * Math.sin(angle);
77
+ return Math.atan2((-sinT * px + cosT * py) / (sy || 1), (cosT * px + sinT * py) / (sx || 1));
78
+ };
79
+ const startAngle = imageAngle(arc.startAngle);
80
+ let deltaAngle = imageAngle(arc.startAngle + arc.deltaAngle) - startAngle;
81
+ const sweepSign = cross2([a, b], [c, d]) < 0 ? -Math.sign(arc.deltaAngle) : Math.sign(arc.deltaAngle);
82
+ if (sweepSign > 0 && deltaAngle < 0) {
83
+ deltaAngle += FULL_TURN;
84
+ }
85
+ if (sweepSign < 0 && deltaAngle > 0) {
86
+ deltaAngle -= FULL_TURN;
87
+ }
88
+ return {
89
+ center: [a * arc.center[0] + c * arc.center[1] + tx, b * arc.center[0] + d * arc.center[1] + ty],
90
+ rx: sx,
91
+ ry: sy,
92
+ xAxisRotation: theta,
93
+ startAngle,
94
+ deltaAngle: sweepSign === 0 ? 0 : deltaAngle,
95
+ };
96
+ };
@@ -7,7 +7,9 @@ type Vec3 = Inputs.Base.Vector3;
7
7
  export declare const PARALLEL_SINE = 1e-9;
8
8
  /**
9
9
  * A frame as the four vectors the maths reads: the origin and three unit axes at right angles,
10
- * with `y` the cross product of `z` and `x`.
10
+ * with `y` the cross product of `z` and `x`. `vectorToWorld`, `pointToWorld` and `composeAxes`
11
+ * also map by axes of any length and angle, such as a scaled block insert's; the `ToLocal`
12
+ * functions and `relativeAxes` undo only unit axes at right angles.
11
13
  */
12
14
  export interface FrameAxes {
13
15
  readonly origin: Vec3;
@@ -0,0 +1,6 @@
1
+ export declare const NESTING_BOX_MARGIN = 0.01;
2
+ export declare const INTERIOR_SCANLINES: number[];
3
+ export declare const COINCIDENT_AREA_SHARE = 1e-9;
4
+ export declare const SWEEP_CANDIDATES_PER_PAIR = 1000;
5
+ export declare const SWEEP_STEPS_PER_BOX = 20;
6
+ export declare const SWEEP_STEPS_PER_CANDIDATE = 2;
@@ -0,0 +1,6 @@
1
+ export const NESTING_BOX_MARGIN = 0.01;
2
+ export const INTERIOR_SCANLINES = [0.5, 0.25, 0.75, 0.125, 0.375, 0.625, 0.875];
3
+ export const COINCIDENT_AREA_SHARE = 1e-9;
4
+ export const SWEEP_CANDIDATES_PER_PAIR = 1000;
5
+ export const SWEEP_STEPS_PER_BOX = 20;
6
+ export const SWEEP_STEPS_PER_CANDIDATE = 2;
@@ -0,0 +1,31 @@
1
+ import type * as Inputs from "../../../inputs";
2
+ import { WorkBudget } from "../files/work-budget";
3
+ type Point2 = Inputs.Base.Point2;
4
+ export type FillRule2 = "nonzero" | "evenOdd";
5
+ export interface Box2 {
6
+ min: Point2;
7
+ max: Point2;
8
+ }
9
+ export interface NestingOutline2 {
10
+ points: Point2[];
11
+ area: number;
12
+ box: Box2;
13
+ inner?: Point2;
14
+ }
15
+ export interface FilledRegion2 {
16
+ outer: number;
17
+ holes: number[];
18
+ }
19
+ export declare const boxOf2: (points: readonly Point2[]) => Box2;
20
+ export declare const boxesOverlap2: (a: Box2, b: Box2) => boolean;
21
+ export declare const interiorPoint2: (points: readonly Point2[], box?: Box2) => Point2 | undefined;
22
+ export declare const nestingOutlineOf2: (points: Point2[]) => NestingOutline2;
23
+ export declare function overlappingBoxPairs2(boxes: readonly Box2[]): [number, number][];
24
+ export declare function overlappingBoxPairs2(boxes: readonly Box2[], most: number, budget?: WorkBudget): [number, number][] | undefined;
25
+ export declare const segmentsCross2: (p1: Point2, p2: Point2, q1: Point2, q2: Point2) => boolean;
26
+ export declare function outlinesCross2(outlines: readonly NestingOutline2[], pairs: readonly (readonly [number, number])[]): boolean;
27
+ export declare function outlinesCross2(outlines: readonly NestingOutline2[], pairs: readonly (readonly [number, number])[], budget: WorkBudget): boolean | undefined;
28
+ export declare function nestedOutlines2(outlines: readonly NestingOutline2[], pairs: readonly (readonly [number, number])[]): number[][];
29
+ export declare function nestedOutlines2(outlines: readonly NestingOutline2[], pairs: readonly (readonly [number, number])[], budget: WorkBudget): number[][] | undefined;
30
+ export declare const filledRegions2: (outlines: readonly NestingOutline2[], ancestors: readonly (readonly number[])[], rule: FillRule2) => FilledRegion2[];
31
+ export {};
@@ -0,0 +1,251 @@
1
+ import { WorkBudget } from "../files/work-budget";
2
+ import { isInsidePolygon2, signedArea2 } from "./polygons";
3
+ import { cross2, subtract2 } from "./vectors";
4
+ import { COINCIDENT_AREA_SHARE, INTERIOR_SCANLINES, NESTING_BOX_MARGIN, SWEEP_CANDIDATES_PER_PAIR, SWEEP_STEPS_PER_BOX, SWEEP_STEPS_PER_CANDIDATE, } from "./polygon-nesting.constants";
5
+ const SWEEP_AXES = [0, 1];
6
+ export const boxOf2 = (points) => {
7
+ const min = [Infinity, Infinity];
8
+ const max = [-Infinity, -Infinity];
9
+ for (const [x, y] of points) {
10
+ min[0] = Math.min(min[0], x);
11
+ min[1] = Math.min(min[1], y);
12
+ max[0] = Math.max(max[0], x);
13
+ max[1] = Math.max(max[1], y);
14
+ }
15
+ return { min, max };
16
+ };
17
+ export const boxesOverlap2 = (a, b) => a.min[0] <= b.max[0] && b.min[0] <= a.max[0] && a.min[1] <= b.max[1] && b.min[1] <= a.max[1];
18
+ const boxHolds = (outer, inner) => {
19
+ const margin = NESTING_BOX_MARGIN * Math.max(outer.max[0] - outer.min[0], outer.max[1] - outer.min[1]);
20
+ return inner.min[0] >= outer.min[0] - margin && inner.min[1] >= outer.min[1] - margin
21
+ && inner.max[0] <= outer.max[0] + margin && inner.max[1] <= outer.max[1] + margin;
22
+ };
23
+ const widestSpanAt = (points, y) => {
24
+ const xs = [];
25
+ for (let at = 0, previous = points.length - 1; at < points.length; previous = at++) {
26
+ const [x1, y1] = points[at];
27
+ const [x2, y2] = points[previous];
28
+ if ((y1 > y) !== (y2 > y)) {
29
+ xs.push(x1 + (y - y1) * (x2 - x1) / (y2 - y1));
30
+ }
31
+ }
32
+ xs.sort((a, b) => a - b);
33
+ let best;
34
+ for (let k = 0; k + 1 < xs.length; k += 2) {
35
+ const width = xs[k + 1] - xs[k];
36
+ if (width > 0 && (!best || width > best.width)) {
37
+ best = { width, middle: [(xs[k] + xs[k + 1]) / 2, y] };
38
+ }
39
+ }
40
+ return best;
41
+ };
42
+ export const interiorPoint2 = (points, box = boxOf2(points)) => {
43
+ let best;
44
+ for (const share of INTERIOR_SCANLINES) {
45
+ const span = widestSpanAt(points, box.min[1] + (box.max[1] - box.min[1]) * share);
46
+ if (span && (!best || span.width > best.width)) {
47
+ best = span;
48
+ }
49
+ }
50
+ return best === null || best === void 0 ? void 0 : best.middle;
51
+ };
52
+ export const nestingOutlineOf2 = (points) => {
53
+ const box = boxOf2(points);
54
+ const area = signedArea2(points);
55
+ const outline = { points, area, box };
56
+ const inner = area === 0 ? undefined : interiorPoint2(points, box);
57
+ if (inner) {
58
+ outline.inner = inner;
59
+ }
60
+ return outline;
61
+ };
62
+ const firstAbove = (sorted, value) => {
63
+ let low = 0;
64
+ let high = sorted.length;
65
+ while (low < high) {
66
+ const middle = (low + high) >> 1;
67
+ if (sorted[middle] > value) {
68
+ high = middle;
69
+ }
70
+ else {
71
+ low = middle + 1;
72
+ }
73
+ }
74
+ return low;
75
+ };
76
+ const sweepOrder = (boxes, axis) => boxes.map((_, i) => i).sort((a, b) => boxes[a].min[axis] - boxes[b].min[axis]);
77
+ const sweepCandidates = (boxes, order, axis) => {
78
+ const starts = order.map((i) => boxes[i].min[axis]);
79
+ return order.reduce((sum, i, k) => sum + Math.max(0, firstAbove(starts, boxes[i].max[axis]) - k - 1), 0);
80
+ };
81
+ const sweptPairs = (boxes, order, axis, most) => {
82
+ const pairs = [];
83
+ for (let k = 0; k < order.length; k++) {
84
+ const i = order[k];
85
+ const a = boxes[i];
86
+ for (let m = k + 1; m < order.length; m++) {
87
+ const j = order[m];
88
+ const b = boxes[j];
89
+ if (b.min[axis] > a.max[axis]) {
90
+ break;
91
+ }
92
+ if (boxesOverlap2(a, b)) {
93
+ if (pairs.length >= most) {
94
+ return undefined;
95
+ }
96
+ pairs.push([i, j]);
97
+ }
98
+ }
99
+ }
100
+ return pairs;
101
+ };
102
+ const unbounded = () => new WorkBudget(Number.POSITIVE_INFINITY);
103
+ export function overlappingBoxPairs2(boxes, most = Number.POSITIVE_INFINITY, budget = unbounded()) {
104
+ const examinable = most * SWEEP_CANDIDATES_PER_PAIR;
105
+ for (const axis of SWEEP_AXES) {
106
+ if (!budget.spend(boxes.length * SWEEP_STEPS_PER_BOX)) {
107
+ return undefined;
108
+ }
109
+ const order = sweepOrder(boxes, axis);
110
+ const candidates = sweepCandidates(boxes, order, axis);
111
+ if (candidates <= examinable) {
112
+ return budget.spend(candidates * SWEEP_STEPS_PER_CANDIDATE) ? sweptPairs(boxes, order, axis, most) : undefined;
113
+ }
114
+ }
115
+ return undefined;
116
+ }
117
+ export const segmentsCross2 = (p1, p2, q1, q2) => {
118
+ const d = subtract2(p2, p1);
119
+ const e = subtract2(q2, q1);
120
+ return cross2(d, subtract2(q1, p1)) * cross2(d, subtract2(q2, p1)) < 0 && cross2(e, subtract2(p1, q1)) * cross2(e, subtract2(p2, q1)) < 0;
121
+ };
122
+ const spanMeets = (p, q, low, high) => Math.min(p, q) <= high && low <= Math.max(p, q);
123
+ const edgesNear = (outline, box) => {
124
+ const { points } = outline;
125
+ const near = [];
126
+ for (let k = 0; k < points.length; k++) {
127
+ const p = points[k];
128
+ const q = points[(k + 1) % points.length];
129
+ if (spanMeets(p[0], q[0], box.min[0], box.max[0]) && spanMeets(p[1], q[1], box.min[1], box.max[1])) {
130
+ near.push(k);
131
+ }
132
+ }
133
+ return near;
134
+ };
135
+ const edgeBoxesOf = (outline, edges) => {
136
+ const boxes = {
137
+ minX: new Float64Array(edges.length), minY: new Float64Array(edges.length), maxX: new Float64Array(edges.length), maxY: new Float64Array(edges.length),
138
+ };
139
+ edges.forEach((k, at) => {
140
+ const p = outline.points[k];
141
+ const q = outline.points[(k + 1) % outline.points.length];
142
+ boxes.minX[at] = Math.min(p[0], q[0]);
143
+ boxes.minY[at] = Math.min(p[1], q[1]);
144
+ boxes.maxX[at] = Math.max(p[0], q[0]);
145
+ boxes.maxY[at] = Math.max(p[1], q[1]);
146
+ });
147
+ return boxes;
148
+ };
149
+ const edgeCrossesAny = (a, k, b, edges, boxes) => {
150
+ const p1 = a.points[k];
151
+ const p2 = a.points[(k + 1) % a.points.length];
152
+ const minX = Math.min(p1[0], p2[0]);
153
+ const minY = Math.min(p1[1], p2[1]);
154
+ const maxX = Math.max(p1[0], p2[0]);
155
+ const maxY = Math.max(p1[1], p2[1]);
156
+ for (let at = 0; at < edges.length; at++) {
157
+ if (boxes.minX[at] <= maxX && minX <= boxes.maxX[at] && boxes.minY[at] <= maxY && minY <= boxes.maxY[at]
158
+ && segmentsCross2(p1, p2, b.points[edges[at]], b.points[(edges[at] + 1) % b.points.length])) {
159
+ return true;
160
+ }
161
+ }
162
+ return false;
163
+ };
164
+ export function outlinesCross2(outlines, pairs, budget = unbounded()) {
165
+ for (const [first, second] of pairs) {
166
+ const a = outlines[first];
167
+ const b = outlines[second];
168
+ if (!budget.spend(a.points.length)) {
169
+ return undefined;
170
+ }
171
+ const ofA = edgesNear(a, b.box);
172
+ if (ofA.length === 0) {
173
+ continue;
174
+ }
175
+ if (!budget.spend(b.points.length)) {
176
+ return undefined;
177
+ }
178
+ const ofB = edgesNear(b, a.box);
179
+ const boxesOfB = edgeBoxesOf(b, ofB);
180
+ for (const k of ofA) {
181
+ if (!budget.spend(ofB.length)) {
182
+ return undefined;
183
+ }
184
+ if (edgeCrossesAny(a, k, b, ofB, boxesOfB)) {
185
+ return true;
186
+ }
187
+ }
188
+ }
189
+ return false;
190
+ }
191
+ const sameSize = (a, b) => Math.abs(a - b) <= COINCIDENT_AREA_SHARE * Math.max(a, b);
192
+ export function nestedOutlines2(outlines, pairs, budget = unbounded()) {
193
+ const ancestors = outlines.map(() => []);
194
+ let affordable = true;
195
+ const holds = (outer, inner) => {
196
+ if (inner.inner === undefined || !boxHolds(outer.box, inner.box)) {
197
+ return false;
198
+ }
199
+ affordable = budget.spend(outer.points.length);
200
+ return affordable && isInsidePolygon2(inner.inner, outer.points);
201
+ };
202
+ for (const [first, second] of pairs) {
203
+ const sizeOfFirst = Math.abs(outlines[first].area);
204
+ const sizeOfSecond = Math.abs(outlines[second].area);
205
+ if (sameSize(sizeOfFirst, sizeOfSecond)) {
206
+ if (holds(outlines[first], outlines[second]) && holds(outlines[second], outlines[first])) {
207
+ ancestors[Math.max(first, second)].push(Math.min(first, second));
208
+ }
209
+ }
210
+ else {
211
+ const [big, small] = sizeOfFirst > sizeOfSecond ? [first, second] : [second, first];
212
+ if (holds(outlines[big], outlines[small])) {
213
+ ancestors[small].push(big);
214
+ }
215
+ }
216
+ if (!affordable) {
217
+ return undefined;
218
+ }
219
+ }
220
+ return ancestors;
221
+ }
222
+ export const filledRegions2 = (outlines, ancestors, rule) => {
223
+ const depth = ancestors.map((a) => a.length);
224
+ const parent = ancestors.map((a) => a.reduce((best, j) => (best === -1 || depth[j] > depth[best] ? j : best), -1));
225
+ const sign = outlines.map((outline) => Math.sign(outline.area));
226
+ const filled = outlines.map((_, i) => rule === "evenOdd"
227
+ ? depth[i] % 2 === 0
228
+ : sign[i] + ancestors[i].reduce((sum, j) => sum + sign[j], 0) !== 0);
229
+ const effective = outlines.map((outline, i) => outline.inner !== undefined && filled[i] !== (parent[i] === -1 ? false : filled[parent[i]]));
230
+ const effectiveParent = (i) => {
231
+ let up = parent[i];
232
+ while (up !== -1 && !effective[up]) {
233
+ up = parent[up];
234
+ }
235
+ return up;
236
+ };
237
+ const regions = new Map();
238
+ outlines.forEach((_, i) => {
239
+ if (effective[i] && filled[i]) {
240
+ regions.set(i, { outer: i, holes: [] });
241
+ }
242
+ });
243
+ outlines.forEach((_, i) => {
244
+ var _a;
245
+ if (effective[i] && !filled[i]) {
246
+ (_a = regions.get(effectiveParent(i))) === null || _a === void 0 ? void 0 : _a.holes.push(i);
247
+ }
248
+ });
249
+ const sizeOf = (i) => Math.abs(outlines[i].area);
250
+ return [...regions.values()].filter((region) => !region.holes.some((hole) => sameSize(sizeOf(hole), sizeOf(region.outer))));
251
+ };
@@ -0,0 +1,3 @@
1
+ export declare const GIMBAL_SINE: number;
2
+ export declare const QUARTER_TURN_DEGREES = 90;
3
+ export declare const QUATERNION_LENGTH = 4;
@@ -0,0 +1,3 @@
1
+ export const GIMBAL_SINE = 1 - 1e-12;
2
+ export const QUARTER_TURN_DEGREES = 90;
3
+ export const QUATERNION_LENGTH = 4;
@@ -0,0 +1,14 @@
1
+ import type * as Inputs from "../../../inputs";
2
+ import type { FrameAxes } from "./frame-axes";
3
+ type Quaternion = Inputs.Base.Quaternion;
4
+ type Vec3 = Inputs.Base.Vector3;
5
+ export declare const isQuaternion: (value: unknown) => value is Quaternion;
6
+ export declare const unitQuaternion: (quaternion: Quaternion) => Quaternion | undefined;
7
+ export declare const quaternionAbout: (unitAxis: Vec3, degrees: number) => Quaternion;
8
+ export declare const quaternionProduct: (a: Quaternion, b: Quaternion) => Quaternion;
9
+ export declare const quaternionOfDegrees: (angles: Vec3) => Quaternion;
10
+ export declare const quaternionTurned: (unit: Quaternion, vector: Vec3) => Vec3;
11
+ export declare const degreesOfQuaternion: (unit: Quaternion) => Vec3;
12
+ export declare const quaternionOfAxes: ({ x, y, z }: Pick<FrameAxes, "x" | "y" | "z">) => Quaternion;
13
+ export declare const quaternionMatrix: ([x, y, z, w]: Quaternion) => Inputs.Base.TransformMatrix;
14
+ export {};
@@ -0,0 +1,71 @@
1
+ import { degreesOf, radiansOf } from "./scalars";
2
+ import { GIMBAL_SINE, QUARTER_TURN_DEGREES, QUATERNION_LENGTH } from "./quaternions.constants";
3
+ const HALF = 0.5;
4
+ export const isQuaternion = (value) => Array.isArray(value) && value.length === QUATERNION_LENGTH && value.every(n => typeof n === "number" && Number.isFinite(n));
5
+ export const unitQuaternion = (quaternion) => {
6
+ const length = Math.hypot(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);
7
+ if (!(length > 0 && length < Infinity)) {
8
+ return undefined;
9
+ }
10
+ return [quaternion[0] / length, quaternion[1] / length, quaternion[2] / length, quaternion[3] / length];
11
+ };
12
+ export const quaternionAbout = (unitAxis, degrees) => {
13
+ const half = radiansOf(degrees) * HALF;
14
+ const sine = Math.sin(half);
15
+ return [unitAxis[0] * sine, unitAxis[1] * sine, unitAxis[2] * sine, Math.cos(half)];
16
+ };
17
+ export const quaternionProduct = (a, b) => [
18
+ a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],
19
+ a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],
20
+ a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],
21
+ a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],
22
+ ];
23
+ export const quaternionOfDegrees = (angles) => quaternionProduct(quaternionAbout([0, 0, 1], angles[2]), quaternionProduct(quaternionAbout([0, 1, 0], angles[1]), quaternionAbout([1, 0, 0], angles[0])));
24
+ export const quaternionTurned = (unit, vector) => {
25
+ const [x, y, z, w] = unit;
26
+ const tx = 2 * (y * vector[2] - z * vector[1]);
27
+ const ty = 2 * (z * vector[0] - x * vector[2]);
28
+ const tz = 2 * (x * vector[1] - y * vector[0]);
29
+ return [vector[0] + w * tx + (y * tz - z * ty), vector[1] + w * ty + (z * tx - x * tz), vector[2] + w * tz + (x * ty - y * tx)];
30
+ };
31
+ export const degreesOfQuaternion = (unit) => {
32
+ const [x, y, z, w] = unit;
33
+ const r00 = 1 - 2 * (y * y + z * z);
34
+ const r01 = 2 * (x * y - z * w);
35
+ const r10 = 2 * (x * y + z * w);
36
+ const r11 = 1 - 2 * (x * x + z * z);
37
+ const r20 = 2 * (x * z - y * w);
38
+ const r21 = 2 * (y * z + x * w);
39
+ const r22 = 1 - 2 * (x * x + y * y);
40
+ if (Math.abs(r20) > GIMBAL_SINE) {
41
+ return [0, r20 > 0 ? -QUARTER_TURN_DEGREES : QUARTER_TURN_DEGREES, degreesOf(Math.atan2(-r01, r11))];
42
+ }
43
+ return [degreesOf(Math.atan2(r21, r22)), degreesOf(Math.asin(-r20)), degreesOf(Math.atan2(r10, r00))];
44
+ };
45
+ export const quaternionOfAxes = ({ x, y, z }) => {
46
+ const trace = x[0] + y[1] + z[2];
47
+ if (trace > 0) {
48
+ const root = Math.sqrt(trace + 1);
49
+ const share = HALF / root;
50
+ return [(y[2] - z[1]) * share, (z[0] - x[2]) * share, (x[1] - y[0]) * share, root * HALF];
51
+ }
52
+ if (x[0] > y[1] && x[0] > z[2]) {
53
+ const root = Math.sqrt(1 + x[0] - y[1] - z[2]);
54
+ const share = HALF / root;
55
+ return [root * HALF, (y[0] + x[1]) * share, (z[0] + x[2]) * share, (y[2] - z[1]) * share];
56
+ }
57
+ if (y[1] > z[2]) {
58
+ const root = Math.sqrt(1 + y[1] - x[0] - z[2]);
59
+ const share = HALF / root;
60
+ return [(y[0] + x[1]) * share, root * HALF, (z[1] + y[2]) * share, (z[0] - x[2]) * share];
61
+ }
62
+ const root = Math.sqrt(1 + z[2] - x[0] - y[1]);
63
+ const share = HALF / root;
64
+ return [(z[0] + x[2]) * share, (z[1] + y[2]) * share, root * HALF, (x[1] - y[0]) * share];
65
+ };
66
+ export const quaternionMatrix = ([x, y, z, w]) => [
67
+ 1 - 2 * (y * y + z * z), 2 * (x * y + z * w), 2 * (z * x - y * w), 0,
68
+ 2 * (x * y - z * w), 1 - 2 * (z * z + x * x), 2 * (y * z + x * w), 0,
69
+ 2 * (z * x + y * w), 2 * (y * z - x * w), 1 - 2 * (y * y + x * x), 0,
70
+ 0, 0, 0, 1,
71
+ ];
@@ -0,0 +1 @@
1
+ export declare const NICE_MANTISSAS: readonly [1, 2, 5];
@@ -0,0 +1 @@
1
+ export const NICE_MANTISSAS = [1, 2, 5];
@@ -1,3 +1,4 @@
1
+ import type * as Inputs from "../../../inputs";
1
2
  export declare const smoothstep: (value: number) => number;
2
3
  export declare const roundedTo: (value: number, places: number) => number;
3
4
  export declare const roundedToMillionths: (value: number) => number;
@@ -6,4 +7,6 @@ export declare const radiansOf: (degrees: number) => number;
6
7
  export declare const degreesOf: (radians: number) => number;
7
8
  export declare const angleOfCosine: (cosine: number) => number;
8
9
  export declare const interpolated: (start: number, end: number, share: number) => number;
10
+ export declare function shortestAngle(from: number, to: number, fullTurn: number): number;
11
+ export declare function niceStep(value: number, direction: `${Inputs.Math.niceStepDirectionEnum}`): number;
9
12
  export declare function fractionText(value: number, denominator: number): string;
@@ -1,18 +1,46 @@
1
+ import { NICE_MANTISSAS } from "./scalars.constants";
1
2
  const MILLIONTH_PLACES = 6;
2
3
  const DECIMAL_BASE = 10;
3
4
  const SMOOTHSTEP_RISE = 3;
4
5
  const HALF_TURN_DEGREES = 180;
6
+ const NICE_SLACK = 1e-9;
5
7
  export const smoothstep = (value) => {
6
8
  const t = Math.min(1, Math.max(0, value));
7
9
  return t * t * (SMOOTHSTEP_RISE - 2 * t);
8
10
  };
9
- export const roundedTo = (value, places) => Math.round(value * Math.pow(DECIMAL_BASE, places)) / Math.pow(DECIMAL_BASE, places);
11
+ export const roundedTo = (value, places) => {
12
+ const rounded = Math.round(value * Math.pow(DECIMAL_BASE, places)) / Math.pow(DECIMAL_BASE, places);
13
+ return rounded === 0 ? 0 : rounded;
14
+ };
10
15
  export const roundedToMillionths = (value) => roundedTo(value, MILLIONTH_PLACES);
11
16
  export const fractionOf = (value) => value - Math.floor(value);
12
17
  export const radiansOf = (degrees) => degrees * Math.PI / HALF_TURN_DEGREES;
13
18
  export const degreesOf = (radians) => radians * HALF_TURN_DEGREES / Math.PI;
14
19
  export const angleOfCosine = (cosine) => Math.acos(Math.min(1, Math.max(-1, cosine)));
15
20
  export const interpolated = (start, end, share) => start + (end - start) * share;
21
+ export function shortestAngle(from, to, fullTurn) {
22
+ const half = fullTurn / 2;
23
+ const delta = (to - from) % fullTurn;
24
+ if (delta > half) {
25
+ return from + delta - fullTurn;
26
+ }
27
+ return delta < -half ? from + delta + fullTurn : from + delta;
28
+ }
29
+ function niceValue(mantissa, exponent) {
30
+ return Number(`${String(mantissa)}e${String(exponent)}`);
31
+ }
32
+ export function niceStep(value, direction) {
33
+ var _a, _b;
34
+ const exponent = Math.floor(Math.log10(value));
35
+ const candidates = [exponent - 1, exponent, exponent + 1].flatMap(each => NICE_MANTISSAS.map(mantissa => niceValue(mantissa, each)));
36
+ if (direction === "up") {
37
+ return (_a = candidates.find(candidate => candidate >= value * (1 - NICE_SLACK))) !== null && _a !== void 0 ? _a : candidates[candidates.length - 1];
38
+ }
39
+ if (direction === "down") {
40
+ return (_b = candidates.filter(candidate => candidate <= value * (1 + NICE_SLACK)).pop()) !== null && _b !== void 0 ? _b : candidates[0];
41
+ }
42
+ return candidates.reduce((best, candidate) => Math.abs(Math.log(candidate / value)) < Math.abs(Math.log(best / value)) ? candidate : best);
43
+ }
16
44
  function greatestCommonDivisor(first, second) {
17
45
  let [a, b] = [first, second];
18
46
  while (b !== 0) {
@@ -22,4 +22,5 @@ export declare const cross3: (a: Vec3, b: Vec3) => Vec3;
22
22
  export declare const length3: (a: Vec3) => number;
23
23
  export declare const between3: (a: Vec3, b: Vec3, share: number) => Vec3;
24
24
  export declare const distance3: (a: Vec3, b: Vec3) => number;
25
+ export declare const distanceToSegment3: (point: Vec3, start: Vec3, end: Vec3) => number;
25
26
  export {};
@@ -41,3 +41,9 @@ export const cross3 = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] *
41
41
  export const length3 = (a) => Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
42
42
  export const between3 = (a, b, share) => [a[0] + (b[0] - a[0]) * share, a[1] + (b[1] - a[1]) * share, a[2] + (b[2] - a[2]) * share];
43
43
  export const distance3 = (a, b) => length3(subtract3(a, b));
44
+ export const distanceToSegment3 = (point, start, end) => {
45
+ const along = subtract3(end, start);
46
+ const reach = dot3(along, along);
47
+ const share = reach > 0 ? Math.min(Math.max(dot3(subtract3(point, start), along) / reach, 0), 1) : 0;
48
+ return distance3(point, between3(start, end, share));
49
+ };
@@ -5,3 +5,4 @@ export declare const POINT_SHARE = 1e-12;
5
5
  export declare const FLAT_SHARE = 1e-28;
6
6
  export declare const WELD_SHARE = 1e-9;
7
7
  export declare const PRUNE_SLACK: number;
8
+ export declare const TRIANGLE_SIDES = 3;
@@ -9,3 +9,4 @@ export const POINT_SHARE = 1e-12;
9
9
  export const FLAT_SHARE = 1e-28;
10
10
  export const WELD_SHARE = 1e-9;
11
11
  export const PRUNE_SLACK = 8 * Number.EPSILON;
12
+ export const TRIANGLE_SIDES = 3;
@@ -2,6 +2,7 @@ import type * as Inputs from "../../../inputs";
2
2
  import type { TreeBox, TriangleTree } from "../helper-types";
3
3
  type Vec = Inputs.Base.Point3;
4
4
  export declare function triangleTree(positions: ArrayLike<number>, indices: ArrayLike<number>): TriangleTree;
5
+ export declare function closestOnTriangle(p: Vec, a: Vec, b: Vec, c: Vec): Inputs.Base.TrianglePoint3;
5
6
  export declare function treesWithin(first: TriangleTree, second: TriangleTree, limit: number): boolean;
6
7
  export declare function pointInTree(tree: TriangleTree, point: Vec): boolean;
7
8
  export declare function pointOnTree(tree: TriangleTree): Vec | undefined;