@jscad/modeling 2.11.1 → 3.0.0-alpha.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 (1193) hide show
  1. package/CHANGELOG.md +39 -267
  2. package/README.md +5 -3
  3. package/dist/jscad-modeling.es.js +7 -0
  4. package/dist/jscad-modeling.min.js +7 -1205
  5. package/global.d.ts +15 -0
  6. package/package.json +22 -19
  7. package/rollup.config.js +21 -0
  8. package/src/colors/colorNameToRgb.d.ts +2 -4
  9. package/src/colors/colorNameToRgb.js +4 -6
  10. package/src/colors/colorNameToRgb.test.js +2 -2
  11. package/src/colors/colorize.d.ts +6 -8
  12. package/src/colors/colorize.js +20 -22
  13. package/src/colors/colorize.test.js +6 -8
  14. package/src/colors/cssColors.d.ts +1 -1
  15. package/src/colors/cssColors.js +2 -4
  16. package/src/colors/hexToRgb.d.ts +2 -4
  17. package/src/colors/hexToRgb.js +3 -5
  18. package/src/colors/hexToRgb.test.js +2 -2
  19. package/src/colors/hslToRgb.d.ts +5 -7
  20. package/src/colors/hslToRgb.js +4 -6
  21. package/src/colors/hslToRgb.test.js +2 -2
  22. package/src/colors/hsvToRgb.d.ts +5 -7
  23. package/src/colors/hsvToRgb.js +3 -5
  24. package/src/colors/hsvToRgb.test.js +2 -2
  25. package/src/colors/hueToColorComponent.d.ts +1 -3
  26. package/src/colors/hueToColorComponent.js +2 -4
  27. package/src/colors/index.d.ts +11 -12
  28. package/src/colors/index.js +12 -13
  29. package/src/colors/rgbToHex.d.ts +3 -5
  30. package/src/colors/rgbToHex.js +2 -4
  31. package/src/colors/rgbToHex.test.js +2 -2
  32. package/src/colors/rgbToHsl.d.ts +5 -7
  33. package/src/colors/rgbToHsl.js +2 -4
  34. package/src/colors/rgbToHsl.test.js +2 -2
  35. package/src/colors/rgbToHsv.d.ts +5 -7
  36. package/src/colors/rgbToHsv.js +2 -4
  37. package/src/colors/rgbToHsv.test.js +2 -2
  38. package/src/connectors/create.js +3 -5
  39. package/src/connectors/create.test.js +3 -3
  40. package/src/connectors/extends.js +7 -8
  41. package/src/connectors/fromPointAxisNormal.js +6 -8
  42. package/src/connectors/fromPointAxisNormal.test.js +3 -3
  43. package/src/connectors/index.js +7 -9
  44. package/src/connectors/normalize.js +7 -9
  45. package/src/connectors/toString.js +1 -3
  46. package/src/connectors/transform.js +10 -12
  47. package/src/connectors/transform.test.js +3 -3
  48. package/src/connectors/transformationBetween.js +25 -27
  49. package/src/connectors/transformationBetween.test.js +13 -13
  50. package/src/curves/bezier/arcLengthToT.d.ts +2 -4
  51. package/src/curves/bezier/arcLengthToT.js +11 -13
  52. package/src/curves/bezier/arcLengthToT.test.js +38 -38
  53. package/src/curves/bezier/create.d.ts +2 -4
  54. package/src/curves/bezier/create.js +3 -5
  55. package/src/curves/bezier/create.test.js +2 -2
  56. package/src/curves/bezier/index.d.ts +7 -8
  57. package/src/curves/bezier/index.js +9 -8
  58. package/src/curves/bezier/length.d.ts +2 -4
  59. package/src/curves/bezier/length.js +5 -9
  60. package/src/curves/bezier/length.test.js +14 -14
  61. package/src/curves/bezier/lengths.d.ts +2 -4
  62. package/src/curves/bezier/lengths.js +13 -15
  63. package/src/curves/bezier/lengths.test.js +15 -15
  64. package/src/curves/bezier/tangentAt.d.ts +2 -4
  65. package/src/curves/bezier/tangentAt.js +2 -4
  66. package/src/curves/bezier/tangentAt.test.js +2 -2
  67. package/src/curves/bezier/type.d.ts +1 -3
  68. package/src/curves/bezier/valueAt.d.ts +2 -4
  69. package/src/curves/bezier/valueAt.js +2 -4
  70. package/src/curves/bezier/valueAt.test.js +2 -2
  71. package/src/curves/index.d.ts +1 -3
  72. package/src/curves/index.js +4 -6
  73. package/src/geometries/geom2/applyTransforms.js +7 -13
  74. package/src/geometries/geom2/applyTransforms.test.js +6 -6
  75. package/src/geometries/geom2/clone.d.ts +2 -4
  76. package/src/geometries/geom2/clone.js +3 -5
  77. package/src/geometries/geom2/clone.test.js +5 -5
  78. package/src/geometries/geom2/create.d.ts +3 -5
  79. package/src/geometries/geom2/create.js +19 -19
  80. package/src/geometries/geom2/create.test.js +6 -6
  81. package/src/geometries/geom2/fromCompactBinary.d.ts +2 -4
  82. package/src/geometries/geom2/fromCompactBinary.js +19 -11
  83. package/src/geometries/geom2/fromSides.d.ts +4 -0
  84. package/src/geometries/geom2/fromSides.js +115 -0
  85. package/src/geometries/geom2/fromToCompactBinary.test.js +16 -38
  86. package/src/geometries/geom2/index.d.ts +14 -15
  87. package/src/geometries/geom2/index.js +17 -24
  88. package/src/geometries/geom2/isA.d.ts +2 -4
  89. package/src/geometries/geom2/isA.js +4 -6
  90. package/src/geometries/geom2/isA.test.js +5 -3
  91. package/src/geometries/geom2/reverse.d.ts +2 -4
  92. package/src/geometries/geom2/reverse.js +12 -14
  93. package/src/geometries/geom2/reverse.test.js +29 -9
  94. package/src/geometries/geom2/toCompactBinary.d.ts +2 -4
  95. package/src/geometries/geom2/toCompactBinary.js +18 -15
  96. package/src/geometries/geom2/toOutlines.d.ts +3 -5
  97. package/src/geometries/geom2/toOutlines.js +3 -109
  98. package/src/geometries/geom2/toOutlines.test.js +34 -61
  99. package/src/geometries/geom2/toPoints.d.ts +3 -5
  100. package/src/geometries/geom2/toPoints.js +10 -13
  101. package/src/geometries/geom2/toPoints.test.js +8 -8
  102. package/src/geometries/geom2/toSides.d.ts +3 -5
  103. package/src/geometries/geom2/toSides.js +13 -6
  104. package/src/geometries/geom2/toString.d.ts +2 -4
  105. package/src/geometries/geom2/toString.js +9 -11
  106. package/src/geometries/geom2/toString.test.js +17 -0
  107. package/src/geometries/geom2/transform.d.ts +3 -5
  108. package/src/geometries/geom2/transform.js +8 -10
  109. package/src/geometries/geom2/transform.test.js +21 -22
  110. package/src/geometries/geom2/type.d.ts +5 -7
  111. package/src/geometries/geom2/validate.d.ts +1 -3
  112. package/src/geometries/geom2/validate.js +34 -13
  113. package/src/geometries/geom2/validate.test.js +39 -0
  114. package/src/geometries/geom3/applyTransforms.js +5 -7
  115. package/src/geometries/geom3/applyTransforms.test.js +6 -6
  116. package/src/geometries/geom3/clone.d.ts +2 -4
  117. package/src/geometries/geom3/clone.js +3 -5
  118. package/src/geometries/geom3/clone.test.js +5 -5
  119. package/src/geometries/geom3/create.d.ts +3 -5
  120. package/src/geometries/geom3/create.js +17 -8
  121. package/src/geometries/geom3/create.test.js +5 -5
  122. package/src/geometries/geom3/fromCompactBinary.d.ts +2 -4
  123. package/src/geometries/geom3/fromCompactBinary.js +6 -8
  124. package/src/geometries/geom3/fromPoints.d.ts +3 -5
  125. package/src/geometries/geom3/fromPoints.js +11 -19
  126. package/src/geometries/geom3/fromPoints.test.js +6 -6
  127. package/src/geometries/geom3/fromToCompactBinary.test.js +7 -7
  128. package/src/geometries/geom3/index.d.ts +13 -14
  129. package/src/geometries/geom3/index.js +21 -29
  130. package/src/geometries/geom3/invert.d.ts +2 -4
  131. package/src/geometries/geom3/invert.js +8 -10
  132. package/src/geometries/geom3/invert.test.js +5 -5
  133. package/src/geometries/geom3/isA.d.ts +2 -4
  134. package/src/geometries/geom3/isA.js +2 -4
  135. package/src/geometries/geom3/isA.test.js +2 -2
  136. package/src/geometries/geom3/toCompactBinary.d.ts +2 -4
  137. package/src/geometries/geom3/toCompactBinary.js +10 -12
  138. package/src/geometries/geom3/toPoints.d.ts +3 -5
  139. package/src/geometries/geom3/toPoints.js +5 -8
  140. package/src/geometries/geom3/toPoints.test.js +9 -9
  141. package/src/geometries/geom3/toPolygons.d.ts +3 -5
  142. package/src/geometries/geom3/toPolygons.js +4 -6
  143. package/src/geometries/geom3/toString.d.ts +2 -4
  144. package/src/geometries/geom3/toString.js +5 -7
  145. package/src/geometries/geom3/toString.test.js +17 -0
  146. package/src/geometries/geom3/transform.d.ts +3 -5
  147. package/src/geometries/geom3/transform.js +6 -8
  148. package/src/geometries/geom3/transform.test.js +6 -6
  149. package/src/geometries/geom3/type.d.ts +4 -6
  150. package/src/geometries/geom3/validate.d.ts +1 -3
  151. package/src/geometries/geom3/validate.js +5 -6
  152. package/src/geometries/geom3/validate.test.js +26 -0
  153. package/src/geometries/index.d.ts +6 -7
  154. package/src/geometries/index.js +10 -9
  155. package/src/geometries/path2/appendArc.d.ts +4 -6
  156. package/src/geometries/path2/appendArc.js +58 -60
  157. package/src/geometries/path2/appendArc.test.js +8 -7
  158. package/src/geometries/path2/appendBezier.d.ts +3 -5
  159. package/src/geometries/path2/appendBezier.js +41 -43
  160. package/src/geometries/path2/appendBezier.test.js +3 -3
  161. package/src/geometries/path2/appendPoints.d.ts +3 -5
  162. package/src/geometries/path2/appendPoints.js +6 -8
  163. package/src/geometries/path2/appendPoints.test.js +2 -2
  164. package/src/geometries/path2/applyTransforms.js +3 -5
  165. package/src/geometries/path2/applyTransforms.test.js +4 -4
  166. package/src/geometries/path2/clone.d.ts +2 -4
  167. package/src/geometries/path2/clone.js +3 -5
  168. package/src/geometries/path2/close.d.ts +2 -4
  169. package/src/geometries/path2/close.js +6 -8
  170. package/src/geometries/path2/close.test.js +2 -2
  171. package/src/geometries/path2/concat.d.ts +2 -4
  172. package/src/geometries/path2/concat.js +11 -13
  173. package/src/geometries/path2/concat.test.js +2 -2
  174. package/src/geometries/path2/create.d.ts +3 -5
  175. package/src/geometries/path2/create.js +12 -9
  176. package/src/geometries/path2/create.test.js +2 -2
  177. package/src/geometries/path2/equals.d.ts +2 -4
  178. package/src/geometries/path2/equals.js +9 -11
  179. package/src/geometries/path2/equals.test.js +2 -2
  180. package/src/geometries/path2/fromCompactBinary.d.ts +2 -4
  181. package/src/geometries/path2/fromCompactBinary.js +5 -7
  182. package/src/geometries/path2/fromPoints.d.ts +3 -5
  183. package/src/geometries/path2/fromPoints.js +9 -11
  184. package/src/geometries/path2/fromPoints.test.js +3 -3
  185. package/src/geometries/path2/fromToCompactBinary.test.js +2 -2
  186. package/src/geometries/path2/index.d.ts +18 -19
  187. package/src/geometries/path2/index.js +19 -28
  188. package/src/geometries/path2/isA.d.ts +2 -4
  189. package/src/geometries/path2/isA.js +2 -4
  190. package/src/geometries/path2/isA.test.js +2 -2
  191. package/src/geometries/path2/reverse.d.ts +2 -4
  192. package/src/geometries/path2/reverse.js +5 -7
  193. package/src/geometries/path2/reverse.test.js +2 -2
  194. package/src/geometries/path2/toCompactBinary.d.ts +2 -4
  195. package/src/geometries/path2/toCompactBinary.js +2 -4
  196. package/src/geometries/path2/toPoints.d.ts +3 -5
  197. package/src/geometries/path2/toPoints.js +4 -6
  198. package/src/geometries/path2/toPoints.test.js +3 -3
  199. package/src/geometries/path2/toString.d.ts +2 -4
  200. package/src/geometries/path2/toString.js +5 -7
  201. package/src/geometries/path2/transform.d.ts +3 -5
  202. package/src/geometries/path2/transform.js +6 -8
  203. package/src/geometries/path2/transform.test.js +5 -5
  204. package/src/geometries/path2/type.d.ts +4 -6
  205. package/src/geometries/path2/validate.d.ts +1 -3
  206. package/src/geometries/path2/validate.js +6 -7
  207. package/src/geometries/poly2/arePointsInside.d.ts +3 -5
  208. package/src/geometries/poly2/arePointsInside.js +21 -31
  209. package/src/geometries/poly2/arePointsInside.test.js +2 -2
  210. package/src/geometries/poly2/clone.d.ts +3 -0
  211. package/src/geometries/poly2/clone.js +8 -0
  212. package/src/geometries/poly2/clone.test.js +17 -0
  213. package/src/geometries/poly2/create.d.ts +3 -5
  214. package/src/geometries/poly2/create.js +11 -12
  215. package/src/geometries/poly2/create.test.js +4 -4
  216. package/src/geometries/poly2/index.d.ts +14 -6
  217. package/src/geometries/poly2/index.js +16 -11
  218. package/src/geometries/poly2/isA.d.ts +3 -0
  219. package/src/geometries/poly2/isA.js +16 -0
  220. package/src/geometries/poly2/isA.test.js +30 -0
  221. package/src/geometries/poly2/isConvex.d.ts +3 -0
  222. package/src/geometries/poly2/isConvex.js +37 -0
  223. package/src/geometries/poly2/isConvex.test.js +27 -0
  224. package/src/geometries/poly2/isSimple.d.ts +3 -0
  225. package/src/geometries/poly2/isSimple.js +38 -0
  226. package/src/geometries/poly2/isSimple.test.js +31 -0
  227. package/src/geometries/poly2/measureArea.d.ts +2 -4
  228. package/src/geometries/poly2/measureArea.js +5 -7
  229. package/src/geometries/poly2/measureArea.test.js +2 -2
  230. package/src/geometries/poly2/measureBoundingBox.d.ts +4 -0
  231. package/src/geometries/poly2/measureBoundingBox.js +18 -0
  232. package/src/geometries/poly2/measureBoundingBox.test.js +71 -0
  233. package/src/geometries/poly2/reverse.d.ts +3 -0
  234. package/src/geometries/poly2/reverse.js +13 -0
  235. package/src/geometries/poly2/reverse.test.js +27 -0
  236. package/src/geometries/poly2/toPoints.d.ts +4 -0
  237. package/src/geometries/poly2/toPoints.js +8 -0
  238. package/src/geometries/poly2/toPoints.test.js +18 -0
  239. package/src/geometries/poly2/toString.d.ts +3 -0
  240. package/src/geometries/poly2/toString.js +9 -0
  241. package/src/geometries/poly2/toString.test.js +10 -0
  242. package/src/geometries/poly2/transform.d.ts +4 -0
  243. package/src/geometries/poly2/transform.js +20 -0
  244. package/src/geometries/poly2/transform.test.js +62 -0
  245. package/src/geometries/poly2/type.d.ts +5 -5
  246. package/src/geometries/poly2/validate.d.ts +2 -0
  247. package/src/geometries/poly2/validate.js +46 -0
  248. package/src/geometries/poly2/validate.test.js +31 -0
  249. package/src/geometries/poly3/clone.d.ts +3 -5
  250. package/src/geometries/poly3/clone.js +6 -8
  251. package/src/geometries/poly3/clone.test.js +6 -5
  252. package/src/geometries/poly3/create.d.ts +3 -5
  253. package/src/geometries/poly3/create.js +6 -6
  254. package/src/geometries/poly3/create.test.js +15 -3
  255. package/src/geometries/poly3/fromVerticesAndPlane.d.ts +5 -0
  256. package/src/geometries/poly3/{fromPointsAndPlane.js → fromVerticesAndPlane.js} +5 -7
  257. package/src/geometries/poly3/index.d.ts +16 -18
  258. package/src/geometries/poly3/index.js +17 -22
  259. package/src/geometries/poly3/invert.d.ts +2 -4
  260. package/src/geometries/poly3/invert.js +6 -7
  261. package/src/geometries/poly3/invert.test.js +5 -5
  262. package/src/geometries/poly3/isA.d.ts +2 -4
  263. package/src/geometries/poly3/isA.js +2 -4
  264. package/src/geometries/poly3/isA.test.js +3 -3
  265. package/src/geometries/poly3/isConvex.d.ts +2 -4
  266. package/src/geometries/poly3/isConvex.js +21 -23
  267. package/src/geometries/poly3/isConvex.test.js +9 -9
  268. package/src/geometries/poly3/measureArea.d.ts +2 -4
  269. package/src/geometries/poly3/measureArea.js +4 -6
  270. package/src/geometries/poly3/measureArea.test.js +12 -11
  271. package/src/geometries/poly3/measureBoundingBox.d.ts +3 -5
  272. package/src/geometries/poly3/measureBoundingBox.js +6 -8
  273. package/src/geometries/poly3/measureBoundingBox.test.js +9 -8
  274. package/src/geometries/poly3/measureBoundingSphere.d.ts +3 -5
  275. package/src/geometries/poly3/measureBoundingSphere.js +5 -8
  276. package/src/geometries/poly3/measureBoundingSphere.test.js +8 -7
  277. package/src/geometries/poly3/measureSignedVolume.d.ts +2 -4
  278. package/src/geometries/poly3/measureSignedVolume.js +4 -6
  279. package/src/geometries/poly3/measureSignedVolume.test.js +8 -8
  280. package/src/geometries/poly3/plane.d.ts +3 -5
  281. package/src/geometries/poly3/plane.js +2 -4
  282. package/src/geometries/poly3/toString.d.ts +2 -4
  283. package/src/geometries/poly3/toString.js +4 -12
  284. package/src/geometries/poly3/toString.test.js +10 -0
  285. package/src/geometries/poly3/toVertices.d.ts +4 -0
  286. package/src/geometries/poly3/toVertices.js +8 -0
  287. package/src/geometries/poly3/transform.d.ts +3 -5
  288. package/src/geometries/poly3/transform.js +7 -9
  289. package/src/geometries/poly3/transform.test.js +7 -7
  290. package/src/geometries/poly3/type.d.ts +7 -5
  291. package/src/geometries/poly3/validate.d.ts +1 -3
  292. package/src/geometries/poly3/validate.js +14 -15
  293. package/src/geometries/slice/calculatePlane.d.ts +5 -0
  294. package/src/geometries/slice/calculatePlane.js +65 -0
  295. package/src/geometries/slice/calculatePlane.test.js +43 -0
  296. package/src/geometries/slice/clone.d.ts +3 -0
  297. package/src/geometries/slice/clone.js +9 -0
  298. package/src/geometries/slice/clone.test.js +14 -0
  299. package/src/geometries/slice/create.d.ts +4 -0
  300. package/src/geometries/slice/create.js +18 -0
  301. package/src/{operations/extrusions → geometries}/slice/create.test.js +3 -3
  302. package/src/{operations/extrusions → geometries/slice}/earcut/assignHoles.js +6 -8
  303. package/src/geometries/slice/earcut/assignHoles.test.js +75 -0
  304. package/src/{operations/extrusions → geometries/slice}/earcut/eliminateHoles.js +3 -5
  305. package/src/{operations/extrusions → geometries/slice}/earcut/index.js +7 -8
  306. package/src/{operations/extrusions → geometries/slice}/earcut/linkedList.js +3 -6
  307. package/src/{operations/extrusions → geometries/slice}/earcut/linkedListSort.js +1 -4
  308. package/src/{operations/extrusions → geometries/slice}/earcut/linkedPolygon.js +8 -10
  309. package/src/{operations/extrusions → geometries/slice}/earcut/polygonHierarchy.js +13 -13
  310. package/src/{operations/extrusions → geometries/slice}/earcut/triangle.js +2 -5
  311. package/src/geometries/slice/equals.d.ts +3 -0
  312. package/src/geometries/slice/equals.js +27 -0
  313. package/src/geometries/slice/equals.test.js +17 -0
  314. package/src/geometries/slice/fromGeom2.d.ts +5 -0
  315. package/src/geometries/slice/fromGeom2.js +17 -0
  316. package/src/geometries/slice/fromVertices.d.ts +7 -0
  317. package/src/geometries/slice/fromVertices.js +34 -0
  318. package/src/geometries/slice/fromVertices.test.js +11 -0
  319. package/src/geometries/slice/index.d.ts +16 -0
  320. package/src/geometries/slice/index.js +23 -0
  321. package/src/geometries/slice/isA.d.ts +3 -0
  322. package/src/geometries/slice/isA.js +16 -0
  323. package/src/{operations/extrusions → geometries}/slice/isA.test.js +3 -3
  324. package/src/geometries/slice/reverse.d.ts +3 -0
  325. package/src/geometries/slice/reverse.js +14 -0
  326. package/src/geometries/slice/toEdges.d.ts +3 -0
  327. package/src/geometries/slice/toEdges.js +20 -0
  328. package/src/geometries/slice/toPolygons.d.ts +5 -0
  329. package/src/{operations/extrusions → geometries}/slice/toPolygons.js +9 -10
  330. package/src/geometries/slice/toString.d.ts +3 -0
  331. package/src/geometries/slice/toString.js +16 -0
  332. package/src/geometries/slice/toString.test.js +17 -0
  333. package/src/geometries/slice/toVertices.d.ts +4 -0
  334. package/src/geometries/slice/toVertices.js +19 -0
  335. package/src/geometries/slice/transform.d.ts +5 -0
  336. package/src/geometries/slice/transform.js +19 -0
  337. package/src/{operations/extrusions → geometries}/slice/transform.test.js +11 -21
  338. package/src/geometries/slice/type.d.ts +7 -0
  339. package/src/geometries/slice/validate.d.ts +1 -0
  340. package/src/geometries/slice/validate.js +49 -0
  341. package/src/geometries/slice/validate.test.js +36 -0
  342. package/src/geometries/types.d.ts +12 -10
  343. package/src/index.d.ts +2 -4
  344. package/src/index.js +14 -16
  345. package/src/index.test-d.ts +3 -3
  346. package/src/maths/constants.d.ts +1 -1
  347. package/src/maths/constants.js +10 -20
  348. package/src/maths/index.d.ts +9 -11
  349. package/src/maths/index.js +10 -13
  350. package/src/maths/line2/clone.d.ts +2 -4
  351. package/src/maths/line2/clone.js +4 -6
  352. package/src/maths/line2/clone.test.js +4 -3
  353. package/src/maths/line2/closestPoint.d.ts +3 -5
  354. package/src/maths/line2/closestPoint.js +7 -9
  355. package/src/maths/line2/closestPoint.test.js +4 -3
  356. package/src/maths/line2/copy.d.ts +2 -4
  357. package/src/maths/line2/copy.js +4 -6
  358. package/src/maths/line2/copy.test.js +4 -3
  359. package/src/maths/line2/create.d.ts +2 -4
  360. package/src/maths/line2/create.js +5 -8
  361. package/src/maths/line2/create.test.js +3 -3
  362. package/src/maths/line2/direction.d.ts +3 -5
  363. package/src/maths/line2/direction.js +4 -6
  364. package/src/maths/line2/direction.test.js +3 -3
  365. package/src/maths/line2/distanceToPoint.d.ts +3 -5
  366. package/src/maths/line2/distanceToPoint.js +5 -7
  367. package/src/maths/line2/distanceToPoint.test.js +6 -4
  368. package/src/maths/line2/equals.d.ts +2 -4
  369. package/src/maths/line2/equals.js +4 -6
  370. package/src/maths/line2/equals.test.js +3 -2
  371. package/src/maths/line2/fromPoints.d.ts +3 -5
  372. package/src/maths/line2/fromPoints.js +6 -8
  373. package/src/maths/line2/fromPoints.test.js +4 -3
  374. package/src/maths/line2/fromValues.d.ts +2 -4
  375. package/src/maths/line2/fromValues.js +6 -8
  376. package/src/maths/line2/fromValues.test.js +4 -3
  377. package/src/maths/line2/index.d.ts +16 -17
  378. package/src/maths/line2/index.js +16 -18
  379. package/src/maths/line2/intersectPointOfLines.d.ts +3 -5
  380. package/src/maths/line2/intersectPointOfLines.js +7 -8
  381. package/src/maths/line2/intersectPointOfLines.test.js +4 -3
  382. package/src/maths/line2/origin.d.ts +3 -5
  383. package/src/maths/line2/origin.js +4 -6
  384. package/src/maths/line2/origin.test.js +4 -3
  385. package/src/maths/line2/reverse.d.ts +2 -4
  386. package/src/maths/line2/reverse.js +7 -9
  387. package/src/maths/line2/reverse.test.js +4 -3
  388. package/src/maths/line2/toString.d.ts +2 -4
  389. package/src/maths/line2/toString.js +3 -5
  390. package/src/maths/line2/transform.d.ts +3 -5
  391. package/src/maths/line2/transform.js +9 -11
  392. package/src/maths/line2/transform.test.js +4 -3
  393. package/src/maths/line2/type.d.ts +1 -3
  394. package/src/maths/line2/xAtY.d.ts +2 -4
  395. package/src/maths/line2/xAtY.js +5 -7
  396. package/src/maths/line2/xAtY.test.js +6 -4
  397. package/src/maths/line3/clone.d.ts +2 -4
  398. package/src/maths/line3/clone.js +5 -7
  399. package/src/maths/line3/clone.test.js +4 -3
  400. package/src/maths/line3/closestPoint.d.ts +3 -5
  401. package/src/maths/line3/closestPoint.js +12 -14
  402. package/src/maths/line3/closestPoint.test.js +4 -3
  403. package/src/maths/line3/copy.d.ts +2 -4
  404. package/src/maths/line3/copy.js +5 -7
  405. package/src/maths/line3/copy.test.js +4 -3
  406. package/src/maths/line3/create.d.ts +2 -4
  407. package/src/maths/line3/create.js +4 -7
  408. package/src/maths/line3/create.test.js +3 -3
  409. package/src/maths/line3/direction.d.ts +3 -5
  410. package/src/maths/line3/direction.js +3 -5
  411. package/src/maths/line3/direction.test.js +4 -3
  412. package/src/maths/line3/distanceToPoint.d.ts +3 -5
  413. package/src/maths/line3/distanceToPoint.js +8 -10
  414. package/src/maths/line3/distanceToPoint.test.js +6 -4
  415. package/src/maths/line3/equals.d.ts +2 -4
  416. package/src/maths/line3/equals.js +4 -6
  417. package/src/maths/line3/equals.test.js +3 -2
  418. package/src/maths/line3/fromPlanes.d.ts +3 -5
  419. package/src/maths/line3/fromPlanes.js +14 -17
  420. package/src/maths/line3/fromPlanes.test.js +4 -4
  421. package/src/maths/line3/fromPointAndDirection.d.ts +3 -5
  422. package/src/maths/line3/fromPointAndDirection.js +6 -8
  423. package/src/maths/line3/fromPointAndDirection.test.js +4 -3
  424. package/src/maths/line3/fromPoints.d.ts +3 -5
  425. package/src/maths/line3/fromPoints.js +7 -9
  426. package/src/maths/line3/fromPoints.test.js +4 -3
  427. package/src/maths/line3/index.d.ts +16 -17
  428. package/src/maths/line3/index.js +16 -18
  429. package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +4 -6
  430. package/src/maths/line3/intersectPointOfLineAndPlane.js +10 -13
  431. package/src/maths/line3/intersectPointOfLineAndPlane.test.js +4 -4
  432. package/src/maths/line3/origin.d.ts +3 -5
  433. package/src/maths/line3/origin.js +3 -5
  434. package/src/maths/line3/origin.test.js +4 -3
  435. package/src/maths/line3/reverse.d.ts +2 -4
  436. package/src/maths/line3/reverse.js +6 -8
  437. package/src/maths/line3/reverse.test.js +4 -3
  438. package/src/maths/line3/toString.d.ts +2 -4
  439. package/src/maths/line3/toString.js +3 -5
  440. package/src/maths/line3/transform.d.ts +3 -5
  441. package/src/maths/line3/transform.js +10 -12
  442. package/src/maths/line3/transform.test.js +4 -3
  443. package/src/maths/line3/type.d.ts +2 -4
  444. package/src/maths/mat4/add.d.ts +2 -4
  445. package/src/maths/mat4/add.js +5 -7
  446. package/src/maths/mat4/add.test.js +4 -3
  447. package/src/maths/mat4/clone.d.ts +2 -4
  448. package/src/maths/mat4/clone.js +4 -6
  449. package/src/maths/mat4/clone.test.js +4 -3
  450. package/src/maths/mat4/copy.d.ts +2 -4
  451. package/src/maths/mat4/copy.js +4 -6
  452. package/src/maths/mat4/copy.test.js +4 -3
  453. package/src/maths/mat4/create.d.ts +2 -4
  454. package/src/maths/mat4/create.js +2 -5
  455. package/src/maths/mat4/create.test.js +3 -3
  456. package/src/maths/mat4/equals.d.ts +2 -4
  457. package/src/maths/mat4/equals.js +4 -6
  458. package/src/maths/mat4/equals.test.js +3 -2
  459. package/src/maths/mat4/fromRotation.d.ts +3 -5
  460. package/src/maths/mat4/fromRotation.js +8 -10
  461. package/src/maths/mat4/fromRotation.test.js +4 -3
  462. package/src/maths/mat4/fromScaling.d.ts +3 -5
  463. package/src/maths/mat4/fromScaling.js +4 -6
  464. package/src/maths/mat4/fromScaling.test.js +4 -3
  465. package/src/maths/mat4/fromTaitBryanRotation.d.ts +2 -4
  466. package/src/maths/mat4/fromTaitBryanRotation.js +7 -9
  467. package/src/maths/mat4/fromTaitBryanRotation.test.js +3 -3
  468. package/src/maths/mat4/fromTranslation.d.ts +3 -5
  469. package/src/maths/mat4/fromTranslation.js +4 -6
  470. package/src/maths/mat4/fromTranslation.test.js +4 -3
  471. package/src/maths/mat4/fromValues.d.ts +2 -4
  472. package/src/maths/mat4/fromValues.js +19 -21
  473. package/src/maths/mat4/fromValues.test.js +4 -3
  474. package/src/maths/mat4/fromVectorRotation.d.ts +3 -5
  475. package/src/maths/mat4/fromVectorRotation.js +8 -10
  476. package/src/maths/mat4/fromVectorRotation.test.js +4 -5
  477. package/src/maths/mat4/fromXRotation.d.ts +2 -4
  478. package/src/maths/mat4/fromXRotation.js +5 -7
  479. package/src/maths/mat4/fromXRotation.test.js +4 -3
  480. package/src/maths/mat4/fromYRotation.d.ts +2 -4
  481. package/src/maths/mat4/fromYRotation.js +5 -7
  482. package/src/maths/mat4/fromYRotation.test.js +4 -3
  483. package/src/maths/mat4/fromZRotation.d.ts +2 -4
  484. package/src/maths/mat4/fromZRotation.js +5 -7
  485. package/src/maths/mat4/fromZRotation.test.js +4 -3
  486. package/src/maths/mat4/identity.d.ts +2 -4
  487. package/src/maths/mat4/identity.js +3 -5
  488. package/src/maths/mat4/identity.test.js +4 -3
  489. package/src/maths/mat4/index.d.ts +30 -27
  490. package/src/maths/mat4/index.js +29 -31
  491. package/src/maths/mat4/invert.d.ts +3 -0
  492. package/src/maths/mat4/invert.js +7 -7
  493. package/src/maths/mat4/invert.test.js +6 -5
  494. package/src/maths/mat4/isIdentity.d.ts +3 -0
  495. package/src/maths/mat4/isIdentity.js +4 -6
  496. package/src/maths/mat4/isIdentity.test.js +2 -2
  497. package/src/maths/mat4/isMirroring.d.ts +2 -4
  498. package/src/maths/mat4/isMirroring.js +4 -6
  499. package/src/maths/mat4/isMirroring.test.js +3 -3
  500. package/src/maths/mat4/isOnlyTransformScale.d.ts +3 -0
  501. package/src/maths/mat4/isOnlyTransformScale.js +7 -5
  502. package/src/maths/mat4/isOnlyTransformScale.test.js +3 -3
  503. package/src/maths/mat4/leftMultiplyVec2.d.ts +3 -5
  504. package/src/maths/mat4/leftMultiplyVec2.js +5 -7
  505. package/src/maths/mat4/leftMultiplyVec3.d.ts +3 -5
  506. package/src/maths/mat4/leftMultiplyVec3.js +5 -7
  507. package/src/maths/mat4/mirror.d.ts +3 -5
  508. package/src/maths/mat4/mirror.js +5 -7
  509. package/src/maths/mat4/mirrorByPlane.d.ts +3 -5
  510. package/src/maths/mat4/mirrorByPlane.js +4 -6
  511. package/src/maths/mat4/mirrorByPlane.test.js +4 -4
  512. package/src/maths/mat4/multiply.d.ts +2 -4
  513. package/src/maths/mat4/multiply.js +5 -7
  514. package/src/maths/mat4/multiply.test.js +4 -3
  515. package/src/maths/mat4/rightMultiplyVec2.d.ts +3 -5
  516. package/src/maths/mat4/rightMultiplyVec2.js +5 -7
  517. package/src/maths/mat4/rightMultiplyVec3.d.ts +3 -5
  518. package/src/maths/mat4/rightMultiplyVec3.js +5 -7
  519. package/src/maths/mat4/rotate.d.ts +3 -5
  520. package/src/maths/mat4/rotate.js +9 -11
  521. package/src/maths/mat4/rotate.test.js +6 -5
  522. package/src/maths/mat4/rotateX.d.ts +2 -4
  523. package/src/maths/mat4/rotateX.js +6 -8
  524. package/src/maths/mat4/rotateX.test.js +4 -3
  525. package/src/maths/mat4/rotateY.d.ts +2 -4
  526. package/src/maths/mat4/rotateY.js +6 -8
  527. package/src/maths/mat4/rotateY.test.js +4 -3
  528. package/src/maths/mat4/rotateZ.d.ts +2 -4
  529. package/src/maths/mat4/rotateZ.js +6 -8
  530. package/src/maths/mat4/rotateZ.test.js +4 -3
  531. package/src/maths/mat4/scale.d.ts +3 -5
  532. package/src/maths/mat4/scale.js +5 -7
  533. package/src/maths/mat4/scale.test.js +4 -3
  534. package/src/maths/mat4/subtract.d.ts +2 -4
  535. package/src/maths/mat4/subtract.js +5 -7
  536. package/src/maths/mat4/subtract.test.js +4 -3
  537. package/src/maths/mat4/toString.d.ts +2 -4
  538. package/src/maths/mat4/toString.js +3 -5
  539. package/src/maths/mat4/translate.d.ts +3 -5
  540. package/src/maths/mat4/translate.js +5 -7
  541. package/src/maths/mat4/translate.test.js +11 -15
  542. package/src/maths/mat4/type.d.ts +1 -3
  543. package/src/maths/plane/clone.d.ts +2 -4
  544. package/src/maths/plane/clone.test.js +4 -3
  545. package/src/maths/plane/copy.d.ts +2 -4
  546. package/src/maths/plane/copy.test.js +4 -3
  547. package/src/maths/plane/create.d.ts +2 -4
  548. package/src/maths/plane/create.test.js +3 -3
  549. package/src/maths/plane/equals.d.ts +2 -4
  550. package/src/maths/plane/equals.test.js +3 -2
  551. package/src/maths/plane/flip.d.ts +2 -4
  552. package/src/maths/plane/flip.js +4 -6
  553. package/src/maths/plane/flip.test.js +4 -3
  554. package/src/maths/plane/fromNormalAndPoint.d.ts +3 -5
  555. package/src/maths/plane/fromNormalAndPoint.js +6 -9
  556. package/src/maths/plane/fromNormalAndPoint.test.js +4 -3
  557. package/src/maths/plane/fromPoints.d.ts +3 -5
  558. package/src/maths/plane/fromPoints.js +4 -6
  559. package/src/maths/plane/fromPoints.test.js +4 -3
  560. package/src/maths/plane/fromPointsRandom.d.ts +3 -5
  561. package/src/maths/plane/fromPointsRandom.js +8 -10
  562. package/src/maths/plane/fromValues.d.ts +2 -4
  563. package/src/maths/plane/index.d.ts +14 -15
  564. package/src/maths/plane/index.js +38 -39
  565. package/src/maths/plane/projectionOfPoint.d.ts +3 -5
  566. package/src/maths/plane/projectionOfPoint.js +5 -7
  567. package/src/maths/plane/projectionOfPoint.test.js +3 -3
  568. package/src/maths/plane/signedDistanceToPoint.d.ts +3 -5
  569. package/src/maths/plane/signedDistanceToPoint.js +5 -7
  570. package/src/maths/plane/signedDistanceToPoint.test.js +3 -2
  571. package/src/maths/plane/toString.d.ts +2 -4
  572. package/src/maths/plane/transform.d.ts +3 -5
  573. package/src/maths/plane/transform.js +11 -13
  574. package/src/maths/plane/transform.test.js +4 -3
  575. package/src/maths/plane/type.d.ts +1 -3
  576. package/src/maths/rotation.test.js +4 -4
  577. package/src/maths/types.d.ts +15 -8
  578. package/src/maths/utils/OrthonormalFormula.d.ts +9 -0
  579. package/src/maths/utils/OrthonormalFormula.js +82 -0
  580. package/src/maths/utils/OrthonormalFormula.test.js +72 -0
  581. package/src/maths/utils/aboutEqualNormals.d.ts +2 -4
  582. package/src/maths/utils/aboutEqualNormals.js +4 -6
  583. package/src/maths/utils/area.d.ts +2 -4
  584. package/src/maths/utils/area.js +2 -4
  585. package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +2 -4
  586. package/src/maths/utils/interpolateBetween2DPointsForY.js +4 -6
  587. package/src/maths/utils/intersect.d.ts +2 -4
  588. package/src/maths/utils/intersect.js +14 -9
  589. package/src/maths/utils/intersect.test.js +40 -0
  590. package/src/maths/utils/solve2Linear.d.ts +2 -4
  591. package/src/maths/utils/solve2Linear.js +1 -3
  592. package/src/maths/utils/trigonometry.js +7 -9
  593. package/src/maths/utils/trigonometry.test.js +3 -3
  594. package/src/maths/vec1/type.d.ts +1 -3
  595. package/src/maths/vec2/abs.d.ts +2 -4
  596. package/src/maths/vec2/abs.js +4 -6
  597. package/src/maths/vec2/abs.test.js +4 -3
  598. package/src/maths/vec2/add.d.ts +2 -4
  599. package/src/maths/vec2/add.js +5 -7
  600. package/src/maths/vec2/add.test.js +4 -3
  601. package/src/maths/vec2/angle.d.ts +1 -3
  602. package/src/maths/vec2/angle.js +1 -1
  603. package/src/maths/vec2/angleDegrees.d.ts +2 -4
  604. package/src/maths/vec2/angleDegrees.js +4 -6
  605. package/src/maths/vec2/angleDegrees.test.js +6 -4
  606. package/src/maths/vec2/angleRadians.d.ts +2 -4
  607. package/src/maths/vec2/angleRadians.js +3 -5
  608. package/src/maths/vec2/angleRadians.test.js +6 -4
  609. package/src/maths/vec2/clone.d.ts +2 -4
  610. package/src/maths/vec2/clone.js +4 -6
  611. package/src/maths/vec2/clone.test.js +4 -3
  612. package/src/maths/vec2/copy.d.ts +2 -4
  613. package/src/maths/vec2/copy.js +4 -6
  614. package/src/maths/vec2/copy.test.js +4 -3
  615. package/src/maths/vec2/create.d.ts +2 -4
  616. package/src/maths/vec2/create.js +2 -5
  617. package/src/maths/vec2/create.test.js +3 -3
  618. package/src/maths/vec2/cross.d.ts +3 -5
  619. package/src/maths/vec2/cross.js +5 -7
  620. package/src/maths/vec2/cross.test.js +14 -12
  621. package/src/maths/vec2/distance.d.ts +2 -4
  622. package/src/maths/vec2/distance.js +4 -6
  623. package/src/maths/vec2/distance.test.js +6 -4
  624. package/src/maths/vec2/divide.d.ts +2 -4
  625. package/src/maths/vec2/divide.js +5 -7
  626. package/src/maths/vec2/divide.test.js +4 -3
  627. package/src/maths/vec2/dot.d.ts +2 -4
  628. package/src/maths/vec2/dot.js +4 -6
  629. package/src/maths/vec2/dot.test.js +3 -2
  630. package/src/maths/vec2/equals.d.ts +2 -4
  631. package/src/maths/vec2/equals.js +3 -5
  632. package/src/maths/vec2/equals.test.js +3 -2
  633. package/src/maths/vec2/fromAngleDegrees.d.ts +2 -4
  634. package/src/maths/vec2/fromAngleDegrees.js +5 -7
  635. package/src/maths/vec2/fromAngleDegrees.test.js +4 -3
  636. package/src/maths/vec2/fromAngleRadians.d.ts +2 -4
  637. package/src/maths/vec2/fromAngleRadians.js +5 -7
  638. package/src/maths/vec2/fromAngleRadians.test.js +4 -4
  639. package/src/maths/vec2/fromScalar.d.ts +2 -4
  640. package/src/maths/vec2/fromScalar.js +4 -6
  641. package/src/maths/vec2/fromScalar.test.js +4 -3
  642. package/src/maths/vec2/fromValues.d.ts +2 -4
  643. package/src/maths/vec2/fromValues.js +5 -7
  644. package/src/maths/vec2/index.d.ts +34 -35
  645. package/src/maths/vec2/index.js +33 -35
  646. package/src/maths/vec2/length.d.ts +2 -4
  647. package/src/maths/vec2/length.js +3 -5
  648. package/src/maths/vec2/length.test.js +6 -4
  649. package/src/maths/vec2/lerp.d.ts +2 -4
  650. package/src/maths/vec2/lerp.js +6 -8
  651. package/src/maths/vec2/lerp.test.js +4 -3
  652. package/src/maths/vec2/max.d.ts +2 -4
  653. package/src/maths/vec2/max.js +5 -7
  654. package/src/maths/vec2/max.test.js +4 -3
  655. package/src/maths/vec2/min.d.ts +2 -4
  656. package/src/maths/vec2/min.js +5 -7
  657. package/src/maths/vec2/min.test.js +4 -3
  658. package/src/maths/vec2/multiply.d.ts +2 -4
  659. package/src/maths/vec2/multiply.js +5 -7
  660. package/src/maths/vec2/multiply.test.js +4 -3
  661. package/src/maths/vec2/negate.d.ts +2 -4
  662. package/src/maths/vec2/negate.js +4 -6
  663. package/src/maths/vec2/negate.test.js +4 -3
  664. package/src/maths/vec2/normal.d.ts +2 -4
  665. package/src/maths/vec2/normal.js +7 -9
  666. package/src/maths/vec2/normal.test.js +4 -3
  667. package/src/maths/vec2/normalize.d.ts +2 -4
  668. package/src/maths/vec2/normalize.js +4 -8
  669. package/src/maths/vec2/normalize.test.js +4 -3
  670. package/src/maths/vec2/rotate.d.ts +2 -4
  671. package/src/maths/vec2/rotate.js +6 -8
  672. package/src/maths/vec2/rotate.test.js +4 -4
  673. package/src/maths/vec2/scale.d.ts +2 -4
  674. package/src/maths/vec2/scale.js +5 -7
  675. package/src/maths/vec2/scale.test.js +4 -3
  676. package/src/maths/vec2/snap.d.ts +2 -4
  677. package/src/maths/vec2/snap.js +5 -7
  678. package/src/maths/vec2/snap.test.js +4 -3
  679. package/src/maths/vec2/squaredDistance.d.ts +2 -4
  680. package/src/maths/vec2/squaredDistance.js +4 -6
  681. package/src/maths/vec2/squaredDistance.test.js +6 -4
  682. package/src/maths/vec2/squaredLength.d.ts +2 -4
  683. package/src/maths/vec2/squaredLength.js +3 -5
  684. package/src/maths/vec2/squaredLength.test.js +6 -4
  685. package/src/maths/vec2/subtract.d.ts +2 -4
  686. package/src/maths/vec2/subtract.js +5 -7
  687. package/src/maths/vec2/subtract.test.js +4 -3
  688. package/src/maths/vec2/toString.d.ts +2 -4
  689. package/src/maths/vec2/toString.js +3 -5
  690. package/src/maths/vec2/transform.d.ts +3 -5
  691. package/src/maths/vec2/transform.js +5 -7
  692. package/src/maths/vec2/transform.test.js +4 -3
  693. package/src/maths/vec2/type.d.ts +1 -3
  694. package/src/maths/vec3/abs.d.ts +2 -4
  695. package/src/maths/vec3/abs.js +4 -6
  696. package/src/maths/vec3/abs.test.js +4 -3
  697. package/src/maths/vec3/add.d.ts +2 -4
  698. package/src/maths/vec3/add.js +5 -7
  699. package/src/maths/vec3/add.test.js +4 -3
  700. package/src/maths/vec3/angle.d.ts +2 -4
  701. package/src/maths/vec3/angle.js +5 -7
  702. package/src/maths/vec3/angle.test.js +6 -4
  703. package/src/maths/vec3/clone.d.ts +2 -4
  704. package/src/maths/vec3/clone.js +4 -6
  705. package/src/maths/vec3/clone.test.js +4 -3
  706. package/src/maths/vec3/copy.d.ts +2 -4
  707. package/src/maths/vec3/copy.js +4 -6
  708. package/src/maths/vec3/copy.test.js +4 -3
  709. package/src/maths/vec3/create.d.ts +2 -4
  710. package/src/maths/vec3/create.js +2 -5
  711. package/src/maths/vec3/create.test.js +3 -3
  712. package/src/maths/vec3/cross.d.ts +2 -4
  713. package/src/maths/vec3/cross.js +5 -7
  714. package/src/maths/vec3/cross.test.js +4 -3
  715. package/src/maths/vec3/distance.d.ts +2 -4
  716. package/src/maths/vec3/distance.js +4 -6
  717. package/src/maths/vec3/distance.test.js +6 -4
  718. package/src/maths/vec3/divide.d.ts +2 -4
  719. package/src/maths/vec3/divide.js +5 -7
  720. package/src/maths/vec3/divide.test.js +4 -3
  721. package/src/maths/vec3/dot.d.ts +2 -4
  722. package/src/maths/vec3/dot.js +4 -6
  723. package/src/maths/vec3/dot.test.js +3 -2
  724. package/src/maths/vec3/equals.d.ts +2 -4
  725. package/src/maths/vec3/equals.js +3 -5
  726. package/src/maths/vec3/equals.test.js +3 -2
  727. package/src/maths/vec3/fromScalar.d.ts +2 -4
  728. package/src/maths/vec3/fromScalar.js +4 -6
  729. package/src/maths/vec3/fromScalar.test.js +4 -3
  730. package/src/maths/vec3/fromValues.d.ts +2 -4
  731. package/src/maths/vec3/fromValues.js +6 -8
  732. package/src/maths/vec3/fromValues.test.js +4 -3
  733. package/src/maths/vec3/fromVec2.d.ts +3 -5
  734. package/src/maths/vec3/fromVec2.js +4 -6
  735. package/src/maths/vec3/fromVec2.test.js +3 -3
  736. package/src/maths/vec3/index.d.ts +33 -34
  737. package/src/maths/vec3/index.js +32 -34
  738. package/src/maths/vec3/length.d.ts +2 -4
  739. package/src/maths/vec3/length.js +3 -5
  740. package/src/maths/vec3/length.test.js +6 -4
  741. package/src/maths/vec3/lerp.d.ts +2 -4
  742. package/src/maths/vec3/lerp.js +6 -8
  743. package/src/maths/vec3/lerp.test.js +4 -3
  744. package/src/maths/vec3/max.d.ts +2 -4
  745. package/src/maths/vec3/max.js +5 -7
  746. package/src/maths/vec3/max.test.js +4 -3
  747. package/src/maths/vec3/min.d.ts +2 -4
  748. package/src/maths/vec3/min.js +5 -7
  749. package/src/maths/vec3/min.test.js +4 -3
  750. package/src/maths/vec3/multiply.d.ts +2 -4
  751. package/src/maths/vec3/multiply.js +5 -7
  752. package/src/maths/vec3/multiply.test.js +4 -3
  753. package/src/maths/vec3/negate.d.ts +2 -4
  754. package/src/maths/vec3/negate.js +4 -6
  755. package/src/maths/vec3/negate.test.js +4 -3
  756. package/src/maths/vec3/normalize.d.ts +2 -4
  757. package/src/maths/vec3/normalize.js +4 -6
  758. package/src/maths/vec3/normalize.test.js +4 -3
  759. package/src/maths/vec3/orthogonal.d.ts +2 -4
  760. package/src/maths/vec3/orthogonal.js +7 -9
  761. package/src/maths/vec3/orthogonal.test.js +4 -3
  762. package/src/maths/vec3/rotateX.d.ts +2 -4
  763. package/src/maths/vec3/rotateX.js +6 -8
  764. package/src/maths/vec3/rotateX.test.js +4 -4
  765. package/src/maths/vec3/rotateY.d.ts +2 -4
  766. package/src/maths/vec3/rotateY.js +6 -8
  767. package/src/maths/vec3/rotateY.test.js +4 -4
  768. package/src/maths/vec3/rotateZ.d.ts +2 -4
  769. package/src/maths/vec3/rotateZ.js +6 -8
  770. package/src/maths/vec3/rotateZ.test.js +4 -4
  771. package/src/maths/vec3/scale.d.ts +2 -4
  772. package/src/maths/vec3/scale.js +5 -7
  773. package/src/maths/vec3/scale.test.js +4 -3
  774. package/src/maths/vec3/snap.d.ts +2 -4
  775. package/src/maths/vec3/snap.js +5 -7
  776. package/src/maths/vec3/snap.test.js +4 -3
  777. package/src/maths/vec3/squaredDistance.d.ts +2 -4
  778. package/src/maths/vec3/squaredDistance.js +4 -6
  779. package/src/maths/vec3/squaredDistance.test.js +6 -4
  780. package/src/maths/vec3/squaredLength.d.ts +2 -4
  781. package/src/maths/vec3/squaredLength.js +3 -5
  782. package/src/maths/vec3/squaredLength.test.js +6 -4
  783. package/src/maths/vec3/subtract.d.ts +2 -4
  784. package/src/maths/vec3/subtract.js +5 -7
  785. package/src/maths/vec3/subtract.test.js +4 -3
  786. package/src/maths/vec3/toString.d.ts +2 -4
  787. package/src/maths/vec3/toString.js +3 -5
  788. package/src/maths/vec3/transform.d.ts +3 -5
  789. package/src/maths/vec3/transform.js +5 -7
  790. package/src/maths/vec3/transform.test.js +12 -15
  791. package/src/maths/vec3/type.d.ts +1 -3
  792. package/src/maths/vec4/clone.d.ts +2 -4
  793. package/src/maths/vec4/clone.js +4 -6
  794. package/src/maths/vec4/clone.test.js +4 -3
  795. package/src/maths/vec4/copy.d.ts +2 -4
  796. package/src/maths/vec4/copy.js +4 -6
  797. package/src/maths/vec4/copy.test.js +4 -3
  798. package/src/maths/vec4/create.d.ts +2 -4
  799. package/src/maths/vec4/create.js +2 -5
  800. package/src/maths/vec4/create.test.js +3 -3
  801. package/src/maths/vec4/dot.d.ts +2 -4
  802. package/src/maths/vec4/dot.js +4 -6
  803. package/src/maths/vec4/dot.test.js +2 -2
  804. package/src/maths/vec4/equals.d.ts +2 -4
  805. package/src/maths/vec4/equals.js +3 -5
  806. package/src/maths/vec4/equals.test.js +3 -2
  807. package/src/maths/vec4/fromScalar.d.ts +2 -4
  808. package/src/maths/vec4/fromScalar.js +3 -5
  809. package/src/maths/vec4/fromScalar.test.js +4 -3
  810. package/src/maths/vec4/fromValues.d.ts +2 -4
  811. package/src/maths/vec4/fromValues.js +7 -9
  812. package/src/maths/vec4/fromValues.test.js +4 -3
  813. package/src/maths/vec4/index.d.ts +10 -11
  814. package/src/maths/vec4/index.js +9 -11
  815. package/src/maths/vec4/toString.d.ts +2 -4
  816. package/src/maths/vec4/toString.js +3 -5
  817. package/src/maths/vec4/transform.d.ts +3 -5
  818. package/src/maths/vec4/transform.js +6 -7
  819. package/src/maths/vec4/transform.test.js +4 -3
  820. package/src/maths/vec4/type.d.ts +1 -3
  821. package/src/measurements/calculateEpsilonFromBounds.js +2 -4
  822. package/src/measurements/calculateEpsilonFromBounds.test.js +4 -3
  823. package/src/measurements/index.d.ts +13 -14
  824. package/src/measurements/index.js +13 -15
  825. package/src/measurements/measureAggregateArea.d.ts +3 -5
  826. package/src/measurements/measureAggregateArea.js +4 -6
  827. package/src/measurements/measureAggregateArea.test.js +4 -3
  828. package/src/measurements/measureAggregateBoundingBox.d.ts +4 -6
  829. package/src/measurements/measureAggregateBoundingBox.js +6 -8
  830. package/src/measurements/measureAggregateBoundingBox.test.js +4 -4
  831. package/src/measurements/measureAggregateEpsilon.d.ts +3 -5
  832. package/src/measurements/measureAggregateEpsilon.js +10 -8
  833. package/src/measurements/measureAggregateEpsilon.test.js +6 -4
  834. package/src/measurements/measureAggregateVolume.d.ts +3 -5
  835. package/src/measurements/measureAggregateVolume.js +4 -6
  836. package/src/measurements/measureAggregateVolume.test.js +4 -3
  837. package/src/measurements/measureArea.d.ts +5 -7
  838. package/src/measurements/measureArea.js +37 -19
  839. package/src/measurements/measureArea.test.js +14 -4
  840. package/src/measurements/measureBoundingBox.d.ts +6 -8
  841. package/src/measurements/measureBoundingBox.js +81 -81
  842. package/src/measurements/measureBoundingBox.test.js +26 -5
  843. package/src/measurements/measureBoundingSphere.d.ts +4 -7
  844. package/src/measurements/measureBoundingSphere.js +83 -64
  845. package/src/measurements/measureBoundingSphere.test.js +7 -4
  846. package/src/measurements/measureCenter.d.ts +4 -6
  847. package/src/measurements/measureCenter.js +4 -6
  848. package/src/measurements/measureCenter.test.js +7 -4
  849. package/src/measurements/measureCenterOfMass.d.ts +4 -6
  850. package/src/measurements/measureCenterOfMass.js +6 -8
  851. package/src/measurements/measureCenterOfMass.test.js +7 -4
  852. package/src/measurements/measureDimensions.d.ts +4 -6
  853. package/src/measurements/measureDimensions.js +3 -5
  854. package/src/measurements/measureDimensions.test.js +7 -4
  855. package/src/measurements/measureEpsilon.d.ts +5 -7
  856. package/src/measurements/measureEpsilon.js +14 -29
  857. package/src/measurements/measureEpsilon.test.js +7 -4
  858. package/src/measurements/measureVolume.d.ts +5 -7
  859. package/src/measurements/measureVolume.js +7 -30
  860. package/src/measurements/measureVolume.test.js +7 -4
  861. package/src/measurements/types.d.ts +2 -1
  862. package/src/operations/booleans/index.d.ts +3 -5
  863. package/src/operations/booleans/index.js +5 -7
  864. package/src/operations/booleans/intersect.d.ts +5 -6
  865. package/src/operations/booleans/intersect.js +12 -14
  866. package/src/operations/booleans/intersect.test.js +25 -0
  867. package/src/operations/booleans/intersectGeom2.js +10 -16
  868. package/src/operations/booleans/intersectGeom2.test.js +23 -17
  869. package/src/operations/booleans/intersectGeom3.js +9 -11
  870. package/src/operations/booleans/intersectGeom3.test.js +13 -17
  871. package/src/operations/booleans/intersectGeom3Sub.js +10 -11
  872. package/src/operations/booleans/martinez/compareEvents.js +45 -0
  873. package/src/operations/booleans/martinez/compareSegments.js +51 -0
  874. package/src/operations/booleans/martinez/computeFields.js +109 -0
  875. package/src/operations/booleans/martinez/connectEdges.js +189 -0
  876. package/src/operations/booleans/martinez/contour.js +12 -0
  877. package/src/operations/booleans/martinez/divideSegment.js +32 -0
  878. package/src/operations/booleans/martinez/edgeType.js +4 -0
  879. package/src/operations/booleans/martinez/fillQueue.js +80 -0
  880. package/src/operations/booleans/martinez/index.js +154 -0
  881. package/src/operations/booleans/martinez/operation.js +4 -0
  882. package/src/operations/booleans/martinez/possibleIntersection.js +113 -0
  883. package/src/operations/booleans/martinez/segmentIntersection.js +132 -0
  884. package/src/operations/booleans/martinez/signedArea.js +16 -0
  885. package/src/operations/booleans/martinez/splaytree.js +599 -0
  886. package/src/operations/booleans/martinez/subdivideSegments.js +82 -0
  887. package/src/operations/booleans/martinez/sweepEvent.js +132 -0
  888. package/src/operations/booleans/martinez/tinyqueue.js +76 -0
  889. package/src/operations/booleans/mayOverlap.js +6 -7
  890. package/src/operations/booleans/mayOverlap.test.js +6 -6
  891. package/src/operations/booleans/scission.js +5 -9
  892. package/src/operations/booleans/scission.test.js +4 -4
  893. package/src/operations/booleans/scissionGeom3.js +15 -16
  894. package/src/operations/booleans/subtract.d.ts +5 -6
  895. package/src/operations/booleans/subtract.js +12 -14
  896. package/src/operations/booleans/subtract.test.js +25 -0
  897. package/src/operations/booleans/subtractGeom2.js +10 -16
  898. package/src/operations/booleans/subtractGeom2.test.js +22 -17
  899. package/src/operations/booleans/subtractGeom3.js +9 -11
  900. package/src/operations/booleans/subtractGeom3.test.js +12 -6
  901. package/src/operations/booleans/subtractGeom3Sub.js +10 -11
  902. package/src/operations/booleans/trees/Node.js +45 -48
  903. package/src/operations/booleans/trees/PolygonTreeNode.js +36 -38
  904. package/src/operations/booleans/trees/Tree.js +9 -12
  905. package/src/operations/booleans/trees/index.js +1 -3
  906. package/src/operations/booleans/trees/splitLineSegmentByPlane.js +2 -4
  907. package/src/operations/booleans/trees/splitPolygonByPlane.js +55 -57
  908. package/src/operations/booleans/union.d.ts +5 -6
  909. package/src/operations/booleans/union.js +12 -14
  910. package/src/operations/booleans/union.test.js +25 -0
  911. package/src/operations/booleans/unionGeom2.js +10 -16
  912. package/src/operations/booleans/unionGeom2.test.js +129 -84
  913. package/src/operations/booleans/unionGeom3.js +9 -11
  914. package/src/operations/booleans/unionGeom3.test.js +17 -9
  915. package/src/operations/booleans/unionGeom3Sub.js +10 -12
  916. package/src/operations/extrusions/extrudeFromSlices.d.ts +3 -6
  917. package/src/operations/extrusions/extrudeFromSlices.js +19 -31
  918. package/src/operations/extrusions/extrudeFromSlices.test.js +47 -48
  919. package/src/operations/extrusions/extrudeHelical.d.ts +2 -4
  920. package/src/operations/extrusions/extrudeHelical.js +21 -29
  921. package/src/operations/extrusions/extrudeHelical.test.js +40 -42
  922. package/src/operations/extrusions/extrudeLinear.d.ts +4 -6
  923. package/src/operations/extrusions/extrudeLinear.js +10 -12
  924. package/src/operations/extrusions/extrudeLinear.test.js +84 -67
  925. package/src/operations/extrusions/extrudeLinearGeom2.js +18 -23
  926. package/src/operations/extrusions/extrudeLinearPath2.js +11 -12
  927. package/src/operations/extrusions/extrudeRotate.d.ts +2 -4
  928. package/src/operations/extrusions/extrudeRotate.js +27 -32
  929. package/src/operations/extrusions/extrudeRotate.test.js +58 -34
  930. package/src/operations/extrusions/extrudeWalls.js +11 -14
  931. package/src/operations/extrusions/extrudeWalls.test.js +24 -48
  932. package/src/operations/extrusions/index.d.ts +5 -8
  933. package/src/operations/extrusions/index.js +6 -10
  934. package/src/operations/extrusions/project.d.ts +6 -8
  935. package/src/operations/extrusions/project.js +36 -29
  936. package/src/operations/extrusions/project.test.js +116 -83
  937. package/src/operations/hulls/hull.d.ts +5 -7
  938. package/src/operations/hulls/hull.js +10 -12
  939. package/src/operations/hulls/hull.test.js +56 -58
  940. package/src/operations/hulls/hullChain.d.ts +5 -7
  941. package/src/operations/hulls/hullChain.js +10 -10
  942. package/src/operations/hulls/hullChain.test.js +17 -8
  943. package/src/operations/hulls/hullGeom2.js +7 -9
  944. package/src/operations/hulls/hullGeom3.js +8 -10
  945. package/src/operations/hulls/hullPath2.js +6 -8
  946. package/src/operations/hulls/hullPath2.test.js +3 -3
  947. package/src/operations/hulls/hullPoints2.js +5 -6
  948. package/src/operations/hulls/hullPoints2.test.js +2 -2
  949. package/src/operations/hulls/index.d.ts +2 -4
  950. package/src/operations/hulls/index.js +3 -5
  951. package/src/operations/hulls/quickhull/Face.js +7 -21
  952. package/src/operations/hulls/quickhull/HalfEdge.js +2 -5
  953. package/src/operations/hulls/quickhull/QuickHull.js +14 -16
  954. package/src/operations/hulls/quickhull/Vertex.js +1 -3
  955. package/src/operations/hulls/quickhull/VertexList.js +1 -4
  956. package/src/operations/hulls/quickhull/index.js +2 -4
  957. package/src/operations/hulls/quickhull/point-line-distance.js +2 -6
  958. package/src/operations/hulls/toUniquePoints.js +4 -6
  959. package/src/operations/modifiers/generalize.d.ts +2 -2
  960. package/src/operations/modifiers/generalize.js +14 -16
  961. package/src/operations/modifiers/generalize.test.js +6 -6
  962. package/src/operations/modifiers/index.d.ts +3 -3
  963. package/src/operations/modifiers/index.js +4 -6
  964. package/src/operations/modifiers/insertTjunctions.js +164 -165
  965. package/src/operations/modifiers/insertTjunctions.test.js +5 -5
  966. package/src/operations/modifiers/mergePolygons.js +35 -36
  967. package/src/operations/modifiers/reTesselateCoplanarPolygons.js +235 -236
  968. package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +4 -4
  969. package/src/operations/modifiers/retessellate.d.ts +2 -2
  970. package/src/operations/modifiers/retessellate.js +69 -30
  971. package/src/operations/modifiers/retessellate.test.js +4 -4
  972. package/src/operations/modifiers/snap.d.ts +2 -2
  973. package/src/operations/modifiers/snap.js +30 -19
  974. package/src/operations/modifiers/snap.test.js +32 -10
  975. package/src/operations/modifiers/snapPolygons.js +14 -16
  976. package/src/operations/modifiers/snapPolygons.test.js +3 -3
  977. package/src/operations/modifiers/triangulatePolygons.js +5 -6
  978. package/src/operations/offsets/extrudePolygon.js +32 -0
  979. package/src/operations/offsets/index.d.ts +2 -0
  980. package/src/operations/offsets/index.js +9 -0
  981. package/src/operations/offsets/offset.d.ts +12 -0
  982. package/src/operations/offsets/offset.js +36 -0
  983. package/src/operations/offsets/offsetFromPoints.d.ts +10 -0
  984. package/src/operations/{expansions → offsets}/offsetFromPoints.js +29 -28
  985. package/src/operations/offsets/offsetFromPoints.test.js +317 -0
  986. package/src/operations/offsets/offsetGeom2.js +55 -0
  987. package/src/operations/offsets/offsetGeom2.test.js +268 -0
  988. package/src/operations/offsets/offsetGeom3.js +33 -0
  989. package/src/operations/{expansions/expandGeom3.test.js → offsets/offsetGeom3.test.js} +63 -5
  990. package/src/operations/{expansions/expandPath2.js → offsets/offsetPath2.js} +27 -33
  991. package/src/operations/offsets/offsetPath2.test.js +103 -0
  992. package/src/operations/{expansions/expandShell.js → offsets/offsetShell.js} +54 -56
  993. package/src/operations/transforms/align.d.ts +5 -7
  994. package/src/operations/transforms/align.js +9 -9
  995. package/src/operations/transforms/align.test.js +7 -6
  996. package/src/operations/transforms/center.d.ts +3 -3
  997. package/src/operations/transforms/center.js +11 -18
  998. package/src/operations/transforms/center.test.js +16 -6
  999. package/src/operations/transforms/index.d.ts +7 -9
  1000. package/src/operations/transforms/index.js +8 -29
  1001. package/src/operations/transforms/mirror.d.ts +3 -3
  1002. package/src/operations/transforms/mirror.js +11 -18
  1003. package/src/operations/transforms/mirror.test.js +18 -6
  1004. package/src/operations/transforms/rotate.d.ts +6 -6
  1005. package/src/operations/transforms/rotate.js +13 -20
  1006. package/src/operations/transforms/rotate.test.js +18 -7
  1007. package/src/operations/transforms/scale.d.ts +6 -6
  1008. package/src/operations/transforms/scale.js +12 -19
  1009. package/src/operations/transforms/scale.test.js +21 -6
  1010. package/src/operations/transforms/transform.d.ts +3 -3
  1011. package/src/operations/transforms/transform.js +7 -9
  1012. package/src/operations/transforms/transform.test.js +7 -7
  1013. package/src/operations/transforms/translate.d.ts +3 -5
  1014. package/src/operations/transforms/translate.js +13 -20
  1015. package/src/operations/transforms/translate.test.js +18 -6
  1016. package/src/primitives/arc.d.ts +3 -5
  1017. package/src/primitives/arc.js +26 -28
  1018. package/src/primitives/arc.test.js +6 -5
  1019. package/src/primitives/circle.d.ts +3 -5
  1020. package/src/primitives/circle.js +11 -13
  1021. package/src/primitives/circle.test.js +13 -5
  1022. package/src/primitives/commonChecks.js +3 -9
  1023. package/src/primitives/cube.d.ts +3 -5
  1024. package/src/primitives/cube.js +7 -10
  1025. package/src/primitives/cube.test.js +11 -4
  1026. package/src/primitives/cuboid.d.ts +3 -5
  1027. package/src/primitives/cuboid.js +12 -11
  1028. package/src/primitives/cuboid.test.js +11 -4
  1029. package/src/primitives/cylinder.d.ts +3 -5
  1030. package/src/primitives/cylinder.js +15 -14
  1031. package/src/primitives/cylinder.test.js +18 -4
  1032. package/src/primitives/cylinderElliptic.d.ts +3 -5
  1033. package/src/primitives/cylinderElliptic.js +33 -35
  1034. package/src/primitives/cylinderElliptic.test.js +6 -5
  1035. package/src/primitives/ellipse.d.ts +3 -5
  1036. package/src/primitives/ellipse.js +23 -22
  1037. package/src/primitives/ellipse.test.js +13 -5
  1038. package/src/primitives/ellipsoid.d.ts +3 -5
  1039. package/src/primitives/ellipsoid.js +52 -52
  1040. package/src/primitives/ellipsoid.test.js +11 -4
  1041. package/src/primitives/geodesicSphere.d.ts +2 -4
  1042. package/src/primitives/geodesicSphere.js +18 -18
  1043. package/src/primitives/geodesicSphere.test.js +11 -4
  1044. package/src/primitives/index.d.ts +21 -23
  1045. package/src/primitives/index.js +22 -24
  1046. package/src/primitives/line.d.ts +3 -5
  1047. package/src/primitives/line.js +3 -5
  1048. package/src/primitives/line.test.js +4 -4
  1049. package/src/primitives/polygon.d.ts +3 -5
  1050. package/src/primitives/polygon.js +17 -20
  1051. package/src/primitives/polygon.test.js +7 -7
  1052. package/src/primitives/polyhedron.d.ts +4 -6
  1053. package/src/primitives/polyhedron.js +15 -17
  1054. package/src/primitives/polyhedron.test.js +4 -4
  1055. package/src/primitives/rectangle.d.ts +3 -5
  1056. package/src/primitives/rectangle.js +14 -13
  1057. package/src/primitives/rectangle.test.js +11 -4
  1058. package/src/primitives/roundedCuboid.d.ts +3 -5
  1059. package/src/primitives/roundedCuboid.js +65 -59
  1060. package/src/primitives/roundedCuboid.test.js +18 -4
  1061. package/src/primitives/roundedCylinder.d.ts +3 -5
  1062. package/src/primitives/roundedCylinder.js +83 -79
  1063. package/src/primitives/roundedCylinder.test.js +25 -4
  1064. package/src/primitives/roundedRectangle.d.ts +3 -5
  1065. package/src/primitives/roundedRectangle.js +24 -17
  1066. package/src/primitives/roundedRectangle.test.js +18 -4
  1067. package/src/primitives/sphere.d.ts +3 -5
  1068. package/src/primitives/sphere.js +9 -12
  1069. package/src/primitives/sphere.test.js +11 -4
  1070. package/src/primitives/square.d.ts +3 -5
  1071. package/src/primitives/square.js +7 -10
  1072. package/src/primitives/square.test.js +11 -4
  1073. package/src/primitives/star.d.ts +3 -5
  1074. package/src/primitives/star.js +16 -18
  1075. package/src/primitives/star.test.js +4 -4
  1076. package/src/primitives/torus.d.ts +2 -4
  1077. package/src/primitives/torus.js +16 -18
  1078. package/src/primitives/torus.test.js +8 -6
  1079. package/src/primitives/triangle.d.ts +2 -4
  1080. package/src/primitives/triangle.js +9 -11
  1081. package/src/primitives/triangle.test.js +8 -6
  1082. package/src/text/fonts/single-line/hershey/simplex.js +1 -1
  1083. package/src/text/index.d.ts +2 -4
  1084. package/src/text/index.js +3 -5
  1085. package/src/text/vectorChar.d.ts +2 -8
  1086. package/src/text/vectorChar.js +51 -39
  1087. package/src/text/vectorChar.test.js +63 -0
  1088. package/src/text/vectorText.d.ts +2 -8
  1089. package/src/text/vectorText.js +100 -72
  1090. package/src/text/vectorText.test.js +267 -0
  1091. package/src/utils/areAllShapesTheSameType.d.ts +2 -4
  1092. package/src/utils/areAllShapesTheSameType.js +4 -6
  1093. package/src/utils/areAllShapesTheSameType.test.js +3 -3
  1094. package/src/utils/degToRad.d.ts +1 -3
  1095. package/src/utils/degToRad.js +3 -5
  1096. package/src/utils/degToRad.test.js +3 -3
  1097. package/src/utils/flatten.d.ts +2 -4
  1098. package/src/utils/flatten.js +1 -3
  1099. package/src/utils/fnNumberSort.d.ts +1 -3
  1100. package/src/utils/fnNumberSort.js +1 -3
  1101. package/src/utils/index.d.ts +4 -9
  1102. package/src/utils/index.js +5 -10
  1103. package/src/utils/insertSorted.d.ts +1 -3
  1104. package/src/utils/insertSorted.js +11 -13
  1105. package/src/utils/padArrayToLength.d.ts +1 -3
  1106. package/src/utils/padArrayToLength.js +2 -4
  1107. package/src/utils/padArrayToLength.test.js +2 -2
  1108. package/src/utils/radToDeg.d.ts +1 -3
  1109. package/src/utils/radToDeg.js +3 -5
  1110. package/src/utils/radToDeg.test.js +3 -3
  1111. package/src/utils/radiusToSegments.d.ts +1 -3
  1112. package/src/utils/radiusToSegments.js +6 -8
  1113. package/src/utils/radiusToSegments.test.js +3 -3
  1114. package/src/utils/recursiveArray.d.ts +1 -3
  1115. package/test/helpers/asserts.js +9 -16
  1116. package/test/helpers/comparePoints.js +2 -4
  1117. package/test/helpers/comparePolygonLists.js +2 -4
  1118. package/test/helpers/comparePolygons.js +4 -6
  1119. package/test/helpers/comparePolygonsAsPoints.js +4 -6
  1120. package/test/helpers/compareVectors.js +5 -6
  1121. package/test/helpers/index.js +6 -8
  1122. package/test/helpers/nearlyEqual.js +1 -3
  1123. package/tsconfig.json +17 -0
  1124. package/src/geometries/geom2/fromPoints.d.ts +0 -6
  1125. package/src/geometries/geom2/fromPoints.js +0 -35
  1126. package/src/geometries/geom2/fromPoints.test.js +0 -22
  1127. package/src/geometries/poly2/flip.d.ts +0 -5
  1128. package/src/geometries/poly2/flip.js +0 -15
  1129. package/src/geometries/poly3/fromPoints.d.ts +0 -6
  1130. package/src/geometries/poly3/fromPoints.js +0 -25
  1131. package/src/geometries/poly3/fromPoints.test.js +0 -15
  1132. package/src/geometries/poly3/fromPointsAndPlane.d.ts +0 -7
  1133. package/src/geometries/poly3/toPoints.d.ts +0 -6
  1134. package/src/geometries/poly3/toPoints.js +0 -10
  1135. package/src/maths/OrthoNormalBasis.js +0 -207
  1136. package/src/maths/utils/index.d.ts +0 -8
  1137. package/src/maths/utils/index.js +0 -15
  1138. package/src/operations/booleans/fromFakePolygons.js +0 -52
  1139. package/src/operations/booleans/to3DWalls.js +0 -36
  1140. package/src/operations/expansions/expand.d.ts +0 -18
  1141. package/src/operations/expansions/expand.js +0 -42
  1142. package/src/operations/expansions/expand.test.js +0 -188
  1143. package/src/operations/expansions/expandGeom2.js +0 -43
  1144. package/src/operations/expansions/expandGeom3.js +0 -36
  1145. package/src/operations/expansions/extrudePolygon.js +0 -34
  1146. package/src/operations/expansions/index.d.ts +0 -4
  1147. package/src/operations/expansions/index.js +0 -11
  1148. package/src/operations/expansions/offset.d.ts +0 -15
  1149. package/src/operations/expansions/offset.js +0 -36
  1150. package/src/operations/expansions/offset.test.js +0 -503
  1151. package/src/operations/expansions/offsetGeom2.js +0 -47
  1152. package/src/operations/expansions/offsetPath2.js +0 -32
  1153. package/src/operations/extrusions/earcut/assignHoles.test.js +0 -74
  1154. package/src/operations/extrusions/extrudeRectangular.d.ts +0 -17
  1155. package/src/operations/extrusions/extrudeRectangular.js +0 -45
  1156. package/src/operations/extrusions/extrudeRectangular.test.js +0 -72
  1157. package/src/operations/extrusions/extrudeRectangularGeom2.js +0 -46
  1158. package/src/operations/extrusions/extrudeRectangularPath2.js +0 -33
  1159. package/src/operations/extrusions/slice/calculatePlane.d.ts +0 -7
  1160. package/src/operations/extrusions/slice/calculatePlane.js +0 -41
  1161. package/src/operations/extrusions/slice/calculatePlane.test.js +0 -35
  1162. package/src/operations/extrusions/slice/clone.d.ts +0 -6
  1163. package/src/operations/extrusions/slice/clone.js +0 -28
  1164. package/src/operations/extrusions/slice/clone.test.js +0 -34
  1165. package/src/operations/extrusions/slice/create.d.ts +0 -5
  1166. package/src/operations/extrusions/slice/create.js +0 -20
  1167. package/src/operations/extrusions/slice/equals.d.ts +0 -5
  1168. package/src/operations/extrusions/slice/equals.js +0 -27
  1169. package/src/operations/extrusions/slice/equals.test.js +0 -17
  1170. package/src/operations/extrusions/slice/fromPoints.d.ts +0 -9
  1171. package/src/operations/extrusions/slice/fromPoints.js +0 -35
  1172. package/src/operations/extrusions/slice/fromPoints.test.js +0 -15
  1173. package/src/operations/extrusions/slice/fromSides.d.ts +0 -7
  1174. package/src/operations/extrusions/slice/fromSides.js +0 -27
  1175. package/src/operations/extrusions/slice/fromSides.test.js +0 -15
  1176. package/src/operations/extrusions/slice/index.d.ts +0 -16
  1177. package/src/operations/extrusions/slice/index.js +0 -19
  1178. package/src/operations/extrusions/slice/isA.d.ts +0 -5
  1179. package/src/operations/extrusions/slice/isA.js +0 -18
  1180. package/src/operations/extrusions/slice/repair.js +0 -62
  1181. package/src/operations/extrusions/slice/reverse.d.ts +0 -6
  1182. package/src/operations/extrusions/slice/reverse.js +0 -26
  1183. package/src/operations/extrusions/slice/toEdges.d.ts +0 -5
  1184. package/src/operations/extrusions/slice/toEdges.js +0 -13
  1185. package/src/operations/extrusions/slice/toPolygons.d.ts +0 -7
  1186. package/src/operations/extrusions/slice/toString.d.ts +0 -5
  1187. package/src/operations/extrusions/slice/toString.js +0 -15
  1188. package/src/operations/extrusions/slice/transform.d.ts +0 -7
  1189. package/src/operations/extrusions/slice/transform.js +0 -21
  1190. package/src/operations/extrusions/slice/type.d.ts +0 -7
  1191. package/src/operations/hulls/quickhull/get-plane-normal.js +0 -20
  1192. package/src/text/text.test.js +0 -187
  1193. package/src/text/vectorParams.js +0 -26
@@ -1,24 +1,24 @@
1
- const { EPS } = require('../../maths/constants')
1
+ import { EPS } from '../../maths/constants.js'
2
2
 
3
- const vec2 = require('../../maths/vec2')
3
+ import * as vec2 from '../../maths/vec2/index.js'
4
4
 
5
- const close = require('./close')
6
- const create = require('./create')
5
+ import { close } from './close.js'
6
+ import { create } from './create.js'
7
7
 
8
8
  /**
9
9
  * Create a new path from the given points.
10
10
  * The points must be provided an array of points,
11
11
  * where each point is an array of two numbers.
12
- * @param {Object} options - options for construction
13
- * @param {Boolean} [options.closed=false] - if the path should be open or closed
12
+ * @param {object} options - options for construction
13
+ * @param {boolean} [options.closed=false] - if the path should be open or closed
14
14
  * @param {Array} points - array of points (2D) from which to create the path
15
- * @returns {path2} a new path
15
+ * @returns {Path2} a new path
16
16
  * @alias module:modeling/geometries/path2.fromPoints
17
17
  *
18
18
  * @example:
19
- * my newpath = fromPoints({closed: true}, [[10, 10], [-10, 10]])
19
+ * my newPath = fromPoints({closed: true}, [[10, 10], [-10, 10]])
20
20
  */
21
- const fromPoints = (options, points) => {
21
+ export const fromPoints = (options, points) => {
22
22
  const defaults = { closed: false }
23
23
  let { closed } = Object.assign({}, defaults, options)
24
24
 
@@ -38,5 +38,3 @@ const fromPoints = (options, points) => {
38
38
 
39
39
  return created
40
40
  }
41
-
42
- module.exports = fromPoints
@@ -1,8 +1,8 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const vec2 = require('../../maths/vec2')
3
+ import { vec2 } from '../../maths/index.js'
4
4
 
5
- const { fromPoints, toPoints, toString } = require('./index')
5
+ import { fromPoints, toPoints, toString } from './index.js'
6
6
 
7
7
  test('fromPoints: creating a path from no points produces an open, empty non-canonical path', (t) => {
8
8
  const created = fromPoints({}, [])
@@ -1,6 +1,6 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { fromCompactBinary, toCompactBinary, create, fromPoints } = require('./index')
3
+ import { fromCompactBinary, toCompactBinary, create, fromPoints } from './index.js'
4
4
 
5
5
  test('toCompactBinary: converts path2 into a compact form', (t) => {
6
6
  const geometry1 = create()
@@ -1,20 +1,19 @@
1
- export { default as appendArc, AppendArcOptions } from './appendArc'
2
- export { default as appendBezier, AppendBezierOptions } from './appendBezier'
3
- export { default as appendPoints } from './appendPoints'
4
- export { default as clone } from './clone'
5
- export { default as close } from './close'
6
- export { default as concat } from './concat'
7
- export { default as create } from './create'
8
- export { default as equals } from './equals'
9
- export { default as fromPoints, FromPointsOptions } from './fromPoints'
10
- export { default as fromCompactBinary } from './fromCompactBinary'
11
- export { default as isA } from './isA'
12
- export { default as reverse } from './reverse'
13
- export { default as toPoints } from './toPoints'
14
- export { default as toString } from './toString'
15
- export { default as toCompactBinary } from './toCompactBinary'
16
- export { default as transform } from './transform'
17
- export { default as validate } from './validate'
1
+ export { appendArc, AppendArcOptions } from './appendArc.js'
2
+ export { appendBezier, AppendBezierOptions } from './appendBezier.js'
3
+ export { appendPoints } from './appendPoints.js'
4
+ export { clone } from './clone.js'
5
+ export { close } from './close.js'
6
+ export { concat } from './concat.js'
7
+ export { create } from './create.js'
8
+ export { equals } from './equals.js'
9
+ export { fromPoints, FromPointsOptions } from './fromPoints.js'
10
+ export { fromCompactBinary } from './fromCompactBinary.js'
11
+ export { isA } from './isA.js'
12
+ export { reverse } from './reverse.js'
13
+ export { toPoints } from './toPoints.js'
14
+ export { toString } from './toString.js'
15
+ export { toCompactBinary } from './toCompactBinary.js'
16
+ export { transform } from './transform.js'
17
+ export { validate } from './validate.js'
18
18
 
19
- export { default as Path2 } from './type'
20
- export as namespace path2
19
+ export type { Path2 } from './type.d.ts'
@@ -4,32 +4,23 @@
4
4
  * @module modeling/geometries/path2
5
5
  *
6
6
  * @example
7
- * colorize([0,0,0,1], path2.fromPoints({ closed: true }, [[0,0], [4,0], [4,3]]))
8
- *
9
- * @example
10
- * {
11
- * "points": [[0,0], [4,0], [4,3]],
12
- * "isClosed": true,
13
- * "transforms": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
14
- * "color": [0,0,0,1]
15
- * }
7
+ * import { geometries } from '@jscad/modeling'
8
+ * let myShape = geometries.path2.fromPoints({ closed: true }, [[0,0], [4,0], [4,3]])
16
9
  */
17
- module.exports = {
18
- appendArc: require('./appendArc'),
19
- appendBezier: require('./appendBezier'),
20
- appendPoints: require('./appendPoints'),
21
- clone: require('./clone'),
22
- close: require('./close'),
23
- concat: require('./concat'),
24
- create: require('./create'),
25
- equals: require('./equals'),
26
- fromPoints: require('./fromPoints'),
27
- fromCompactBinary: require('./fromCompactBinary'),
28
- isA: require('./isA'),
29
- reverse: require('./reverse'),
30
- toPoints: require('./toPoints'),
31
- toString: require('./toString'),
32
- toCompactBinary: require('./toCompactBinary'),
33
- transform: require('./transform'),
34
- validate: require('./validate')
35
- }
10
+ export { appendArc } from './appendArc.js'
11
+ export { appendBezier } from './appendBezier.js'
12
+ export { appendPoints } from './appendPoints.js'
13
+ export { clone } from './clone.js'
14
+ export { close } from './close.js'
15
+ export { concat } from './concat.js'
16
+ export { create } from './create.js'
17
+ export { equals } from './equals.js'
18
+ export { fromPoints } from './fromPoints.js'
19
+ export { fromCompactBinary } from './fromCompactBinary.js'
20
+ export { isA } from './isA.js'
21
+ export { reverse } from './reverse.js'
22
+ export { toPoints } from './toPoints.js'
23
+ export { toString } from './toString.js'
24
+ export { toCompactBinary } from './toCompactBinary.js'
25
+ export { transform } from './transform.js'
26
+ export { validate } from './validate.js'
@@ -1,5 +1,3 @@
1
- import Path2 from './type'
1
+ import type { Path2 } from './type.d.ts'
2
2
 
3
- export default isA
4
-
5
- declare function isA(object: any): object is Path2
3
+ export function isA(object: any): object is Path2
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Determine if the given object is a path2 geometry.
3
- * @param {Object} object - the object to interrogate
3
+ * @param {object} object - the object to interrogate
4
4
  * @returns {Boolean} true if the object matches a path2
5
5
  * @alias module:modeling/geometries/path2.isA
6
6
  */
7
- const isA = (object) => {
7
+ export const isA = (object) => {
8
8
  if (object && typeof object === 'object') {
9
9
  // see create for the required attributes and types
10
10
  if ('points' in object && 'transforms' in object && 'isClosed' in object) {
@@ -16,5 +16,3 @@ const isA = (object) => {
16
16
  }
17
17
  return false
18
18
  }
19
-
20
- module.exports = isA
@@ -1,6 +1,6 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { isA, create, fromPoints } = require('./index')
3
+ import { isA, create, fromPoints } from './index.js'
4
4
 
5
5
  test('isA: identifies created paths', (t) => {
6
6
  const p1 = create()
@@ -1,5 +1,3 @@
1
- import Path2 from './type'
1
+ import type { Path2 } from './type.d.ts'
2
2
 
3
- export default reverse
4
-
5
- declare function reverse(path: Path2): Path2
3
+ export function reverse(path: Path2): Path2
@@ -1,20 +1,18 @@
1
- const clone = require('./clone')
1
+ import { clone } from './clone.js'
2
2
 
3
3
  /**
4
4
  * Reverses the path so that the points are in the opposite order.
5
5
  * This swaps the left (interior) and right (exterior) edges.
6
- * @param {path2} geometry - the path to reverse
7
- * @returns {path2} a new path
6
+ * @param {Path2} geometry - the path to reverse
7
+ * @returns {Path2} a new path
8
8
  * @alias module:modeling/geometries/path2.reverse
9
9
  *
10
10
  * @example
11
- * let newpath = reverse(mypath)
11
+ * let newPath = reverse(myPath)
12
12
  */
13
- const reverse = (geometry) => {
13
+ export const reverse = (geometry) => {
14
14
  // NOTE: this only updates the order of the points
15
15
  const cloned = clone(geometry)
16
16
  cloned.points = geometry.points.slice().reverse()
17
17
  return cloned
18
18
  }
19
-
20
- module.exports = reverse
@@ -1,6 +1,6 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { reverse, equals, fromPoints } = require('./index')
3
+ import { reverse, equals, fromPoints } from './index.js'
4
4
 
5
5
  test('reverse: The reverse of a path has reversed points', (t) => {
6
6
  const pointArray = [[0, 0], [1, 1]]
@@ -1,5 +1,3 @@
1
- import Path2 from './type'
1
+ import type { Path2 } from './type.d.ts'
2
2
 
3
- export default toCompactBinary
4
-
5
- declare function toCompactBinary(geometry: Path2): Float32Array
3
+ export function toCompactBinary(geometry: Path2): Float32Array
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Produce a compact binary representation from the given path.
3
- * @param {path2} geometry - the path geometry
3
+ * @param {Path2} geometry - the path geometry
4
4
  * @returns {TypedArray} compact binary representation
5
5
  * @alias module:modeling/geometries/path2.toCompactBinary
6
6
  */
7
- const toCompactBinary = (geometry) => {
7
+ export const toCompactBinary = (geometry) => {
8
8
  const points = geometry.points
9
9
  const transforms = geometry.transforms
10
10
  let color = [-1, -1, -1, -1]
@@ -48,5 +48,3 @@ const toCompactBinary = (geometry) => {
48
48
  // TODO: how about custom properties or fields ?
49
49
  return compacted
50
50
  }
51
-
52
- module.exports = toCompactBinary
@@ -1,6 +1,4 @@
1
- import Path2 from './type'
2
- import Vec2 from '../../maths/vec2/type'
1
+ import type { Path2 } from './type.d.ts'
2
+ import type { Vec2 } from '../../maths/vec2/type.d.ts'
3
3
 
4
- export default toPoints
5
-
6
- declare function toPoints(geometry: Path2): Array<Vec2>
4
+ export function toPoints(geometry: Path2): Array<Vec2>
@@ -1,15 +1,13 @@
1
- const applyTransforms = require('./applyTransforms')
1
+ import { applyTransforms } from './applyTransforms.js'
2
2
 
3
3
  /**
4
4
  * Produces an array of points from the given geometry.
5
5
  * The returned array should not be modified as the data is shared with the geometry.
6
- * @param {path2} geometry - the geometry
6
+ * @param {Path2} geometry - the geometry
7
7
  * @returns {Array} an array of points
8
8
  * @alias module:modeling/geometries/path2.toPoints
9
9
  *
10
10
  * @example
11
- * let sharedpoints = toPoints(geometry)
11
+ * let sharedPoints = toPoints(geometry)
12
12
  */
13
- const toPoints = (geometry) => applyTransforms(geometry).points
14
-
15
- module.exports = toPoints
13
+ export const toPoints = (geometry) => applyTransforms(geometry).points
@@ -1,8 +1,8 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const vec2 = require('../../maths/vec2')
3
+ import { vec2 } from '../../maths/index.js'
4
4
 
5
- const { toPoints, fromPoints } = require('./index')
5
+ import { toPoints, fromPoints } from './index.js'
6
6
 
7
7
  test('toPoints: An empty path produces an empty point array', (t) => {
8
8
  t.deepEqual(toPoints(fromPoints({}, [])), [])
@@ -1,5 +1,3 @@
1
- import Path2 from './type'
1
+ import type { Path2 } from './type.d.ts'
2
2
 
3
- export default toString
4
-
5
- declare function toString(geometry: Path2): string
3
+ export function toString(geometry: Path2): string
@@ -1,17 +1,17 @@
1
- const vec2 = require('../../maths/vec2')
1
+ import * as vec2 from '../../maths/vec2/index.js'
2
2
 
3
- const toPoints = require('./toPoints')
3
+ import { toPoints } from './toPoints.js'
4
4
 
5
5
  /**
6
6
  * Create a string representing the contents of the given path.
7
- * @param {path2} geometry - the path
8
- * @returns {String} a representative string
7
+ * @param {Path2} geometry - the path
8
+ * @returns {string} a representative string
9
9
  * @alias module:modeling/geometries/path2.toString
10
10
  *
11
11
  * @example
12
12
  * console.out(toString(path))
13
13
  */
14
- const toString = (geometry) => {
14
+ export const toString = (geometry) => {
15
15
  const points = toPoints(geometry)
16
16
  let result = 'path (' + points.length + ' points, ' + geometry.isClosed + '):\n[\n'
17
17
  points.forEach((point) => {
@@ -20,5 +20,3 @@ const toString = (geometry) => {
20
20
  result += ']\n'
21
21
  return result
22
22
  }
23
-
24
- module.exports = toString
@@ -1,6 +1,4 @@
1
- import Path2 from './type'
2
- import Mat4 from '../../maths/mat4/type'
1
+ import type { Path2 } from './type.d.ts'
2
+ import type { Mat4 } from '../../maths/mat4/type.d.ts'
3
3
 
4
- export default transform
5
-
6
- declare function transform(matrix: Mat4, geometry: Path2): Path2
4
+ export function transform(matrix: Mat4, geometry: Path2): Path2
@@ -1,20 +1,18 @@
1
- const mat4 = require('../../maths/mat4')
1
+ import * as mat4 from '../../maths/mat4/index.js'
2
2
 
3
3
  /**
4
4
  * Transform the given geometry using the given matrix.
5
5
  * This is a lazy transform of the points, as this function only adjusts the transforms.
6
6
  * The transforms are applied when accessing the points via toPoints().
7
- * @param {mat4} matrix - the matrix to transform with
8
- * @param {path2} geometry - the geometry to transform
9
- * @returns {path2} a new path
7
+ * @param {Mat4} matrix - the matrix to transform with
8
+ * @param {Path2} geometry - the geometry to transform
9
+ * @returns {Path2} a new path
10
10
  * @alias module:modeling/geometries/path2.transform
11
11
  *
12
12
  * @example
13
- * let newpath = transform(fromZRotation(TAU / 8), path)
13
+ * let newPath = transform(fromZRotation(TAU / 8), path)
14
14
  */
15
- const transform = (matrix, geometry) => {
15
+ export const transform = (matrix, geometry) => {
16
16
  const transforms = mat4.multiply(mat4.create(), matrix, geometry.transforms)
17
17
  return Object.assign({}, geometry, { transforms })
18
18
  }
19
-
20
- module.exports = transform
@@ -1,10 +1,10 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const mat4 = require('../../maths/mat4')
3
+ import { mat4 } from '../../maths/index.js'
4
4
 
5
- const { transform, fromPoints, toPoints } = require('./index')
5
+ import { transform, fromPoints, toPoints } from './index.js'
6
6
 
7
- const { comparePoints, compareVectors } = require('../../../test/helpers/')
7
+ import { comparePoints, compareVectors } from '../../../test/helpers/index.js'
8
8
 
9
9
  test('transform: adjusts the transforms of path', (t) => {
10
10
  const points = [[0, 0], [1, 0], [0, 1]]
@@ -33,7 +33,7 @@ test('transform: adjusts the transforms of path', (t) => {
33
33
  t.false(another.isClosed)
34
34
  t.true(compareVectors(another.transforms, expected.transforms))
35
35
 
36
- // expect application of the transforms to the sides
36
+ // expect application of the transforms to the points
37
37
  expected.points = [[5, 10], [5, 11], [4, 10]]
38
38
  expected.transforms = mat4.create()
39
39
  toPoints(another)
@@ -1,10 +1,8 @@
1
- import Vec2 from '../../maths/vec2/type'
2
- import Mat4 from '../../maths/mat4/type'
3
- import { Color } from '../types'
1
+ import type { Vec2 } from '../../maths/vec2/type.d.ts'
2
+ import type { Mat4 } from '../../maths/mat4/type.d.ts'
3
+ import type { Color } from '../types.d.ts'
4
4
 
5
- export default Path2
6
-
7
- declare interface Path2 {
5
+ export interface Path2 {
8
6
  points: Array<Vec2>
9
7
  isClosed: boolean
10
8
  transforms: Mat4
@@ -1,3 +1 @@
1
- export default validate
2
-
3
- declare function validate(object: any): void
1
+ export function validate(object: any): void
@@ -1,5 +1,6 @@
1
- const vec2 = require('../../maths/vec2')
2
- const isA = require('./isA')
1
+ import * as vec2 from '../../maths/vec2/index.js'
2
+
3
+ import { isA } from './isA.js'
3
4
 
4
5
  /**
5
6
  * Determine if the given object is a valid path2.
@@ -7,11 +8,11 @@ const isA = require('./isA')
7
8
  *
8
9
  * **If the geometry is not valid, an exception will be thrown with details of the geometry error.**
9
10
  *
10
- * @param {Object} object - the object to interrogate
11
+ * @param {object} object - the object to interrogate
11
12
  * @throws {Error} error if the geometry is not valid
12
13
  * @alias module:modeling/geometries/path2.validate
13
14
  */
14
- const validate = (object) => {
15
+ export const validate = (object) => {
15
16
  if (!isA(object)) {
16
17
  throw new Error('invalid path2 structure')
17
18
  }
@@ -20,7 +21,7 @@ const validate = (object) => {
20
21
  if (object.points.length > 1) {
21
22
  for (let i = 0; i < object.points.length; i++) {
22
23
  if (vec2.equals(object.points[i], object.points[(i + 1) % object.points.length])) {
23
- throw new Error(`path2 duplicate points ${object.points[i]}`)
24
+ throw new Error(`path2 has duplicate point ${object.points[i]}`)
24
25
  }
25
26
  }
26
27
  }
@@ -37,5 +38,3 @@ const validate = (object) => {
37
38
  throw new Error(`path2 invalid transforms ${object.transforms}`)
38
39
  }
39
40
  }
40
-
41
- module.exports = validate
@@ -1,6 +1,4 @@
1
- import Poly2 from './type'
2
- import Vec2 from '../../maths/vec2/type'
1
+ import type { Poly2 } from './type.d.ts'
2
+ import type { Vec2 } from '../../maths/vec2/type.d.ts'
3
3
 
4
- export default arePointsInside
5
-
6
- declare function arePointsInside(points: Array<Vec2>, polygon: Poly2): number
4
+ export function arePointsInside(points: Array<Vec2>, polygon: Poly2): number
@@ -1,25 +1,24 @@
1
- const measureArea = require('./measureArea')
2
- const flip = require('./flip')
1
+ import { measureArea } from './measureArea.js'
2
+ import { reverse } from './reverse.js'
3
3
 
4
4
  /**
5
5
  * Determine if the given points are inside the given polygon.
6
6
  *
7
7
  * @param {Array} points - a list of points, where each point is an array with X and Y values
8
- * @param {poly2} polygon - a 2D polygon
9
- * @return {Integer} 1 if all points are inside, 0 if some or none are inside
8
+ * @param {Poly2} polygon - a 2D polygon
9
+ * @return {number} 1 if all points are inside, 0 if some or none are inside
10
10
  * @alias module:modeling/geometries/poly2.arePointsInside
11
11
  */
12
- const arePointsInside = (points, polygon) => {
12
+ export const arePointsInside = (points, polygon) => {
13
13
  if (points.length === 0) return 0 // nothing to check
14
14
 
15
- const vertices = polygon.vertices
16
- if (vertices.length < 3) return 0 // nothing can be inside an empty polygon
15
+ if (polygon.points.length < 3) return 0 // nothing can be inside an empty polygon
17
16
 
18
17
  if (measureArea(polygon) < 0) {
19
- polygon = flip(polygon) // CCW is required
18
+ polygon = reverse(polygon) // CCW is required
20
19
  }
21
20
 
22
- const sum = points.reduce((acc, point) => acc + isPointInside(point, vertices), 0)
21
+ const sum = points.reduce((acc, point) => acc + isPointInside(point, polygon.points), 0)
23
22
  return sum === points.length ? 1 : 0
24
23
  }
25
24
 
@@ -29,42 +28,42 @@ const arePointsInside = (points, polygon) => {
29
28
  * @see http://erich.realtimerendering.com/ptinpoly/ (Crossings Test)
30
29
  * @param {Array} point - an array with X and Y values
31
30
  * @param {Array} polygon - a list of points, where each point is an array with X and Y values
32
- * @return {Integer} 1 if the point is inside, 0 if outside
31
+ * @return {number} 1 if the point is inside, 0 if outside
33
32
  */
34
33
  const isPointInside = (point, polygon) => {
35
- const numverts = polygon.length
34
+ const numPoints = polygon.length
36
35
 
37
36
  const tx = point[0]
38
37
  const ty = point[1]
39
38
 
40
- let vtx0 = polygon[numverts - 1]
39
+ let vtx0 = polygon[numPoints - 1]
41
40
  let vtx1 = polygon[0]
42
41
 
43
- let yflag0 = (vtx0[1] > ty)
42
+ let yFlag0 = (vtx0[1] > ty)
44
43
 
45
44
  let insideFlag = 0
46
45
 
47
46
  let i = 0
48
- for (let j = (numverts + 1); --j;) {
47
+ for (let j = (numPoints + 1); --j;) {
49
48
  /*
50
49
  * check if Y endpoints straddle (are on opposite sides) of point's Y
51
50
  * if so, +X ray could intersect this edge.
52
51
  */
53
- const yflag1 = (vtx1[1] > ty)
54
- if (yflag0 !== yflag1) {
52
+ const yFlag1 = (vtx1[1] > ty)
53
+ if (yFlag0 !== yFlag1) {
55
54
  /*
56
55
  * check if X endpoints are on same side of the point's X
57
56
  * if so, it's easy to test if edge hits or misses.
58
57
  */
59
- const xflag0 = (vtx0[0] > tx)
60
- const xflag1 = (vtx1[0] > tx)
61
- if (xflag0 && xflag1) {
58
+ const xFlag0 = (vtx0[0] > tx)
59
+ const xFlag1 = (vtx1[0] > tx)
60
+ if (xFlag0 && xFlag1) {
62
61
  /* if edge's X values are both right of the point, then the point must be inside */
63
62
  insideFlag = !insideFlag
64
63
  } else {
65
64
  /*
66
65
  * if X endpoints straddle the point, then
67
- * the compute intersection of polygon edge with +X ray
66
+ * compute the intersection of polygon edge with +X ray
68
67
  * if intersection >= point's X then the +X ray hits it.
69
68
  */
70
69
  if ((vtx1[0] - (vtx1[1] - ty) * (vtx0[0] - vtx1[0]) / (vtx0[1] - vtx1[1])) >= tx) {
@@ -72,19 +71,10 @@ const isPointInside = (point, polygon) => {
72
71
  }
73
72
  }
74
73
  }
75
- /* move to next pair of vertices, retaining info as possible */
76
- yflag0 = yflag1
74
+ /* move to next pair of points, retaining info as possible */
75
+ yFlag0 = yFlag1
77
76
  vtx0 = vtx1
78
77
  vtx1 = polygon[++i]
79
78
  }
80
79
  return insideFlag
81
80
  }
82
-
83
- /*
84
- * > 0 : p2 is left of the line p0 -> p1
85
- * = 0 : p2 is on the line p0 -> p1
86
- * < 0 : p2 is right of the line p0 -> p1
87
- */
88
- const isLeft = (p0, p1, p2) => (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p2[0] - p0[0]) * (p1[1] - p0[1])
89
-
90
- module.exports = arePointsInside
@@ -1,6 +1,6 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { arePointsInside, create } = require('./index')
3
+ import { arePointsInside, create } from './index.js'
4
4
 
5
5
  test('poly2: arePointsInside() should return proper values', (t) => {
6
6
  let polygon = create()
@@ -0,0 +1,3 @@
1
+ import type { Poly2 } from './type.d.ts'
2
+
3
+ export function clone(polygon: Poly2): Poly2
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Create a shallow clone of the given polygon.
3
+ *
4
+ * @param {Poly2} polygon - polygon to clone
5
+ * @returns {Poly2} a new polygon
6
+ * @alias module:modeling/geometries/poly2.clone
7
+ */
8
+ export const clone = (polygon) => Object.assign({}, polygon)