flo-mat 2.0.2 → 2.0.3

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 (216) hide show
  1. package/browser/index.js +8230 -8229
  2. package/browser/index.min.js +1 -1
  3. package/node/circle.d.ts +20 -20
  4. package/node/circle.js +31 -31
  5. package/node/compare-curvatures-at-interface.d.ts +19 -19
  6. package/node/compare-curvatures-at-interface.js +124 -124
  7. package/node/contact-point.d.ts +26 -26
  8. package/node/contact-point.js +25 -25
  9. package/node/cp-node/clone.d.ts +8 -8
  10. package/node/cp-node/clone.js +31 -31
  11. package/node/cp-node/remove.d.ts +9 -9
  12. package/node/cp-node/remove.js +19 -19
  13. package/node/cp-node.d.ts +202 -202
  14. package/node/cp-node.js +320 -320
  15. package/node/curve.d.ts +46 -46
  16. package/node/curve.js +88 -88
  17. package/node/debug/cp-node-for-debugging.d.ts +11 -11
  18. package/node/debug/cp-node-for-debugging.js +1 -1
  19. package/node/debug/debug-elem-types.d.ts +32 -32
  20. package/node/debug/debug-elem-types.js +1 -1
  21. package/node/debug/debug.d.ts +50 -50
  22. package/node/debug/debug.js +75 -75
  23. package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
  24. package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
  25. package/node/debug/functions/draw-elem/branch.d.ts +4 -4
  26. package/node/debug/functions/draw-elem/branch.js +22 -22
  27. package/node/debug/functions/draw-elem/culls.d.ts +4 -4
  28. package/node/debug/functions/draw-elem/culls.js +21 -21
  29. package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
  30. package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
  31. package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
  32. package/node/debug/functions/draw-elem/draw-elem.js +45 -45
  33. package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
  34. package/node/debug/functions/draw-elem/dull-corner.js +10 -10
  35. package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
  36. package/node/debug/functions/draw-elem/leaves.js +12 -12
  37. package/node/debug/functions/draw-elem/loop.d.ts +4 -4
  38. package/node/debug/functions/draw-elem/loop.js +11 -11
  39. package/node/debug/functions/draw-elem/loops.d.ts +4 -4
  40. package/node/debug/functions/draw-elem/loops.js +6 -6
  41. package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
  42. package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
  43. package/node/debug/functions/draw-elem/mat.d.ts +4 -4
  44. package/node/debug/functions/draw-elem/mat.js +30 -30
  45. package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
  46. package/node/debug/functions/draw-elem/max-vertex.js +8 -8
  47. package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
  48. package/node/debug/functions/draw-elem/min-y.js +13 -13
  49. package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
  50. package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
  51. package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
  52. package/node/debug/functions/draw-elem/one-prong.js +16 -16
  53. package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
  54. package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
  55. package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
  56. package/node/debug/functions/draw-elem/three-prong.js +16 -16
  57. package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
  58. package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
  59. package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
  60. package/node/debug/functions/draw-elem/two-prong.js +36 -36
  61. package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
  62. package/node/debug/functions/draw-elem/vertex.js +27 -27
  63. package/node/debug/functions/general.d.ts +48 -48
  64. package/node/debug/functions/general.js +52 -52
  65. package/node/debug/functions/three-prong.d.ts +11 -11
  66. package/node/debug/functions/three-prong.js +184 -184
  67. package/node/debug/functions/two-prong.d.ts +13 -13
  68. package/node/debug/functions/two-prong.js +117 -117
  69. package/node/debug/three-prong-for-debugging.d.ts +31 -31
  70. package/node/debug/three-prong-for-debugging.js +20 -20
  71. package/node/debug/two-prong-for-debugging.d.ts +26 -26
  72. package/node/debug/two-prong-for-debugging.js +1 -1
  73. package/node/find-mats.d.ts +26 -26
  74. package/node/find-mats.js +122 -122
  75. package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
  76. package/node/get-boundary-bezier-parts-to-next.js +42 -42
  77. package/node/get-boundary-beziers-to-next.d.ts +8 -8
  78. package/node/get-boundary-beziers-to-next.js +44 -44
  79. package/node/get-bounding-box-.d.ts +2 -2
  80. package/node/get-bounding-box-.js +4 -4
  81. package/node/get-branches.d.ts +12 -12
  82. package/node/get-branches.js +68 -68
  83. package/node/get-curve/get-curve-between.d.ts +9 -9
  84. package/node/get-curve/get-curve-between.js +56 -56
  85. package/node/get-curve/get-edge-direction.d.ts +9 -9
  86. package/node/get-curve/get-edge-direction.js +53 -53
  87. package/node/get-curve-to-next.d.ts +9 -9
  88. package/node/get-curve-to-next.js +11 -11
  89. package/node/get-interface-ccw.d.ts +24 -24
  90. package/node/get-interface-ccw.js +97 -97
  91. package/node/index.d.ts +36 -36
  92. package/node/index.js +32 -32
  93. package/node/loop/get-max-coordinate.d.ts +10 -10
  94. package/node/loop/get-max-coordinate.js +43 -43
  95. package/node/loop.d.ts +16 -16
  96. package/node/loop.js +34 -34
  97. package/node/mat/add-to-cp-graph.d.ts +16 -16
  98. package/node/mat/add-to-cp-graph.js +30 -30
  99. package/node/mat/bezier-piece.d.ts +12 -12
  100. package/node/mat/bezier-piece.js +1 -1
  101. package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
  102. package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -72
  103. package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
  104. package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
  105. package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
  106. package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
  107. package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
  108. package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
  109. package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
  110. package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
  111. package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
  112. package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
  113. package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
  114. package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
  115. package/node/mat/corner.d.ts +37 -37
  116. package/node/mat/corner.js +1 -1
  117. package/node/mat/create-new-cp-tree.d.ts +9 -9
  118. package/node/mat/create-new-cp-tree.js +23 -23
  119. package/node/mat/elem-type-two-prong.d.ts +3 -3
  120. package/node/mat/elem-type-two-prong.js +1 -1
  121. package/node/mat/find-mat/add-1-prong.d.ts +12 -12
  122. package/node/mat/find-mat/add-1-prong.js +42 -42
  123. package/node/mat/find-mat/add-2-prong.d.ts +21 -21
  124. package/node/mat/find-mat/add-2-prong.js +192 -192
  125. package/node/mat/find-mat/add-3-prong.d.ts +19 -19
  126. package/node/mat/find-mat/add-3-prong.js +54 -54
  127. package/node/mat/find-mat/add-debug-info.d.ts +9 -9
  128. package/node/mat/find-mat/add-debug-info.js +67 -67
  129. package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
  130. package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
  131. package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
  132. package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
  133. package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
  134. package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
  135. package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
  136. package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
  137. package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
  138. package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
  139. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
  140. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
  141. package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
  142. package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
  143. package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
  144. package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
  145. package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
  146. package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
  147. package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
  148. package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
  149. package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
  150. package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
  151. package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
  152. package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
  153. package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
  154. package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
  155. package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
  156. package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
  157. package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
  158. package/node/mat/find-mat/find-and-add-2-prongs.js +73 -73
  159. package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
  160. package/node/mat/find-mat/find-and-add-3-prongs.js +146 -146
  161. package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
  162. package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
  163. package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
  164. package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
  165. package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
  166. package/node/mat/find-mat/get-sharp-corners.js +17 -17
  167. package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
  168. package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
  169. package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
  170. package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
  171. package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
  172. package/node/mat/get-boundary-piece-beziers.js +58 -58
  173. package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
  174. package/node/mat/get-contact-circles-at-interface.js +20 -20
  175. package/node/mat/get-largest-vertex.d.ts +4 -4
  176. package/node/mat/get-largest-vertex.js +9 -9
  177. package/node/mat/get-leaves.d.ts +4 -4
  178. package/node/mat/get-leaves.js +12 -12
  179. package/node/mat/get-neighboring-cps.d.ts +14 -14
  180. package/node/mat/get-neighboring-cps.js +30 -30
  181. package/node/mat/get-two-prong-type.d.ts +5 -5
  182. package/node/mat/get-two-prong-type.js +8 -8
  183. package/node/mat/is-another-cp-closeby.d.ts +20 -20
  184. package/node/mat/is-another-cp-closeby.js +55 -55
  185. package/node/mat/simplify-mat-map-only.d.ts +23 -23
  186. package/node/mat/simplify-mat-map-only.js +80 -80
  187. package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
  188. package/node/mat/to-scale-axis/add-debug-info.js +13 -13
  189. package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
  190. package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
  191. package/node/mat/to-scale-axis/cull.d.ts +12 -12
  192. package/node/mat/to-scale-axis/cull.js +132 -132
  193. package/node/mat/trim-mat.d.ts +8 -8
  194. package/node/mat/trim-mat.js +16 -16
  195. package/node/mat.d.ts +22 -22
  196. package/node/mat.js +1 -1
  197. package/node/point-on-shape.d.ts +73 -73
  198. package/node/point-on-shape.js +167 -167
  199. package/node/simplify-mat.d.ts +16 -16
  200. package/node/simplify-mat.js +71 -71
  201. package/node/svg/get-loop-bounds.d.ts +12 -12
  202. package/node/svg/get-loop-bounds.js +80 -80
  203. package/node/svg/get-min-y-pos.d.ts +8 -8
  204. package/node/svg/get-min-y-pos.js +9 -9
  205. package/node/svg/get-shape-bounds.d.ts +9 -9
  206. package/node/svg/get-shape-bounds.js +35 -35
  207. package/node/sweep-line/sweep-line.d.ts +18 -18
  208. package/node/sweep-line/sweep-line.js +72 -72
  209. package/node/to-scale-axis.d.ts +16 -16
  210. package/node/to-scale-axis.js +74 -74
  211. package/node/traverse-edges.d.ts +10 -10
  212. package/node/traverse-edges.js +21 -21
  213. package/node/traverse-vertices.d.ts +12 -12
  214. package/node/traverse-vertices.js +27 -27
  215. package/package.json +11 -11
  216. package/tsconfig.json +0 -1
@@ -1,185 +1,185 @@
1
- import { drawFs } from 'flo-draw';
2
- import { equal, getObjClosestTo } from 'flo-vector2d';
3
- /**
4
- * @hidden
5
- * Draws 3 lines from the given 3-prong center to its 3 contact points.
6
- * @param n - The 3-prong's zero-based index.
7
- */
8
- function drawSpokes(g, n) {
9
- const threeProng = _debug_.generated.elems.threeProng[n];
10
- //const g = threeProng.generated.g;
11
- const cc = threeProng.circle.center;
12
- const poss = threeProng.poss;
13
- //_debug_.fs.draw.line(g, [poss[0].p, cc], 'thin5 red');
14
- //_debug_.fs.draw.line(g, [poss[1].p, cc], 'thin5 red');
15
- //_debug_.fs.draw.line(g, [poss[2].p, cc], 'thin5 red');
16
- drawFs.line(g, [poss[0].p, cc], 'thin5 red');
17
- drawFs.line(g, [poss[1].p, cc], 'thin5 red');
18
- drawFs.line(g, [poss[2].p, cc], 'thin5 red');
19
- }
20
- /**
21
- * @hidden
22
- * Shows the circle for each boundary iteration.
23
- * @param n_ - The 3-prong's zero-based index. If ommitted, all will be shown.
24
- * @param idx - The specific boundary iteration index to view. If ommitted, all
25
- * will be shown.
26
- */
27
- function traceConvergence(g, n_, idx) {
28
- let sIndx;
29
- let eIndx;
30
- if (n_ === undefined) {
31
- sIndx = 0;
32
- eIndx = _debug_.generated.elems.threeProng.length;
33
- }
34
- else {
35
- sIndx = n_;
36
- eIndx = n_ + 1;
37
- }
38
- for (let n = sIndx; n < eIndx; n++) {
39
- const forDebugging = _debug_.generated.elems.threeProng[n];
40
- //const g = forDebugging.generated.g;
41
- console.log(forDebugging);
42
- const candidateThreeProngs = forDebugging.candidateThreeProngs;
43
- //-----------------------------
44
- //---- Get start and end index
45
- //-----------------------------
46
- let startIndx;
47
- let endIndx;
48
- if (n_ === undefined || idx === -1) {
49
- startIndx = forDebugging.bestIndx;
50
- endIndx = forDebugging.bestIndx + 1;
51
- }
52
- else {
53
- if (idx === undefined) {
54
- startIndx = 0;
55
- endIndx = candidateThreeProngs.length;
56
- }
57
- else {
58
- startIndx = idx;
59
- endIndx = idx + 1;
60
- }
61
- }
62
- //---------------------------------
63
- //---- Draw candidate three-prongs
64
- //---------------------------------
65
- for (let i = startIndx; i < endIndx; i++) {
66
- const circle = candidateThreeProngs[i].circle;
67
- if (forDebugging.bestIndx === i) {
68
- drawFs.dot(g, circle.center, 0.2, 'green');
69
- drawFs.circle(g, circle, 'black thin10 nofill');
70
- }
71
- else {
72
- drawFs.dot(g, circle.center, 0.2, 'cyan');
73
- drawFs.circle(g, circle, 'cyan thin5 nofill');
74
- }
75
- }
76
- }
77
- }
78
- /**
79
- * @hidden
80
- * Shows the actual boundary for each iteration.
81
- * @param n The 3-prong's zero-based index.
82
- * @param idx The specific boundary iteration index to view. If ommitted will
83
- * show all.
84
- */
85
- function showBoundary(g, n, idx) {
86
- const debugInfo = _debug_.generated.elems.threeProng[n];
87
- //const g = debugInfo.generated.g;
88
- const candidateThreeProngs = debugInfo.candidateThreeProngs;
89
- const startIndx = idx === undefined ? 0 : idx;
90
- const endIndx = idx === undefined ? candidateThreeProngs.length : idx;
91
- // Draw relevant δs
92
- const cpss = debugInfo.cpss;
93
- let j = 0;
94
- // For each iteration of δ3s (indexed by j)
95
- for (let idx = 1; idx < cpss.length - 1; idx++) {
96
- if (!(j >= startIndx && j <= endIndx)) {
97
- j++;
98
- continue;
99
- }
100
- const δ3s = [
101
- cpss[0],
102
- cpss[idx],
103
- cpss[cpss.length - 1]
104
- ];
105
- // For each of the 3 δs
106
- for (let i = 0; i < 3; i++) {
107
- const δ = δ3s[i];
108
- const δS = δ[0]; // Delta Start
109
- const δE = δ[1]; // Delta End
110
- const posS = δS.cp.pointOnShape;
111
- const posE = δE.cp.pointOnShape;
112
- const pS = posS.p;
113
- const pE = posE.p;
114
- const r = 1 + (i * 0.5);
115
- if (equal(pS, pE)) {
116
- drawFs.crossHair(g, pS, 'red thin10 nofill', r);
117
- }
118
- else {
119
- drawFs.crossHair(g, pS, 'green thin10 nofill', r);
120
- drawFs.crossHair(g, pE, 'blue thin10 nofill', r);
121
- }
122
- }
123
- j++;
124
- }
125
- }
126
- /**
127
- * @hidden
128
- * @param n The 3-prong's zero-based index.
129
- */
130
- function logδs(n) {
131
- const threeProng = _debug_.generated.elems.threeProng[n];
132
- console.log(threeProng.cpss);
133
- }
134
- /**
135
- * @hidden
136
- * @param p
137
- */
138
- function logNearest(showSpokes = true, showTrace = true, showBoundaries = true) {
139
- return function (g, p, showDelay = 1000) {
140
- const generated = _debug_.generated;
141
- const threeProng = getObjClosestTo(p, generated.elems.threeProng, threeProng => threeProng.circle ? threeProng.circle.center : [0, 0]);
142
- const circle = threeProng.circle;
143
- //const g = threeProng.generated.g;
144
- console.log(threeProng);
145
- const circle2 = {
146
- center: circle.center,
147
- radius: circle.radius || 1
148
- };
149
- //const draw = _debug_.fs.draw;
150
- drawFs.circle(g, circle2, 'blue thin10 nofill', showDelay);
151
- drawFs.crossHair(g, circle.center, 'red thin2 nofill', 2, showDelay);
152
- if (showSpokes) {
153
- drawFs.line(g, [threeProng.poss[0].p, circle.center], 'blue thin5 nofill', showDelay);
154
- drawFs.line(g, [threeProng.poss[1].p, circle.center], 'blue thin5 nofill', showDelay);
155
- drawFs.line(g, [threeProng.poss[2].p, circle.center], 'blue thin5 nofill', showDelay);
156
- }
157
- if (showBoundaries) {
158
- const boundaries = threeProng.boundaries;
159
- const boundaryS = boundaries[0];
160
- const boundaryE = boundaries[boundaries.length - 1];
161
- drawFs.beziers(g, boundaryS, 'red thin20 nofill', showDelay);
162
- for (let i = 1; i < boundaries.length - 1; i++) {
163
- const boundary = boundaries[i];
164
- drawFs.beziers(g, boundary, 'green thin20 nofill', showDelay);
165
- }
166
- drawFs.beziers(g, boundaryE, 'blue thin20 nofill', showDelay);
167
- }
168
- if (showTrace) {
169
- const traces = threeProng.traces;
170
- for (const trace of traces) {
171
- drawFs.polyline(g, trace, 'red thin5 nofill', showDelay);
172
- }
173
- }
174
- };
175
- }
176
- /** @hidden */
177
- const threeProngDebugFunctions = {
178
- drawSpokes,
179
- traceConvergence,
180
- showBoundary,
181
- logδs,
182
- logNearest
183
- };
184
- export { threeProngDebugFunctions };
1
+ import { drawFs } from 'flo-draw';
2
+ import { equal, getObjClosestTo } from 'flo-vector2d';
3
+ /**
4
+ * @hidden
5
+ * Draws 3 lines from the given 3-prong center to its 3 contact points.
6
+ * @param n - The 3-prong's zero-based index.
7
+ */
8
+ function drawSpokes(g, n) {
9
+ const threeProng = _debug_.generated.elems.threeProng[n];
10
+ //const g = threeProng.generated.g;
11
+ const cc = threeProng.circle.center;
12
+ const poss = threeProng.poss;
13
+ //_debug_.fs.draw.line(g, [poss[0].p, cc], 'thin5 red');
14
+ //_debug_.fs.draw.line(g, [poss[1].p, cc], 'thin5 red');
15
+ //_debug_.fs.draw.line(g, [poss[2].p, cc], 'thin5 red');
16
+ drawFs.line(g, [poss[0].p, cc], 'thin5 red');
17
+ drawFs.line(g, [poss[1].p, cc], 'thin5 red');
18
+ drawFs.line(g, [poss[2].p, cc], 'thin5 red');
19
+ }
20
+ /**
21
+ * @hidden
22
+ * Shows the circle for each boundary iteration.
23
+ * @param n_ - The 3-prong's zero-based index. If ommitted, all will be shown.
24
+ * @param idx - The specific boundary iteration index to view. If ommitted, all
25
+ * will be shown.
26
+ */
27
+ function traceConvergence(g, n_, idx) {
28
+ let sIndx;
29
+ let eIndx;
30
+ if (n_ === undefined) {
31
+ sIndx = 0;
32
+ eIndx = _debug_.generated.elems.threeProng.length;
33
+ }
34
+ else {
35
+ sIndx = n_;
36
+ eIndx = n_ + 1;
37
+ }
38
+ for (let n = sIndx; n < eIndx; n++) {
39
+ const forDebugging = _debug_.generated.elems.threeProng[n];
40
+ //const g = forDebugging.generated.g;
41
+ console.log(forDebugging);
42
+ const candidateThreeProngs = forDebugging.candidateThreeProngs;
43
+ //-----------------------------
44
+ //---- Get start and end index
45
+ //-----------------------------
46
+ let startIndx;
47
+ let endIndx;
48
+ if (n_ === undefined || idx === -1) {
49
+ startIndx = forDebugging.bestIndx;
50
+ endIndx = forDebugging.bestIndx + 1;
51
+ }
52
+ else {
53
+ if (idx === undefined) {
54
+ startIndx = 0;
55
+ endIndx = candidateThreeProngs.length;
56
+ }
57
+ else {
58
+ startIndx = idx;
59
+ endIndx = idx + 1;
60
+ }
61
+ }
62
+ //---------------------------------
63
+ //---- Draw candidate three-prongs
64
+ //---------------------------------
65
+ for (let i = startIndx; i < endIndx; i++) {
66
+ const circle = candidateThreeProngs[i].circle;
67
+ if (forDebugging.bestIndx === i) {
68
+ drawFs.dot(g, circle.center, 0.2, 'green');
69
+ drawFs.circle(g, circle, 'black thin10 nofill');
70
+ }
71
+ else {
72
+ drawFs.dot(g, circle.center, 0.2, 'cyan');
73
+ drawFs.circle(g, circle, 'cyan thin5 nofill');
74
+ }
75
+ }
76
+ }
77
+ }
78
+ /**
79
+ * @hidden
80
+ * Shows the actual boundary for each iteration.
81
+ * @param n The 3-prong's zero-based index.
82
+ * @param idx The specific boundary iteration index to view. If ommitted will
83
+ * show all.
84
+ */
85
+ function showBoundary(g, n, idx) {
86
+ const debugInfo = _debug_.generated.elems.threeProng[n];
87
+ //const g = debugInfo.generated.g;
88
+ const candidateThreeProngs = debugInfo.candidateThreeProngs;
89
+ const startIndx = idx === undefined ? 0 : idx;
90
+ const endIndx = idx === undefined ? candidateThreeProngs.length : idx;
91
+ // Draw relevant δs
92
+ const cpss = debugInfo.cpss;
93
+ let j = 0;
94
+ // For each iteration of δ3s (indexed by j)
95
+ for (let idx = 1; idx < cpss.length - 1; idx++) {
96
+ if (!(j >= startIndx && j <= endIndx)) {
97
+ j++;
98
+ continue;
99
+ }
100
+ const δ3s = [
101
+ cpss[0],
102
+ cpss[idx],
103
+ cpss[cpss.length - 1]
104
+ ];
105
+ // For each of the 3 δs
106
+ for (let i = 0; i < 3; i++) {
107
+ const δ = δ3s[i];
108
+ const δS = δ[0]; // Delta Start
109
+ const δE = δ[1]; // Delta End
110
+ const posS = δS.cp.pointOnShape;
111
+ const posE = δE.cp.pointOnShape;
112
+ const pS = posS.p;
113
+ const pE = posE.p;
114
+ const r = 1 + (i * 0.5);
115
+ if (equal(pS, pE)) {
116
+ drawFs.crossHair(g, pS, 'red thin10 nofill', r);
117
+ }
118
+ else {
119
+ drawFs.crossHair(g, pS, 'green thin10 nofill', r);
120
+ drawFs.crossHair(g, pE, 'blue thin10 nofill', r);
121
+ }
122
+ }
123
+ j++;
124
+ }
125
+ }
126
+ /**
127
+ * @hidden
128
+ * @param n The 3-prong's zero-based index.
129
+ */
130
+ function logδs(n) {
131
+ const threeProng = _debug_.generated.elems.threeProng[n];
132
+ console.log(threeProng.cpss);
133
+ }
134
+ /**
135
+ * @hidden
136
+ * @param p
137
+ */
138
+ function logNearest(showSpokes = true, showTrace = true, showBoundaries = true) {
139
+ return function (g, p, showDelay = 1000) {
140
+ const generated = _debug_.generated;
141
+ const threeProng = getObjClosestTo(p, generated.elems.threeProng, threeProng => threeProng.circle ? threeProng.circle.center : [0, 0]);
142
+ const circle = threeProng.circle;
143
+ //const g = threeProng.generated.g;
144
+ console.log(threeProng);
145
+ const circle2 = {
146
+ center: circle.center,
147
+ radius: circle.radius || 1
148
+ };
149
+ //const draw = _debug_.fs.draw;
150
+ drawFs.circle(g, circle2, 'blue thin10 nofill', showDelay);
151
+ drawFs.crossHair(g, circle.center, 'red thin2 nofill', 2, showDelay);
152
+ if (showSpokes) {
153
+ drawFs.line(g, [threeProng.poss[0].p, circle.center], 'blue thin5 nofill', showDelay);
154
+ drawFs.line(g, [threeProng.poss[1].p, circle.center], 'blue thin5 nofill', showDelay);
155
+ drawFs.line(g, [threeProng.poss[2].p, circle.center], 'blue thin5 nofill', showDelay);
156
+ }
157
+ if (showBoundaries) {
158
+ const boundaries = threeProng.boundaries;
159
+ const boundaryS = boundaries[0];
160
+ const boundaryE = boundaries[boundaries.length - 1];
161
+ drawFs.beziers(g, boundaryS, 'red thin20 nofill', showDelay);
162
+ for (let i = 1; i < boundaries.length - 1; i++) {
163
+ const boundary = boundaries[i];
164
+ drawFs.beziers(g, boundary, 'green thin20 nofill', showDelay);
165
+ }
166
+ drawFs.beziers(g, boundaryE, 'blue thin20 nofill', showDelay);
167
+ }
168
+ if (showTrace) {
169
+ const traces = threeProng.traces;
170
+ for (const trace of traces) {
171
+ drawFs.polyline(g, trace, 'red thin5 nofill', showDelay);
172
+ }
173
+ }
174
+ };
175
+ }
176
+ /** @hidden */
177
+ const threeProngDebugFunctions = {
178
+ drawSpokes,
179
+ traceConvergence,
180
+ showBoundary,
181
+ logδs,
182
+ logNearest
183
+ };
184
+ export { threeProngDebugFunctions };
185
185
  //# sourceMappingURL=three-prong.js.map
@@ -1,13 +1,13 @@
1
- import { ElemType_TwoProng } from '../../mat/elem-type-two-prong.js';
2
- /** @hidden */
3
- interface ITwoProngDebugFunctions {
4
- logδ: (n: number, type?: ElemType_TwoProng) => void;
5
- log: (n: number, type?: ElemType_TwoProng) => void;
6
- drawNormal: (g: SVGGElement, n: number, showDelay?: number) => void;
7
- logδBasic: (n: number) => void;
8
- logNearest: (g: SVGGElement, p: number[], showDelay?: number) => void;
9
- traceConvergence: (g: SVGGElement, n: number, finalOnly?: boolean, showDelay?: number, range?: number[], type?: ElemType_TwoProng) => void;
10
- }
11
- /** @hidden */
12
- declare const twoProngDebugFunctions: ITwoProngDebugFunctions;
13
- export { ITwoProngDebugFunctions, twoProngDebugFunctions };
1
+ import { ElemType_TwoProng } from '../../mat/elem-type-two-prong.js';
2
+ /** @hidden */
3
+ interface ITwoProngDebugFunctions {
4
+ logδ: (n: number, type?: ElemType_TwoProng) => void;
5
+ log: (n: number, type?: ElemType_TwoProng) => void;
6
+ drawNormal: (g: SVGGElement, n: number, showDelay?: number) => void;
7
+ logδBasic: (n: number) => void;
8
+ logNearest: (g: SVGGElement, p: number[], showDelay?: number) => void;
9
+ traceConvergence: (g: SVGGElement, n: number, finalOnly?: boolean, showDelay?: number, range?: number[], type?: ElemType_TwoProng) => void;
10
+ }
11
+ /** @hidden */
12
+ declare const twoProngDebugFunctions: ITwoProngDebugFunctions;
13
+ export { ITwoProngDebugFunctions, twoProngDebugFunctions };
@@ -1,118 +1,118 @@
1
- import { drawFs } from 'flo-draw';
2
- import { getObjClosestTo, distanceBetween, squaredDistanceBetween } from 'flo-vector2d';
3
- /**
4
- * @hidden
5
- */
6
- function logδ(n, type = 'twoProng_regular') {
7
- const δ = _debug_.generated.elems[type][n].δ;
8
- console.log(δ);
9
- }
10
- /**
11
- * @hidden
12
- */
13
- function log(n, type = 'twoProng_regular') {
14
- const twoProng = _debug_.generated.elems[type][n];
15
- console.log(twoProng);
16
- }
17
- /**
18
- * @hidden
19
- */
20
- function drawNormal(g, n, showDelay = 1000, type = 'twoProng_regular') {
21
- const twoProngs = _debug_.generated.elems[type];
22
- // If not specified which, draw all
23
- if (n === undefined) {
24
- for (let i = 0; i < twoProngs.length; i++) {
25
- drawNormal(g, i);
26
- }
27
- }
28
- const twoProng = twoProngs[n];
29
- //let g = twoProng.generated.g;
30
- if (!twoProng) {
31
- return;
32
- }
33
- drawFs.line(g, [twoProng.pos.p, twoProng.circle.center], 'thin10 blue', showDelay);
34
- }
35
- /**
36
- * @hidden
37
- */
38
- function logδBasic(n, type = 'twoProng_regular') {
39
- const delta = _debug_.generated.elems[type][n].δ;
40
- function f(x) {
41
- const pos = x.cp.pointOnShape;
42
- return {
43
- bez: pos.curve.ps,
44
- t: pos.t
45
- };
46
- }
47
- console.log(f(delta[0]));
48
- console.log(f(delta[1]));
49
- }
50
- /**
51
- * @hidden
52
- */
53
- function logNearest(g, p, showDelay = 1000, type = 'twoProng_regular') {
54
- const closestPerLoops = [];
55
- const generated = _debug_.generated;
56
- const twoProng = getObjClosestTo(p, generated.elems[type], twoProng => twoProng.circle.center);
57
- closestPerLoops.push(twoProng);
58
- console.log(twoProng);
59
- let n;
60
- for (let i = 0; i < _debug_.generated.elems[type].length; i++) {
61
- const twoProng_ = _debug_.generated.elems[type][i];
62
- if (twoProng_ === twoProng) {
63
- n = i;
64
- break;
65
- }
66
- }
67
- if (n !== undefined) {
68
- traceConvergence(g, n, true, showDelay);
69
- }
70
- }
71
- /**
72
- * @hidden
73
- * @param n - The 2-prong's zero-based index.
74
- * @param range
75
- */
76
- function traceConvergence(g, n, finalOnly, showDelay = 1000, range = undefined, type = 'twoProng_regular') {
77
- if (n === undefined) {
78
- return;
79
- }
80
- const twoProngInfo = _debug_.generated.elems[type][n];
81
- const xs = twoProngInfo.xs;
82
- //let g = twoProngInfo.generated.g;
83
- console.log(twoProngInfo);
84
- console.log(twoProngInfo.xs.map(x => ({
85
- x: x.x,
86
- y: x.y,
87
- z: x.z,
88
- d: x.z ? squaredDistanceBetween(x.y.p, x.z.p) : 0,
89
- t: x.t,
90
- })));
91
- for (let i = 0; i < xs.length; i++) {
92
- if (range && (i < range[0] || i >= range[1])) {
93
- continue;
94
- }
95
- if (finalOnly && i !== xs.length - 1) {
96
- continue;
97
- }
98
- const x = twoProngInfo.xs[i];
99
- const circle = { center: x.x, radius: distanceBetween(x.x, x.y.p) };
100
- drawFs.crossHair(g, x.x, 'red thin10 nofill', undefined, showDelay);
101
- drawFs.circle(g, circle, 'blue thin10 nofill', showDelay);
102
- if (x.z !== undefined) {
103
- drawFs.crossHair(g, x.z.p, 'yellow thin10 nofill', 2, showDelay);
104
- }
105
- }
106
- twoProngDebugFunctions.drawNormal(g, n, showDelay);
107
- }
108
- /** @hidden */
109
- const twoProngDebugFunctions = {
110
- logδ,
111
- log,
112
- drawNormal,
113
- logδBasic,
114
- traceConvergence,
115
- logNearest,
116
- };
117
- export { twoProngDebugFunctions };
1
+ import { drawFs } from 'flo-draw';
2
+ import { getObjClosestTo, distanceBetween, squaredDistanceBetween } from 'flo-vector2d';
3
+ /**
4
+ * @hidden
5
+ */
6
+ function logδ(n, type = 'twoProng_regular') {
7
+ const δ = _debug_.generated.elems[type][n].δ;
8
+ console.log(δ);
9
+ }
10
+ /**
11
+ * @hidden
12
+ */
13
+ function log(n, type = 'twoProng_regular') {
14
+ const twoProng = _debug_.generated.elems[type][n];
15
+ console.log(twoProng);
16
+ }
17
+ /**
18
+ * @hidden
19
+ */
20
+ function drawNormal(g, n, showDelay = 1000, type = 'twoProng_regular') {
21
+ const twoProngs = _debug_.generated.elems[type];
22
+ // If not specified which, draw all
23
+ if (n === undefined) {
24
+ for (let i = 0; i < twoProngs.length; i++) {
25
+ drawNormal(g, i);
26
+ }
27
+ }
28
+ const twoProng = twoProngs[n];
29
+ //let g = twoProng.generated.g;
30
+ if (!twoProng) {
31
+ return;
32
+ }
33
+ drawFs.line(g, [twoProng.pos.p, twoProng.circle.center], 'thin10 blue', showDelay);
34
+ }
35
+ /**
36
+ * @hidden
37
+ */
38
+ function logδBasic(n, type = 'twoProng_regular') {
39
+ const delta = _debug_.generated.elems[type][n].δ;
40
+ function f(x) {
41
+ const pos = x.cp.pointOnShape;
42
+ return {
43
+ bez: pos.curve.ps,
44
+ t: pos.t
45
+ };
46
+ }
47
+ console.log(f(delta[0]));
48
+ console.log(f(delta[1]));
49
+ }
50
+ /**
51
+ * @hidden
52
+ */
53
+ function logNearest(g, p, showDelay = 1000, type = 'twoProng_regular') {
54
+ const closestPerLoops = [];
55
+ const generated = _debug_.generated;
56
+ const twoProng = getObjClosestTo(p, generated.elems[type], twoProng => twoProng.circle.center);
57
+ closestPerLoops.push(twoProng);
58
+ console.log(twoProng);
59
+ let n;
60
+ for (let i = 0; i < _debug_.generated.elems[type].length; i++) {
61
+ const twoProng_ = _debug_.generated.elems[type][i];
62
+ if (twoProng_ === twoProng) {
63
+ n = i;
64
+ break;
65
+ }
66
+ }
67
+ if (n !== undefined) {
68
+ traceConvergence(g, n, true, showDelay);
69
+ }
70
+ }
71
+ /**
72
+ * @hidden
73
+ * @param n - The 2-prong's zero-based index.
74
+ * @param range
75
+ */
76
+ function traceConvergence(g, n, finalOnly, showDelay = 1000, range = undefined, type = 'twoProng_regular') {
77
+ if (n === undefined) {
78
+ return;
79
+ }
80
+ const twoProngInfo = _debug_.generated.elems[type][n];
81
+ const xs = twoProngInfo.xs;
82
+ //let g = twoProngInfo.generated.g;
83
+ console.log(twoProngInfo);
84
+ console.log(twoProngInfo.xs.map(x => ({
85
+ x: x.x,
86
+ y: x.y,
87
+ z: x.z,
88
+ d: x.z ? squaredDistanceBetween(x.y.p, x.z.p) : 0,
89
+ t: x.t,
90
+ })));
91
+ for (let i = 0; i < xs.length; i++) {
92
+ if (range && (i < range[0] || i >= range[1])) {
93
+ continue;
94
+ }
95
+ if (finalOnly && i !== xs.length - 1) {
96
+ continue;
97
+ }
98
+ const x = twoProngInfo.xs[i];
99
+ const circle = { center: x.x, radius: distanceBetween(x.x, x.y.p) };
100
+ drawFs.crossHair(g, x.x, 'red thin10 nofill', undefined, showDelay);
101
+ drawFs.circle(g, circle, 'blue thin10 nofill', showDelay);
102
+ if (x.z !== undefined) {
103
+ drawFs.crossHair(g, x.z.p, 'yellow thin10 nofill', 2, showDelay);
104
+ }
105
+ }
106
+ twoProngDebugFunctions.drawNormal(g, n, showDelay);
107
+ }
108
+ /** @hidden */
109
+ const twoProngDebugFunctions = {
110
+ logδ,
111
+ log,
112
+ drawNormal,
113
+ logδBasic,
114
+ traceConvergence,
115
+ logNearest,
116
+ };
117
+ export { twoProngDebugFunctions };
118
118
  //# sourceMappingURL=two-prong.js.map