@jbroll/jscad-modeling 2.12.7

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 (1097) hide show
  1. package/.claude/settings.local.json +30 -0
  2. package/CHANGELOG.md +888 -0
  3. package/CLAUDE.md +135 -0
  4. package/README.md +99 -0
  5. package/benchmarks/booleans.bench.js +100 -0
  6. package/benchmarks/extrusions.bench.js +124 -0
  7. package/benchmarks/measurements.bench.js +123 -0
  8. package/benchmarks/run.js +145 -0
  9. package/benchmarks/transforms.bench.js +106 -0
  10. package/benchmarks/utils.bench.js +89 -0
  11. package/dist/jscad-modeling.min.js +1214 -0
  12. package/package.json +66 -0
  13. package/src/colors/colorNameToRgb.d.ts +5 -0
  14. package/src/colors/colorNameToRgb.js +14 -0
  15. package/src/colors/colorNameToRgb.test.js +14 -0
  16. package/src/colors/colorize.d.ts +14 -0
  17. package/src/colors/colorize.js +65 -0
  18. package/src/colors/colorize.test.js +72 -0
  19. package/src/colors/cssColors.d.ts +149 -0
  20. package/src/colors/cssColors.js +176 -0
  21. package/src/colors/hexToRgb.d.ts +5 -0
  22. package/src/colors/hexToRgb.js +26 -0
  23. package/src/colors/hexToRgb.test.js +37 -0
  24. package/src/colors/hslToRgb.d.ts +8 -0
  25. package/src/colors/hslToRgb.js +44 -0
  26. package/src/colors/hslToRgb.test.js +37 -0
  27. package/src/colors/hsvToRgb.d.ts +8 -0
  28. package/src/colors/hsvToRgb.js +73 -0
  29. package/src/colors/hsvToRgb.test.js +27 -0
  30. package/src/colors/hueToColorComponent.d.ts +3 -0
  31. package/src/colors/hueToColorComponent.js +18 -0
  32. package/src/colors/index.d.ts +13 -0
  33. package/src/colors/index.js +19 -0
  34. package/src/colors/rgbToHex.d.ts +6 -0
  35. package/src/colors/rgbToHex.js +27 -0
  36. package/src/colors/rgbToHex.test.js +15 -0
  37. package/src/colors/rgbToHsl.d.ts +8 -0
  38. package/src/colors/rgbToHsl.js +53 -0
  39. package/src/colors/rgbToHsl.test.js +35 -0
  40. package/src/colors/rgbToHsv.d.ts +8 -0
  41. package/src/colors/rgbToHsv.js +52 -0
  42. package/src/colors/rgbToHsv.test.js +40 -0
  43. package/src/colors/types.d.ts +6 -0
  44. package/src/connectors/create.js +23 -0
  45. package/src/connectors/create.test.js +17 -0
  46. package/src/connectors/extends.js +15 -0
  47. package/src/connectors/fromPointAxisNormal.js +21 -0
  48. package/src/connectors/fromPointAxisNormal.test.js +22 -0
  49. package/src/connectors/index.js +12 -0
  50. package/src/connectors/normalize.js +20 -0
  51. package/src/connectors/toString.js +15 -0
  52. package/src/connectors/transform.js +28 -0
  53. package/src/connectors/transform.test.js +106 -0
  54. package/src/connectors/transformationBetween.js +68 -0
  55. package/src/connectors/transformationBetween.test.js +40 -0
  56. package/src/curves/bezier/arcLengthToT.d.ts +10 -0
  57. package/src/curves/bezier/arcLengthToT.js +63 -0
  58. package/src/curves/bezier/arcLengthToT.test.js +79 -0
  59. package/src/curves/bezier/create.d.ts +5 -0
  60. package/src/curves/bezier/create.js +81 -0
  61. package/src/curves/bezier/create.test.js +60 -0
  62. package/src/curves/bezier/index.d.ts +9 -0
  63. package/src/curves/bezier/index.js +13 -0
  64. package/src/curves/bezier/length.d.ts +5 -0
  65. package/src/curves/bezier/length.js +18 -0
  66. package/src/curves/bezier/length.test.js +54 -0
  67. package/src/curves/bezier/lengths.d.ts +5 -0
  68. package/src/curves/bezier/lengths.js +56 -0
  69. package/src/curves/bezier/lengths.test.js +78 -0
  70. package/src/curves/bezier/tangentAt.d.ts +5 -0
  71. package/src/curves/bezier/tangentAt.js +45 -0
  72. package/src/curves/bezier/tangentAt.test.js +63 -0
  73. package/src/curves/bezier/type.d.ts +9 -0
  74. package/src/curves/bezier/valueAt.d.ts +5 -0
  75. package/src/curves/bezier/valueAt.js +44 -0
  76. package/src/curves/bezier/valueAt.test.js +63 -0
  77. package/src/curves/index.d.ts +3 -0
  78. package/src/curves/index.js +9 -0
  79. package/src/geometries/geom2/applyTransforms.js +26 -0
  80. package/src/geometries/geom2/applyTransforms.test.js +21 -0
  81. package/src/geometries/geom2/clone.d.ts +5 -0
  82. package/src/geometries/geom2/clone.js +9 -0
  83. package/src/geometries/geom2/clone.test.js +26 -0
  84. package/src/geometries/geom2/create.d.ts +6 -0
  85. package/src/geometries/geom2/create.js +26 -0
  86. package/src/geometries/geom2/create.test.js +20 -0
  87. package/src/geometries/geom2/fromCompactBinary.d.ts +5 -0
  88. package/src/geometries/geom2/fromCompactBinary.js +32 -0
  89. package/src/geometries/geom2/fromPoints.d.ts +6 -0
  90. package/src/geometries/geom2/fromPoints.js +35 -0
  91. package/src/geometries/geom2/fromPoints.test.js +22 -0
  92. package/src/geometries/geom2/fromToCompactBinary.test.js +122 -0
  93. package/src/geometries/geom2/index.d.ts +16 -0
  94. package/src/geometries/geom2/index.js +30 -0
  95. package/src/geometries/geom2/isA.d.ts +5 -0
  96. package/src/geometries/geom2/isA.js +18 -0
  97. package/src/geometries/geom2/isA.test.js +19 -0
  98. package/src/geometries/geom2/reverse.d.ts +5 -0
  99. package/src/geometries/geom2/reverse.js +22 -0
  100. package/src/geometries/geom2/reverse.test.js +20 -0
  101. package/src/geometries/geom2/toCompactBinary.d.ts +5 -0
  102. package/src/geometries/geom2/toCompactBinary.js +53 -0
  103. package/src/geometries/geom2/toOutlines.d.ts +6 -0
  104. package/src/geometries/geom2/toOutlines.js +119 -0
  105. package/src/geometries/geom2/toOutlines.test.js +122 -0
  106. package/src/geometries/geom2/toPoints.d.ts +6 -0
  107. package/src/geometries/geom2/toPoints.js +25 -0
  108. package/src/geometries/geom2/toPoints.test.js +24 -0
  109. package/src/geometries/geom2/toSides.d.ts +6 -0
  110. package/src/geometries/geom2/toSides.js +16 -0
  111. package/src/geometries/geom2/toString.d.ts +5 -0
  112. package/src/geometries/geom2/toString.js +24 -0
  113. package/src/geometries/geom2/transform.d.ts +6 -0
  114. package/src/geometries/geom2/transform.js +28 -0
  115. package/src/geometries/geom2/transform.test.js +110 -0
  116. package/src/geometries/geom2/type.d.ts +11 -0
  117. package/src/geometries/geom2/validate.d.ts +3 -0
  118. package/src/geometries/geom2/validate.js +36 -0
  119. package/src/geometries/geom3/applyTransforms.js +23 -0
  120. package/src/geometries/geom3/applyTransforms.test.js +28 -0
  121. package/src/geometries/geom3/clone.d.ts +5 -0
  122. package/src/geometries/geom3/clone.js +9 -0
  123. package/src/geometries/geom3/clone.test.js +31 -0
  124. package/src/geometries/geom3/create.d.ts +6 -0
  125. package/src/geometries/geom3/create.js +26 -0
  126. package/src/geometries/geom3/create.test.js +25 -0
  127. package/src/geometries/geom3/fromCompactBinary.d.ts +5 -0
  128. package/src/geometries/geom3/fromCompactBinary.js +44 -0
  129. package/src/geometries/geom3/fromPoints.d.ts +6 -0
  130. package/src/geometries/geom3/fromPoints.js +28 -0
  131. package/src/geometries/geom3/fromPoints.test.js +24 -0
  132. package/src/geometries/geom3/fromPointsConvex.d.ts +6 -0
  133. package/src/geometries/geom3/fromPointsConvex.js +26 -0
  134. package/src/geometries/geom3/fromPointsConvex.test.js +31 -0
  135. package/src/geometries/geom3/fromToCompactBinary.test.js +139 -0
  136. package/src/geometries/geom3/index.d.ts +16 -0
  137. package/src/geometries/geom3/index.js +37 -0
  138. package/src/geometries/geom3/invert.d.ts +5 -0
  139. package/src/geometries/geom3/invert.js +18 -0
  140. package/src/geometries/geom3/invert.test.js +31 -0
  141. package/src/geometries/geom3/isA.d.ts +5 -0
  142. package/src/geometries/geom3/isA.js +18 -0
  143. package/src/geometries/geom3/isA.test.js +19 -0
  144. package/src/geometries/geom3/toCompactBinary.d.ts +5 -0
  145. package/src/geometries/geom3/toCompactBinary.js +68 -0
  146. package/src/geometries/geom3/toPoints.d.ts +6 -0
  147. package/src/geometries/geom3/toPoints.js +18 -0
  148. package/src/geometries/geom3/toPoints.test.js +19 -0
  149. package/src/geometries/geom3/toPolygons.d.ts +6 -0
  150. package/src/geometries/geom3/toPolygons.js +15 -0
  151. package/src/geometries/geom3/toString.d.ts +5 -0
  152. package/src/geometries/geom3/toString.js +23 -0
  153. package/src/geometries/geom3/transform.d.ts +6 -0
  154. package/src/geometries/geom3/transform.js +20 -0
  155. package/src/geometries/geom3/transform.test.js +49 -0
  156. package/src/geometries/geom3/type.d.ts +11 -0
  157. package/src/geometries/geom3/validate.d.ts +3 -0
  158. package/src/geometries/geom3/validate.js +62 -0
  159. package/src/geometries/index.d.ts +7 -0
  160. package/src/geometries/index.js +21 -0
  161. package/src/geometries/path2/appendArc.d.ts +15 -0
  162. package/src/geometries/path2/appendArc.js +142 -0
  163. package/src/geometries/path2/appendArc.test.js +88 -0
  164. package/src/geometries/path2/appendBezier.d.ts +11 -0
  165. package/src/geometries/path2/appendBezier.js +156 -0
  166. package/src/geometries/path2/appendBezier.test.js +36 -0
  167. package/src/geometries/path2/appendPoints.d.ts +6 -0
  168. package/src/geometries/path2/appendPoints.js +15 -0
  169. package/src/geometries/path2/appendPoints.test.js +35 -0
  170. package/src/geometries/path2/applyTransforms.js +20 -0
  171. package/src/geometries/path2/applyTransforms.test.js +28 -0
  172. package/src/geometries/path2/clone.d.ts +5 -0
  173. package/src/geometries/path2/clone.js +9 -0
  174. package/src/geometries/path2/close.d.ts +5 -0
  175. package/src/geometries/path2/close.js +33 -0
  176. package/src/geometries/path2/close.test.js +43 -0
  177. package/src/geometries/path2/concat.d.ts +5 -0
  178. package/src/geometries/path2/concat.js +36 -0
  179. package/src/geometries/path2/concat.test.js +35 -0
  180. package/src/geometries/path2/create.d.ts +6 -0
  181. package/src/geometries/path2/create.js +30 -0
  182. package/src/geometries/path2/create.test.js +7 -0
  183. package/src/geometries/path2/equals.d.ts +5 -0
  184. package/src/geometries/path2/equals.js +47 -0
  185. package/src/geometries/path2/equals.test.js +38 -0
  186. package/src/geometries/path2/fromCompactBinary.d.ts +5 -0
  187. package/src/geometries/path2/fromCompactBinary.js +33 -0
  188. package/src/geometries/path2/fromPoints.d.ts +10 -0
  189. package/src/geometries/path2/fromPoints.js +42 -0
  190. package/src/geometries/path2/fromPoints.test.js +33 -0
  191. package/src/geometries/path2/fromToCompactBinary.test.js +114 -0
  192. package/src/geometries/path2/index.d.ts +20 -0
  193. package/src/geometries/path2/index.js +35 -0
  194. package/src/geometries/path2/isA.d.ts +5 -0
  195. package/src/geometries/path2/isA.js +20 -0
  196. package/src/geometries/path2/isA.test.js +19 -0
  197. package/src/geometries/path2/reverse.d.ts +5 -0
  198. package/src/geometries/path2/reverse.js +20 -0
  199. package/src/geometries/path2/reverse.test.js +9 -0
  200. package/src/geometries/path2/toCompactBinary.d.ts +5 -0
  201. package/src/geometries/path2/toCompactBinary.js +52 -0
  202. package/src/geometries/path2/toPoints.d.ts +6 -0
  203. package/src/geometries/path2/toPoints.js +15 -0
  204. package/src/geometries/path2/toPoints.test.js +13 -0
  205. package/src/geometries/path2/toString.d.ts +5 -0
  206. package/src/geometries/path2/toString.js +24 -0
  207. package/src/geometries/path2/transform.d.ts +6 -0
  208. package/src/geometries/path2/transform.js +20 -0
  209. package/src/geometries/path2/transform.test.js +50 -0
  210. package/src/geometries/path2/type.d.ts +12 -0
  211. package/src/geometries/path2/validate.d.ts +3 -0
  212. package/src/geometries/path2/validate.js +41 -0
  213. package/src/geometries/poly2/arePointsInside.d.ts +6 -0
  214. package/src/geometries/poly2/arePointsInside.js +83 -0
  215. package/src/geometries/poly2/arePointsInside.test.js +77 -0
  216. package/src/geometries/poly2/create.d.ts +6 -0
  217. package/src/geometries/poly2/create.js +24 -0
  218. package/src/geometries/poly2/create.test.js +13 -0
  219. package/src/geometries/poly2/flip.d.ts +5 -0
  220. package/src/geometries/poly2/flip.js +15 -0
  221. package/src/geometries/poly2/index.d.ts +7 -0
  222. package/src/geometries/poly2/index.js +17 -0
  223. package/src/geometries/poly2/measureArea.d.ts +5 -0
  224. package/src/geometries/poly2/measureArea.js +12 -0
  225. package/src/geometries/poly2/measureArea.test.js +44 -0
  226. package/src/geometries/poly2/type.d.ts +7 -0
  227. package/src/geometries/poly3/clone.d.ts +6 -0
  228. package/src/geometries/poly3/clone.js +28 -0
  229. package/src/geometries/poly3/clone.test.js +35 -0
  230. package/src/geometries/poly3/create.d.ts +6 -0
  231. package/src/geometries/poly3/create.js +24 -0
  232. package/src/geometries/poly3/create.test.js +9 -0
  233. package/src/geometries/poly3/fromPoints.d.ts +6 -0
  234. package/src/geometries/poly3/fromPoints.js +25 -0
  235. package/src/geometries/poly3/fromPoints.test.js +15 -0
  236. package/src/geometries/poly3/fromPointsAndPlane.d.ts +7 -0
  237. package/src/geometries/poly3/fromPointsAndPlane.js +17 -0
  238. package/src/geometries/poly3/index.d.ts +19 -0
  239. package/src/geometries/poly3/index.js +29 -0
  240. package/src/geometries/poly3/invert.d.ts +5 -0
  241. package/src/geometries/poly3/invert.js +21 -0
  242. package/src/geometries/poly3/invert.test.js +18 -0
  243. package/src/geometries/poly3/isA.d.ts +5 -0
  244. package/src/geometries/poly3/isA.js +18 -0
  245. package/src/geometries/poly3/isA.test.js +19 -0
  246. package/src/geometries/poly3/isConvex.d.ts +5 -0
  247. package/src/geometries/poly3/isConvex.js +44 -0
  248. package/src/geometries/poly3/isConvex.test.js +24 -0
  249. package/src/geometries/poly3/measureArea.d.ts +5 -0
  250. package/src/geometries/poly3/measureArea.js +83 -0
  251. package/src/geometries/poly3/measureArea.test.js +111 -0
  252. package/src/geometries/poly3/measureBoundingBox.d.ts +6 -0
  253. package/src/geometries/poly3/measureBoundingBox.js +20 -0
  254. package/src/geometries/poly3/measureBoundingBox.test.js +70 -0
  255. package/src/geometries/poly3/measureBoundingSphere.d.ts +6 -0
  256. package/src/geometries/poly3/measureBoundingSphere.js +56 -0
  257. package/src/geometries/poly3/measureBoundingSphere.test.js +60 -0
  258. package/src/geometries/poly3/measureSignedVolume.d.ts +5 -0
  259. package/src/geometries/poly3/measureSignedVolume.js +25 -0
  260. package/src/geometries/poly3/measureSignedVolume.test.js +68 -0
  261. package/src/geometries/poly3/plane.d.ts +6 -0
  262. package/src/geometries/poly3/plane.js +10 -0
  263. package/src/geometries/poly3/toPoints.d.ts +6 -0
  264. package/src/geometries/poly3/toPoints.js +10 -0
  265. package/src/geometries/poly3/toString.d.ts +5 -0
  266. package/src/geometries/poly3/toString.js +17 -0
  267. package/src/geometries/poly3/transform.d.ts +6 -0
  268. package/src/geometries/poly3/transform.js +22 -0
  269. package/src/geometries/poly3/transform.test.js +62 -0
  270. package/src/geometries/poly3/type.d.ts +11 -0
  271. package/src/geometries/poly3/validate.d.ts +4 -0
  272. package/src/geometries/poly3/validate.js +64 -0
  273. package/src/geometries/types.d.ts +21 -0
  274. package/src/index.d.ts +17 -0
  275. package/src/index.js +17 -0
  276. package/src/index.test-d.ts +26 -0
  277. package/src/maths/OrthoNormalBasis.js +59 -0
  278. package/src/maths/constants.d.ts +3 -0
  279. package/src/maths/constants.js +41 -0
  280. package/src/maths/index.d.ts +11 -0
  281. package/src/maths/index.js +19 -0
  282. package/src/maths/line2/clone.d.ts +5 -0
  283. package/src/maths/line2/clone.js +18 -0
  284. package/src/maths/line2/clone.test.js +21 -0
  285. package/src/maths/line2/closestPoint.d.ts +6 -0
  286. package/src/maths/line2/closestPoint.js +25 -0
  287. package/src/maths/line2/closestPoint.test.js +48 -0
  288. package/src/maths/line2/copy.d.ts +5 -0
  289. package/src/maths/line2/copy.js +16 -0
  290. package/src/maths/line2/copy.test.js +27 -0
  291. package/src/maths/line2/create.d.ts +5 -0
  292. package/src/maths/line2/create.js +20 -0
  293. package/src/maths/line2/create.test.js +10 -0
  294. package/src/maths/line2/direction.d.ts +6 -0
  295. package/src/maths/line2/direction.js +16 -0
  296. package/src/maths/line2/direction.test.js +31 -0
  297. package/src/maths/line2/distanceToPoint.d.ts +6 -0
  298. package/src/maths/line2/distanceToPoint.js +17 -0
  299. package/src/maths/line2/distanceToPoint.test.js +31 -0
  300. package/src/maths/line2/equals.d.ts +5 -0
  301. package/src/maths/line2/equals.js +11 -0
  302. package/src/maths/line2/equals.test.js +26 -0
  303. package/src/maths/line2/fromPoints.d.ts +6 -0
  304. package/src/maths/line2/fromPoints.js +26 -0
  305. package/src/maths/line2/fromPoints.test.js +24 -0
  306. package/src/maths/line2/fromValues.d.ts +5 -0
  307. package/src/maths/line2/fromValues.js +20 -0
  308. package/src/maths/line2/fromValues.test.js +12 -0
  309. package/src/maths/line2/index.d.ts +18 -0
  310. package/src/maths/line2/index.js +22 -0
  311. package/src/maths/line2/intersectPointOfLines.d.ts +6 -0
  312. package/src/maths/line2/intersectPointOfLines.js +21 -0
  313. package/src/maths/line2/intersectPointOfLines.test.js +31 -0
  314. package/src/maths/line2/origin.d.ts +6 -0
  315. package/src/maths/line2/origin.js +13 -0
  316. package/src/maths/line2/origin.test.js +30 -0
  317. package/src/maths/line2/reverse.d.ts +5 -0
  318. package/src/maths/line2/reverse.js +20 -0
  319. package/src/maths/line2/reverse.test.js +36 -0
  320. package/src/maths/line2/toString.d.ts +5 -0
  321. package/src/maths/line2/toString.js +10 -0
  322. package/src/maths/line2/transform.d.ts +6 -0
  323. package/src/maths/line2/transform.js +26 -0
  324. package/src/maths/line2/transform.test.js +89 -0
  325. package/src/maths/line2/type.d.ts +3 -0
  326. package/src/maths/line2/xAtY.d.ts +5 -0
  327. package/src/maths/line2/xAtY.js +22 -0
  328. package/src/maths/line2/xAtY.test.js +39 -0
  329. package/src/maths/line3/clone.d.ts +5 -0
  330. package/src/maths/line3/clone.js +19 -0
  331. package/src/maths/line3/clone.test.js +24 -0
  332. package/src/maths/line3/closestPoint.d.ts +6 -0
  333. package/src/maths/line3/closestPoint.js +24 -0
  334. package/src/maths/line3/closestPoint.test.js +37 -0
  335. package/src/maths/line3/copy.d.ts +5 -0
  336. package/src/maths/line3/copy.js +17 -0
  337. package/src/maths/line3/copy.test.js +33 -0
  338. package/src/maths/line3/create.d.ts +5 -0
  339. package/src/maths/line3/create.js +23 -0
  340. package/src/maths/line3/create.test.js +11 -0
  341. package/src/maths/line3/direction.d.ts +6 -0
  342. package/src/maths/line3/direction.js +10 -0
  343. package/src/maths/line3/direction.test.js +26 -0
  344. package/src/maths/line3/distanceToPoint.d.ts +6 -0
  345. package/src/maths/line3/distanceToPoint.js +19 -0
  346. package/src/maths/line3/distanceToPoint.test.js +31 -0
  347. package/src/maths/line3/equals.d.ts +5 -0
  348. package/src/maths/line3/equals.js +25 -0
  349. package/src/maths/line3/equals.test.js +17 -0
  350. package/src/maths/line3/fromPlanes.d.ts +6 -0
  351. package/src/maths/line3/fromPlanes.js +47 -0
  352. package/src/maths/line3/fromPlanes.test.js +38 -0
  353. package/src/maths/line3/fromPointAndDirection.d.ts +6 -0
  354. package/src/maths/line3/fromPointAndDirection.js +25 -0
  355. package/src/maths/line3/fromPointAndDirection.test.js +37 -0
  356. package/src/maths/line3/fromPoints.d.ts +6 -0
  357. package/src/maths/line3/fromPoints.js +19 -0
  358. package/src/maths/line3/fromPoints.test.js +37 -0
  359. package/src/maths/line3/index.d.ts +18 -0
  360. package/src/maths/line3/index.js +22 -0
  361. package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +7 -0
  362. package/src/maths/line3/intersectPointOfLineAndPlane.js +29 -0
  363. package/src/maths/line3/intersectPointOfLineAndPlane.test.js +29 -0
  364. package/src/maths/line3/origin.d.ts +6 -0
  365. package/src/maths/line3/origin.js +10 -0
  366. package/src/maths/line3/origin.test.js +26 -0
  367. package/src/maths/line3/reverse.d.ts +5 -0
  368. package/src/maths/line3/reverse.js +19 -0
  369. package/src/maths/line3/reverse.test.js +33 -0
  370. package/src/maths/line3/toString.d.ts +5 -0
  371. package/src/maths/line3/toString.js +14 -0
  372. package/src/maths/line3/transform.d.ts +6 -0
  373. package/src/maths/line3/transform.js +26 -0
  374. package/src/maths/line3/transform.test.js +66 -0
  375. package/src/maths/line3/type.d.ts +5 -0
  376. package/src/maths/mat4/add.d.ts +5 -0
  377. package/src/maths/mat4/add.js +30 -0
  378. package/src/maths/mat4/add.test.js +27 -0
  379. package/src/maths/mat4/clone.d.ts +5 -0
  380. package/src/maths/mat4/clone.js +31 -0
  381. package/src/maths/mat4/clone.test.js +21 -0
  382. package/src/maths/mat4/copy.d.ts +5 -0
  383. package/src/maths/mat4/copy.js +29 -0
  384. package/src/maths/mat4/copy.test.js +30 -0
  385. package/src/maths/mat4/create.d.ts +5 -0
  386. package/src/maths/mat4/create.js +20 -0
  387. package/src/maths/mat4/create.test.js +10 -0
  388. package/src/maths/mat4/equals.d.ts +5 -0
  389. package/src/maths/mat4/equals.js +16 -0
  390. package/src/maths/mat4/equals.test.js +56 -0
  391. package/src/maths/mat4/fromRotation.d.ts +6 -0
  392. package/src/maths/mat4/fromRotation.js +60 -0
  393. package/src/maths/mat4/fromRotation.test.js +18 -0
  394. package/src/maths/mat4/fromScaling.d.ts +6 -0
  395. package/src/maths/mat4/fromScaling.js +35 -0
  396. package/src/maths/mat4/fromScaling.test.js +12 -0
  397. package/src/maths/mat4/fromTaitBryanRotation.d.ts +5 -0
  398. package/src/maths/mat4/fromTaitBryanRotation.js +55 -0
  399. package/src/maths/mat4/fromTaitBryanRotation.test.js +24 -0
  400. package/src/maths/mat4/fromTranslation.d.ts +6 -0
  401. package/src/maths/mat4/fromTranslation.js +35 -0
  402. package/src/maths/mat4/fromTranslation.test.js +12 -0
  403. package/src/maths/mat4/fromValues.d.ts +5 -0
  404. package/src/maths/mat4/fromValues.js +53 -0
  405. package/src/maths/mat4/fromValues.test.js +12 -0
  406. package/src/maths/mat4/fromVectorRotation.d.ts +6 -0
  407. package/src/maths/mat4/fromVectorRotation.js +49 -0
  408. package/src/maths/mat4/fromVectorRotation.test.js +127 -0
  409. package/src/maths/mat4/fromXRotation.d.ts +5 -0
  410. package/src/maths/mat4/fromXRotation.js +41 -0
  411. package/src/maths/mat4/fromXRotation.test.js +14 -0
  412. package/src/maths/mat4/fromYRotation.d.ts +5 -0
  413. package/src/maths/mat4/fromYRotation.js +41 -0
  414. package/src/maths/mat4/fromYRotation.test.js +14 -0
  415. package/src/maths/mat4/fromZRotation.d.ts +5 -0
  416. package/src/maths/mat4/fromZRotation.js +41 -0
  417. package/src/maths/mat4/fromZRotation.test.js +14 -0
  418. package/src/maths/mat4/identity.d.ts +5 -0
  419. package/src/maths/mat4/identity.js +28 -0
  420. package/src/maths/mat4/identity.test.js +12 -0
  421. package/src/maths/mat4/index.d.ts +29 -0
  422. package/src/maths/mat4/index.js +36 -0
  423. package/src/maths/mat4/invert.js +71 -0
  424. package/src/maths/mat4/invert.test.js +32 -0
  425. package/src/maths/mat4/isIdentity.d.ts +5 -0
  426. package/src/maths/mat4/isIdentity.js +20 -0
  427. package/src/maths/mat4/isIdentity.test.js +11 -0
  428. package/src/maths/mat4/isMirroring.d.ts +5 -0
  429. package/src/maths/mat4/isMirroring.js +24 -0
  430. package/src/maths/mat4/isMirroring.test.js +37 -0
  431. package/src/maths/mat4/isOnlyTransformScale.js +22 -0
  432. package/src/maths/mat4/isOnlyTransformScale.test.js +29 -0
  433. package/src/maths/mat4/leftMultiplyVec2.d.ts +6 -0
  434. package/src/maths/mat4/leftMultiplyVec2.js +28 -0
  435. package/src/maths/mat4/leftMultiplyVec3.d.ts +6 -0
  436. package/src/maths/mat4/leftMultiplyVec3.js +29 -0
  437. package/src/maths/mat4/mirror.d.ts +6 -0
  438. package/src/maths/mat4/mirror.js +34 -0
  439. package/src/maths/mat4/mirrorByPlane.d.ts +6 -0
  440. package/src/maths/mat4/mirrorByPlane.js +32 -0
  441. package/src/maths/mat4/mirrorByPlane.test.js +28 -0
  442. package/src/maths/mat4/multiply.d.ts +5 -0
  443. package/src/maths/mat4/multiply.js +67 -0
  444. package/src/maths/mat4/multiply.test.js +28 -0
  445. package/src/maths/mat4/rightMultiplyVec2.d.ts +6 -0
  446. package/src/maths/mat4/rightMultiplyVec2.js +29 -0
  447. package/src/maths/mat4/rightMultiplyVec3.d.ts +6 -0
  448. package/src/maths/mat4/rightMultiplyVec3.js +30 -0
  449. package/src/maths/mat4/rotate.d.ts +6 -0
  450. package/src/maths/mat4/rotate.js +82 -0
  451. package/src/maths/mat4/rotate.test.js +27 -0
  452. package/src/maths/mat4/rotateX.d.ts +5 -0
  453. package/src/maths/mat4/rotateX.js +47 -0
  454. package/src/maths/mat4/rotateX.test.js +21 -0
  455. package/src/maths/mat4/rotateY.d.ts +5 -0
  456. package/src/maths/mat4/rotateY.js +47 -0
  457. package/src/maths/mat4/rotateY.test.js +21 -0
  458. package/src/maths/mat4/rotateZ.d.ts +5 -0
  459. package/src/maths/mat4/rotateZ.js +47 -0
  460. package/src/maths/mat4/rotateZ.test.js +21 -0
  461. package/src/maths/mat4/scale.d.ts +6 -0
  462. package/src/maths/mat4/scale.js +34 -0
  463. package/src/maths/mat4/scale.test.js +21 -0
  464. package/src/maths/mat4/subtract.d.ts +5 -0
  465. package/src/maths/mat4/subtract.js +30 -0
  466. package/src/maths/mat4/subtract.test.js +27 -0
  467. package/src/maths/mat4/toString.d.ts +5 -0
  468. package/src/maths/mat4/toString.js +10 -0
  469. package/src/maths/mat4/translate.d.ts +6 -0
  470. package/src/maths/mat4/translate.js +51 -0
  471. package/src/maths/mat4/translate.test.js +72 -0
  472. package/src/maths/mat4/type.d.ts +8 -0
  473. package/src/maths/plane/clone.d.ts +5 -0
  474. package/src/maths/plane/clone.test.js +24 -0
  475. package/src/maths/plane/copy.d.ts +5 -0
  476. package/src/maths/plane/copy.test.js +30 -0
  477. package/src/maths/plane/create.d.ts +5 -0
  478. package/src/maths/plane/create.test.js +10 -0
  479. package/src/maths/plane/equals.d.ts +5 -0
  480. package/src/maths/plane/equals.test.js +17 -0
  481. package/src/maths/plane/flip.d.ts +5 -0
  482. package/src/maths/plane/flip.js +17 -0
  483. package/src/maths/plane/flip.test.js +26 -0
  484. package/src/maths/plane/fromNoisyPoints.d.ts +6 -0
  485. package/src/maths/plane/fromNoisyPoints.js +106 -0
  486. package/src/maths/plane/fromNoisyPoints.test.js +24 -0
  487. package/src/maths/plane/fromNormalAndPoint.d.ts +6 -0
  488. package/src/maths/plane/fromNormalAndPoint.js +32 -0
  489. package/src/maths/plane/fromNormalAndPoint.test.js +12 -0
  490. package/src/maths/plane/fromPoints.d.ts +6 -0
  491. package/src/maths/plane/fromPoints.js +47 -0
  492. package/src/maths/plane/fromPoints.test.js +20 -0
  493. package/src/maths/plane/fromPointsRandom.d.ts +6 -0
  494. package/src/maths/plane/fromPointsRandom.js +42 -0
  495. package/src/maths/plane/fromValues.d.ts +5 -0
  496. package/src/maths/plane/index.d.ts +17 -0
  497. package/src/maths/plane/index.js +46 -0
  498. package/src/maths/plane/projectionOfPoint.d.ts +6 -0
  499. package/src/maths/plane/projectionOfPoint.js +19 -0
  500. package/src/maths/plane/projectionOfPoint.test.js +43 -0
  501. package/src/maths/plane/signedDistanceToPoint.d.ts +6 -0
  502. package/src/maths/plane/signedDistanceToPoint.js +13 -0
  503. package/src/maths/plane/signedDistanceToPoint.test.js +20 -0
  504. package/src/maths/plane/toString.d.ts +5 -0
  505. package/src/maths/plane/transform.d.ts +6 -0
  506. package/src/maths/plane/transform.js +40 -0
  507. package/src/maths/plane/transform.test.js +72 -0
  508. package/src/maths/plane/type.d.ts +3 -0
  509. package/src/maths/rotation.test.js +131 -0
  510. package/src/maths/types.d.ts +8 -0
  511. package/src/maths/utils/aboutEqualNormals.d.ts +5 -0
  512. package/src/maths/utils/aboutEqualNormals.js +12 -0
  513. package/src/maths/utils/area.d.ts +5 -0
  514. package/src/maths/utils/area.js +17 -0
  515. package/src/maths/utils/index.d.ts +8 -0
  516. package/src/maths/utils/index.js +15 -0
  517. package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +5 -0
  518. package/src/maths/utils/interpolateBetween2DPointsForY.js +31 -0
  519. package/src/maths/utils/intersect.d.ts +5 -0
  520. package/src/maths/utils/intersect.js +40 -0
  521. package/src/maths/utils/solve2Linear.d.ts +5 -0
  522. package/src/maths/utils/solve2Linear.js +11 -0
  523. package/src/maths/utils/trigonometry.d.ts +2 -0
  524. package/src/maths/utils/trigonometry.js +34 -0
  525. package/src/maths/utils/trigonometry.test.js +27 -0
  526. package/src/maths/vec1/type.d.ts +3 -0
  527. package/src/maths/vec2/abs.d.ts +5 -0
  528. package/src/maths/vec2/abs.js +15 -0
  529. package/src/maths/vec2/abs.test.js +24 -0
  530. package/src/maths/vec2/add.d.ts +5 -0
  531. package/src/maths/vec2/add.js +16 -0
  532. package/src/maths/vec2/add.test.js +26 -0
  533. package/src/maths/vec2/angle.d.ts +3 -0
  534. package/src/maths/vec2/angle.js +1 -0
  535. package/src/maths/vec2/angleDegrees.d.ts +5 -0
  536. package/src/maths/vec2/angleDegrees.js +12 -0
  537. package/src/maths/vec2/angleDegrees.test.js +24 -0
  538. package/src/maths/vec2/angleRadians.d.ts +5 -0
  539. package/src/maths/vec2/angleRadians.js +10 -0
  540. package/src/maths/vec2/angleRadians.test.js +24 -0
  541. package/src/maths/vec2/clone.d.ts +5 -0
  542. package/src/maths/vec2/clone.js +17 -0
  543. package/src/maths/vec2/clone.test.js +21 -0
  544. package/src/maths/vec2/copy.d.ts +5 -0
  545. package/src/maths/vec2/copy.js +15 -0
  546. package/src/maths/vec2/copy.test.js +30 -0
  547. package/src/maths/vec2/create.d.ts +5 -0
  548. package/src/maths/vec2/create.js +15 -0
  549. package/src/maths/vec2/create.test.js +10 -0
  550. package/src/maths/vec2/cross.d.ts +6 -0
  551. package/src/maths/vec2/cross.js +17 -0
  552. package/src/maths/vec2/cross.test.js +51 -0
  553. package/src/maths/vec2/distance.d.ts +5 -0
  554. package/src/maths/vec2/distance.js +15 -0
  555. package/src/maths/vec2/distance.test.js +30 -0
  556. package/src/maths/vec2/divide.d.ts +5 -0
  557. package/src/maths/vec2/divide.js +16 -0
  558. package/src/maths/vec2/divide.test.js +36 -0
  559. package/src/maths/vec2/dot.d.ts +5 -0
  560. package/src/maths/vec2/dot.js +11 -0
  561. package/src/maths/vec2/dot.test.js +24 -0
  562. package/src/maths/vec2/equals.d.ts +5 -0
  563. package/src/maths/vec2/equals.js +11 -0
  564. package/src/maths/vec2/equals.test.js +17 -0
  565. package/src/maths/vec2/fromAngleDegrees.d.ts +5 -0
  566. package/src/maths/vec2/fromAngleDegrees.js +13 -0
  567. package/src/maths/vec2/fromAngleDegrees.test.js +12 -0
  568. package/src/maths/vec2/fromAngleRadians.d.ts +5 -0
  569. package/src/maths/vec2/fromAngleRadians.js +17 -0
  570. package/src/maths/vec2/fromAngleRadians.test.js +15 -0
  571. package/src/maths/vec2/fromScalar.d.ts +5 -0
  572. package/src/maths/vec2/fromScalar.js +15 -0
  573. package/src/maths/vec2/fromScalar.test.js +12 -0
  574. package/src/maths/vec2/fromValues.d.ts +5 -0
  575. package/src/maths/vec2/fromValues.js +18 -0
  576. package/src/maths/vec2/index.d.ts +36 -0
  577. package/src/maths/vec2/index.js +39 -0
  578. package/src/maths/vec2/length.d.ts +5 -0
  579. package/src/maths/vec2/length.js +10 -0
  580. package/src/maths/vec2/length.test.js +29 -0
  581. package/src/maths/vec2/lerp.d.ts +5 -0
  582. package/src/maths/vec2/lerp.js +19 -0
  583. package/src/maths/vec2/lerp.test.js +26 -0
  584. package/src/maths/vec2/max.d.ts +5 -0
  585. package/src/maths/vec2/max.js +16 -0
  586. package/src/maths/vec2/max.test.js +31 -0
  587. package/src/maths/vec2/min.d.ts +5 -0
  588. package/src/maths/vec2/min.js +16 -0
  589. package/src/maths/vec2/min.test.js +31 -0
  590. package/src/maths/vec2/multiply.d.ts +5 -0
  591. package/src/maths/vec2/multiply.js +16 -0
  592. package/src/maths/vec2/multiply.test.js +36 -0
  593. package/src/maths/vec2/negate.d.ts +5 -0
  594. package/src/maths/vec2/negate.js +15 -0
  595. package/src/maths/vec2/negate.test.js +26 -0
  596. package/src/maths/vec2/normal.d.ts +5 -0
  597. package/src/maths/vec2/normal.js +17 -0
  598. package/src/maths/vec2/normal.test.js +30 -0
  599. package/src/maths/vec2/normalize.d.ts +5 -0
  600. package/src/maths/vec2/normalize.js +23 -0
  601. package/src/maths/vec2/normalize.test.js +36 -0
  602. package/src/maths/vec2/rotate.d.ts +5 -0
  603. package/src/maths/vec2/rotate.js +23 -0
  604. package/src/maths/vec2/rotate.test.js +31 -0
  605. package/src/maths/vec2/scale.d.ts +5 -0
  606. package/src/maths/vec2/scale.js +16 -0
  607. package/src/maths/vec2/scale.test.js +24 -0
  608. package/src/maths/vec2/snap.d.ts +5 -0
  609. package/src/maths/vec2/snap.js +16 -0
  610. package/src/maths/vec2/snap.test.js +32 -0
  611. package/src/maths/vec2/squaredDistance.d.ts +5 -0
  612. package/src/maths/vec2/squaredDistance.js +15 -0
  613. package/src/maths/vec2/squaredDistance.test.js +30 -0
  614. package/src/maths/vec2/squaredLength.d.ts +5 -0
  615. package/src/maths/vec2/squaredLength.js +14 -0
  616. package/src/maths/vec2/squaredLength.test.js +29 -0
  617. package/src/maths/vec2/subtract.d.ts +5 -0
  618. package/src/maths/vec2/subtract.js +16 -0
  619. package/src/maths/vec2/subtract.test.js +26 -0
  620. package/src/maths/vec2/toString.d.ts +5 -0
  621. package/src/maths/vec2/toString.js +10 -0
  622. package/src/maths/vec2/transform.d.ts +6 -0
  623. package/src/maths/vec2/transform.js +18 -0
  624. package/src/maths/vec2/transform.test.js +66 -0
  625. package/src/maths/vec2/type.d.ts +3 -0
  626. package/src/maths/vec3/abs.d.ts +5 -0
  627. package/src/maths/vec3/abs.js +16 -0
  628. package/src/maths/vec3/abs.test.js +24 -0
  629. package/src/maths/vec3/add.d.ts +5 -0
  630. package/src/maths/vec3/add.js +17 -0
  631. package/src/maths/vec3/add.test.js +26 -0
  632. package/src/maths/vec3/angle.d.ts +5 -0
  633. package/src/maths/vec3/angle.js +25 -0
  634. package/src/maths/vec3/angle.test.js +34 -0
  635. package/src/maths/vec3/clone.d.ts +5 -0
  636. package/src/maths/vec3/clone.js +18 -0
  637. package/src/maths/vec3/clone.test.js +21 -0
  638. package/src/maths/vec3/copy.d.ts +5 -0
  639. package/src/maths/vec3/copy.js +16 -0
  640. package/src/maths/vec3/copy.test.js +27 -0
  641. package/src/maths/vec3/create.d.ts +5 -0
  642. package/src/maths/vec3/create.js +15 -0
  643. package/src/maths/vec3/create.test.js +10 -0
  644. package/src/maths/vec3/cross.d.ts +5 -0
  645. package/src/maths/vec3/cross.js +24 -0
  646. package/src/maths/vec3/cross.test.js +51 -0
  647. package/src/maths/vec3/distance.d.ts +5 -0
  648. package/src/maths/vec3/distance.js +16 -0
  649. package/src/maths/vec3/distance.test.js +46 -0
  650. package/src/maths/vec3/divide.d.ts +5 -0
  651. package/src/maths/vec3/divide.js +17 -0
  652. package/src/maths/vec3/divide.test.js +36 -0
  653. package/src/maths/vec3/dot.d.ts +5 -0
  654. package/src/maths/vec3/dot.js +11 -0
  655. package/src/maths/vec3/dot.test.js +24 -0
  656. package/src/maths/vec3/equals.d.ts +5 -0
  657. package/src/maths/vec3/equals.js +11 -0
  658. package/src/maths/vec3/equals.test.js +17 -0
  659. package/src/maths/vec3/fromScalar.d.ts +5 -0
  660. package/src/maths/vec3/fromScalar.js +17 -0
  661. package/src/maths/vec3/fromScalar.test.js +12 -0
  662. package/src/maths/vec3/fromValues.d.ts +5 -0
  663. package/src/maths/vec3/fromValues.js +20 -0
  664. package/src/maths/vec3/fromValues.test.js +12 -0
  665. package/src/maths/vec3/fromVec2.d.ts +6 -0
  666. package/src/maths/vec3/fromVec2.js +17 -0
  667. package/src/maths/vec3/fromVec2.test.js +13 -0
  668. package/src/maths/vec3/index.d.ts +35 -0
  669. package/src/maths/vec3/index.js +39 -0
  670. package/src/maths/vec3/length.d.ts +5 -0
  671. package/src/maths/vec3/length.js +15 -0
  672. package/src/maths/vec3/length.test.js +45 -0
  673. package/src/maths/vec3/lerp.d.ts +5 -0
  674. package/src/maths/vec3/lerp.js +18 -0
  675. package/src/maths/vec3/lerp.test.js +26 -0
  676. package/src/maths/vec3/max.d.ts +5 -0
  677. package/src/maths/vec3/max.js +17 -0
  678. package/src/maths/vec3/max.test.js +31 -0
  679. package/src/maths/vec3/min.d.ts +5 -0
  680. package/src/maths/vec3/min.js +17 -0
  681. package/src/maths/vec3/min.test.js +31 -0
  682. package/src/maths/vec3/multiply.d.ts +5 -0
  683. package/src/maths/vec3/multiply.js +17 -0
  684. package/src/maths/vec3/multiply.test.js +36 -0
  685. package/src/maths/vec3/negate.d.ts +5 -0
  686. package/src/maths/vec3/negate.js +16 -0
  687. package/src/maths/vec3/negate.test.js +26 -0
  688. package/src/maths/vec3/normalize.d.ts +5 -0
  689. package/src/maths/vec3/normalize.js +23 -0
  690. package/src/maths/vec3/normalize.test.js +36 -0
  691. package/src/maths/vec3/orthogonal.d.ts +5 -0
  692. package/src/maths/vec3/orthogonal.js +22 -0
  693. package/src/maths/vec3/orthogonal.test.js +24 -0
  694. package/src/maths/vec3/rotateX.d.ts +5 -0
  695. package/src/maths/vec3/rotateX.js +33 -0
  696. package/src/maths/vec3/rotateX.test.js +31 -0
  697. package/src/maths/vec3/rotateY.d.ts +5 -0
  698. package/src/maths/vec3/rotateY.js +33 -0
  699. package/src/maths/vec3/rotateY.test.js +31 -0
  700. package/src/maths/vec3/rotateZ.d.ts +5 -0
  701. package/src/maths/vec3/rotateZ.js +30 -0
  702. package/src/maths/vec3/rotateZ.test.js +31 -0
  703. package/src/maths/vec3/scale.d.ts +5 -0
  704. package/src/maths/vec3/scale.js +17 -0
  705. package/src/maths/vec3/scale.test.js +36 -0
  706. package/src/maths/vec3/snap.d.ts +5 -0
  707. package/src/maths/vec3/snap.js +17 -0
  708. package/src/maths/vec3/snap.test.js +32 -0
  709. package/src/maths/vec3/squaredDistance.d.ts +5 -0
  710. package/src/maths/vec3/squaredDistance.js +16 -0
  711. package/src/maths/vec3/squaredDistance.test.js +46 -0
  712. package/src/maths/vec3/squaredLength.d.ts +5 -0
  713. package/src/maths/vec3/squaredLength.js +15 -0
  714. package/src/maths/vec3/squaredLength.test.js +45 -0
  715. package/src/maths/vec3/subtract.d.ts +5 -0
  716. package/src/maths/vec3/subtract.js +17 -0
  717. package/src/maths/vec3/subtract.test.js +26 -0
  718. package/src/maths/vec3/toString.d.ts +5 -0
  719. package/src/maths/vec3/toString.js +9 -0
  720. package/src/maths/vec3/transform.d.ts +6 -0
  721. package/src/maths/vec3/transform.js +22 -0
  722. package/src/maths/vec3/transform.test.js +66 -0
  723. package/src/maths/vec3/type.d.ts +3 -0
  724. package/src/maths/vec4/clone.d.ts +5 -0
  725. package/src/maths/vec4/clone.js +19 -0
  726. package/src/maths/vec4/clone.test.js +24 -0
  727. package/src/maths/vec4/copy.d.ts +5 -0
  728. package/src/maths/vec4/copy.js +17 -0
  729. package/src/maths/vec4/copy.test.js +30 -0
  730. package/src/maths/vec4/create.d.ts +5 -0
  731. package/src/maths/vec4/create.js +15 -0
  732. package/src/maths/vec4/create.test.js +10 -0
  733. package/src/maths/vec4/dot.d.ts +5 -0
  734. package/src/maths/vec4/dot.js +11 -0
  735. package/src/maths/vec4/dot.test.js +11 -0
  736. package/src/maths/vec4/equals.d.ts +5 -0
  737. package/src/maths/vec4/equals.js +11 -0
  738. package/src/maths/vec4/equals.test.js +17 -0
  739. package/src/maths/vec4/fromScalar.d.ts +5 -0
  740. package/src/maths/vec4/fromScalar.js +17 -0
  741. package/src/maths/vec4/fromScalar.test.js +12 -0
  742. package/src/maths/vec4/fromValues.d.ts +5 -0
  743. package/src/maths/vec4/fromValues.js +22 -0
  744. package/src/maths/vec4/fromValues.test.js +15 -0
  745. package/src/maths/vec4/index.d.ts +12 -0
  746. package/src/maths/vec4/index.js +16 -0
  747. package/src/maths/vec4/toString.d.ts +5 -0
  748. package/src/maths/vec4/toString.js +10 -0
  749. package/src/maths/vec4/transform.d.ts +6 -0
  750. package/src/maths/vec4/transform.js +20 -0
  751. package/src/maths/vec4/transform.test.js +66 -0
  752. package/src/maths/vec4/type.d.ts +3 -0
  753. package/src/measurements/calculateEpsilonFromBounds.js +11 -0
  754. package/src/measurements/calculateEpsilonFromBounds.test.js +18 -0
  755. package/src/measurements/index.d.ts +15 -0
  756. package/src/measurements/index.js +20 -0
  757. package/src/measurements/measureAggregateArea.d.ts +6 -0
  758. package/src/measurements/measureAggregateArea.js +26 -0
  759. package/src/measurements/measureAggregateArea.test.js +22 -0
  760. package/src/measurements/measureAggregateBoundingBox.d.ts +8 -0
  761. package/src/measurements/measureAggregateBoundingBox.js +30 -0
  762. package/src/measurements/measureAggregateBoundingBox.test.js +35 -0
  763. package/src/measurements/measureAggregateEpsilon.d.ts +6 -0
  764. package/src/measurements/measureAggregateEpsilon.js +29 -0
  765. package/src/measurements/measureAggregateEpsilon.test.js +28 -0
  766. package/src/measurements/measureAggregateVolume.d.ts +6 -0
  767. package/src/measurements/measureAggregateVolume.js +26 -0
  768. package/src/measurements/measureAggregateVolume.test.js +21 -0
  769. package/src/measurements/measureArea.d.ts +8 -0
  770. package/src/measurements/measureArea.js +80 -0
  771. package/src/measurements/measureArea.test.js +58 -0
  772. package/src/measurements/measureBoundingBox.d.ts +10 -0
  773. package/src/measurements/measureBoundingBox.js +134 -0
  774. package/src/measurements/measureBoundingBox.test.js +66 -0
  775. package/src/measurements/measureBoundingSphere.d.ts +9 -0
  776. package/src/measurements/measureBoundingSphere.js +146 -0
  777. package/src/measurements/measureBoundingSphere.test.js +59 -0
  778. package/src/measurements/measureCenter.d.ts +7 -0
  779. package/src/measurements/measureCenter.js +28 -0
  780. package/src/measurements/measureCenter.test.js +58 -0
  781. package/src/measurements/measureCenterOfMass.d.ts +7 -0
  782. package/src/measurements/measureCenterOfMass.js +106 -0
  783. package/src/measurements/measureCenterOfMass.test.js +58 -0
  784. package/src/measurements/measureDimensions.d.ts +7 -0
  785. package/src/measurements/measureDimensions.js +28 -0
  786. package/src/measurements/measureDimensions.test.js +58 -0
  787. package/src/measurements/measureEpsilon.d.ts +8 -0
  788. package/src/measurements/measureEpsilon.js +48 -0
  789. package/src/measurements/measureEpsilon.test.js +58 -0
  790. package/src/measurements/measureVolume.d.ts +8 -0
  791. package/src/measurements/measureVolume.js +68 -0
  792. package/src/measurements/measureVolume.test.js +58 -0
  793. package/src/measurements/types.d.ts +3 -0
  794. package/src/operations/booleans/fromFakePolygons.js +52 -0
  795. package/src/operations/booleans/index.d.ts +6 -0
  796. package/src/operations/booleans/index.js +14 -0
  797. package/src/operations/booleans/intersect.d.ts +7 -0
  798. package/src/operations/booleans/intersect.js +47 -0
  799. package/src/operations/booleans/intersectGeom2.js +27 -0
  800. package/src/operations/booleans/intersectGeom2.test.js +69 -0
  801. package/src/operations/booleans/intersectGeom3.js +25 -0
  802. package/src/operations/booleans/intersectGeom3.test.js +116 -0
  803. package/src/operations/booleans/intersectGeom3Sub.js +33 -0
  804. package/src/operations/booleans/mayOverlap.js +35 -0
  805. package/src/operations/booleans/mayOverlap.test.js +73 -0
  806. package/src/operations/booleans/scission.d.ts +6 -0
  807. package/src/operations/booleans/scission.js +45 -0
  808. package/src/operations/booleans/scission.test.js +51 -0
  809. package/src/operations/booleans/scissionGeom3.js +93 -0
  810. package/src/operations/booleans/subtract.d.ts +7 -0
  811. package/src/operations/booleans/subtract.js +47 -0
  812. package/src/operations/booleans/subtractGeom2.js +27 -0
  813. package/src/operations/booleans/subtractGeom2.test.js +72 -0
  814. package/src/operations/booleans/subtractGeom3.js +25 -0
  815. package/src/operations/booleans/subtractGeom3.test.js +109 -0
  816. package/src/operations/booleans/subtractGeom3Sub.js +31 -0
  817. package/src/operations/booleans/to3DWalls.js +36 -0
  818. package/src/operations/booleans/trees/Node.js +144 -0
  819. package/src/operations/booleans/trees/PolygonTreeNode.js +261 -0
  820. package/src/operations/booleans/trees/Tree.js +50 -0
  821. package/src/operations/booleans/trees/index.js +3 -0
  822. package/src/operations/booleans/trees/splitLineSegmentByPlane.js +15 -0
  823. package/src/operations/booleans/trees/splitPolygonByPlane.d.ts +33 -0
  824. package/src/operations/booleans/trees/splitPolygonByPlane.js +119 -0
  825. package/src/operations/booleans/trees/splitPolygonByPlane.test.js +132 -0
  826. package/src/operations/booleans/union.d.ts +7 -0
  827. package/src/operations/booleans/union.js +46 -0
  828. package/src/operations/booleans/unionGeom2.js +26 -0
  829. package/src/operations/booleans/unionGeom2.test.js +166 -0
  830. package/src/operations/booleans/unionGeom3.js +25 -0
  831. package/src/operations/booleans/unionGeom3.test.js +133 -0
  832. package/src/operations/booleans/unionGeom3Sub.js +40 -0
  833. package/src/operations/expansions/expand.d.ts +18 -0
  834. package/src/operations/expansions/expand.js +42 -0
  835. package/src/operations/expansions/expand.test.js +188 -0
  836. package/src/operations/expansions/expandGeom2.js +43 -0
  837. package/src/operations/expansions/expandGeom3.js +36 -0
  838. package/src/operations/expansions/expandGeom3.test.js +32 -0
  839. package/src/operations/expansions/expandPath2.js +99 -0
  840. package/src/operations/expansions/expandShell.js +224 -0
  841. package/src/operations/expansions/extrudePolygon.js +34 -0
  842. package/src/operations/expansions/index.d.ts +4 -0
  843. package/src/operations/expansions/index.js +11 -0
  844. package/src/operations/expansions/offset.d.ts +15 -0
  845. package/src/operations/expansions/offset.js +36 -0
  846. package/src/operations/expansions/offset.test.js +503 -0
  847. package/src/operations/expansions/offsetFromPoints.js +170 -0
  848. package/src/operations/expansions/offsetGeom2.js +47 -0
  849. package/src/operations/expansions/offsetPath2.js +32 -0
  850. package/src/operations/extrusions/earcut/assignHoles.js +91 -0
  851. package/src/operations/extrusions/earcut/assignHoles.test.js +74 -0
  852. package/src/operations/extrusions/earcut/eliminateHoles.js +131 -0
  853. package/src/operations/extrusions/earcut/index.js +252 -0
  854. package/src/operations/extrusions/earcut/linkedList.js +58 -0
  855. package/src/operations/extrusions/earcut/linkedListSort.js +54 -0
  856. package/src/operations/extrusions/earcut/linkedPolygon.js +197 -0
  857. package/src/operations/extrusions/earcut/polygonHierarchy.js +64 -0
  858. package/src/operations/extrusions/earcut/triangle.js +16 -0
  859. package/src/operations/extrusions/extrudeFromSlices.d.ts +15 -0
  860. package/src/operations/extrusions/extrudeFromSlices.js +124 -0
  861. package/src/operations/extrusions/extrudeFromSlices.test.js +167 -0
  862. package/src/operations/extrusions/extrudeHelical.d.ts +14 -0
  863. package/src/operations/extrusions/extrudeHelical.js +109 -0
  864. package/src/operations/extrusions/extrudeHelical.test.js +70 -0
  865. package/src/operations/extrusions/extrudeLinear.d.ts +15 -0
  866. package/src/operations/extrusions/extrudeLinear.js +47 -0
  867. package/src/operations/extrusions/extrudeLinear.test.js +226 -0
  868. package/src/operations/extrusions/extrudeLinearGeom2.js +64 -0
  869. package/src/operations/extrusions/extrudeLinearPath2.js +24 -0
  870. package/src/operations/extrusions/extrudeRectangular.d.ts +17 -0
  871. package/src/operations/extrusions/extrudeRectangular.js +45 -0
  872. package/src/operations/extrusions/extrudeRectangular.test.js +72 -0
  873. package/src/operations/extrusions/extrudeRectangularGeom2.js +46 -0
  874. package/src/operations/extrusions/extrudeRectangularPath2.js +33 -0
  875. package/src/operations/extrusions/extrudeRotate.d.ts +12 -0
  876. package/src/operations/extrusions/extrudeRotate.js +138 -0
  877. package/src/operations/extrusions/extrudeRotate.test.js +161 -0
  878. package/src/operations/extrusions/extrudeWalls.js +78 -0
  879. package/src/operations/extrusions/extrudeWalls.test.js +82 -0
  880. package/src/operations/extrusions/index.d.ts +9 -0
  881. package/src/operations/extrusions/index.js +16 -0
  882. package/src/operations/extrusions/project.d.ts +14 -0
  883. package/src/operations/extrusions/project.js +88 -0
  884. package/src/operations/extrusions/project.test.js +123 -0
  885. package/src/operations/extrusions/slice/calculatePlane.d.ts +7 -0
  886. package/src/operations/extrusions/slice/calculatePlane.js +41 -0
  887. package/src/operations/extrusions/slice/calculatePlane.test.js +35 -0
  888. package/src/operations/extrusions/slice/clone.d.ts +6 -0
  889. package/src/operations/extrusions/slice/clone.js +28 -0
  890. package/src/operations/extrusions/slice/clone.test.js +34 -0
  891. package/src/operations/extrusions/slice/create.d.ts +5 -0
  892. package/src/operations/extrusions/slice/create.js +20 -0
  893. package/src/operations/extrusions/slice/create.test.js +9 -0
  894. package/src/operations/extrusions/slice/equals.d.ts +5 -0
  895. package/src/operations/extrusions/slice/equals.js +27 -0
  896. package/src/operations/extrusions/slice/equals.test.js +17 -0
  897. package/src/operations/extrusions/slice/fromPoints.d.ts +9 -0
  898. package/src/operations/extrusions/slice/fromPoints.js +35 -0
  899. package/src/operations/extrusions/slice/fromPoints.test.js +15 -0
  900. package/src/operations/extrusions/slice/fromSides.d.ts +7 -0
  901. package/src/operations/extrusions/slice/fromSides.js +27 -0
  902. package/src/operations/extrusions/slice/fromSides.test.js +15 -0
  903. package/src/operations/extrusions/slice/index.d.ts +16 -0
  904. package/src/operations/extrusions/slice/index.js +19 -0
  905. package/src/operations/extrusions/slice/isA.d.ts +5 -0
  906. package/src/operations/extrusions/slice/isA.js +18 -0
  907. package/src/operations/extrusions/slice/isA.test.js +19 -0
  908. package/src/operations/extrusions/slice/repair.js +62 -0
  909. package/src/operations/extrusions/slice/reverse.d.ts +6 -0
  910. package/src/operations/extrusions/slice/reverse.js +26 -0
  911. package/src/operations/extrusions/slice/toEdges.d.ts +5 -0
  912. package/src/operations/extrusions/slice/toEdges.js +13 -0
  913. package/src/operations/extrusions/slice/toPolygons.d.ts +7 -0
  914. package/src/operations/extrusions/slice/toPolygons.js +40 -0
  915. package/src/operations/extrusions/slice/toString.d.ts +5 -0
  916. package/src/operations/extrusions/slice/toString.js +15 -0
  917. package/src/operations/extrusions/slice/transform.d.ts +7 -0
  918. package/src/operations/extrusions/slice/transform.js +21 -0
  919. package/src/operations/extrusions/slice/transform.test.js +66 -0
  920. package/src/operations/extrusions/slice/type.d.ts +7 -0
  921. package/src/operations/hulls/hull.d.ts +8 -0
  922. package/src/operations/hulls/hull.js +52 -0
  923. package/src/operations/hulls/hull.test.js +284 -0
  924. package/src/operations/hulls/hullChain.d.ts +8 -0
  925. package/src/operations/hulls/hullChain.js +43 -0
  926. package/src/operations/hulls/hullChain.test.js +87 -0
  927. package/src/operations/hulls/hullGeom2.js +31 -0
  928. package/src/operations/hulls/hullGeom3.js +27 -0
  929. package/src/operations/hulls/hullPath2.js +28 -0
  930. package/src/operations/hulls/hullPath2.test.js +16 -0
  931. package/src/operations/hulls/hullPoints2.d.ts +5 -0
  932. package/src/operations/hulls/hullPoints2.js +62 -0
  933. package/src/operations/hulls/hullPoints2.test.js +48 -0
  934. package/src/operations/hulls/hullPoints3.d.ts +6 -0
  935. package/src/operations/hulls/hullPoints3.js +23 -0
  936. package/src/operations/hulls/index.d.ts +6 -0
  937. package/src/operations/hulls/index.js +14 -0
  938. package/src/operations/hulls/quickhull/Face.js +334 -0
  939. package/src/operations/hulls/quickhull/HalfEdge.js +56 -0
  940. package/src/operations/hulls/quickhull/QuickHull.js +754 -0
  941. package/src/operations/hulls/quickhull/Vertex.js +21 -0
  942. package/src/operations/hulls/quickhull/VertexList.js +146 -0
  943. package/src/operations/hulls/quickhull/get-plane-normal.js +20 -0
  944. package/src/operations/hulls/quickhull/index.js +16 -0
  945. package/src/operations/hulls/quickhull/point-line-distance.js +42 -0
  946. package/src/operations/hulls/toUniquePoints.js +34 -0
  947. package/src/operations/modifiers/generalize.d.ts +12 -0
  948. package/src/operations/modifiers/generalize.js +82 -0
  949. package/src/operations/modifiers/generalize.test.js +170 -0
  950. package/src/operations/modifiers/index.d.ts +3 -0
  951. package/src/operations/modifiers/index.js +12 -0
  952. package/src/operations/modifiers/insertTjunctions.js +294 -0
  953. package/src/operations/modifiers/insertTjunctions.test.js +89 -0
  954. package/src/operations/modifiers/mergePolygons.js +208 -0
  955. package/src/operations/modifiers/reTesselateCoplanarPolygons.js +345 -0
  956. package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +70 -0
  957. package/src/operations/modifiers/retessellate.d.ts +3 -0
  958. package/src/operations/modifiers/retessellate.js +93 -0
  959. package/src/operations/modifiers/retessellate.test.js +173 -0
  960. package/src/operations/modifiers/snap.d.ts +6 -0
  961. package/src/operations/modifiers/snap.js +57 -0
  962. package/src/operations/modifiers/snap.test.js +146 -0
  963. package/src/operations/modifiers/snapPolygons.js +32 -0
  964. package/src/operations/modifiers/snapPolygons.test.js +70 -0
  965. package/src/operations/modifiers/triangulatePolygons.js +45 -0
  966. package/src/operations/transforms/align.d.ts +16 -0
  967. package/src/operations/transforms/align.js +89 -0
  968. package/src/operations/transforms/align.test.js +96 -0
  969. package/src/operations/transforms/center.d.ts +24 -0
  970. package/src/operations/transforms/center.js +90 -0
  971. package/src/operations/transforms/center.test.js +128 -0
  972. package/src/operations/transforms/index.d.ts +9 -0
  973. package/src/operations/transforms/index.js +37 -0
  974. package/src/operations/transforms/mirror.d.ts +24 -0
  975. package/src/operations/transforms/mirror.js +78 -0
  976. package/src/operations/transforms/mirror.test.js +158 -0
  977. package/src/operations/transforms/rotate.d.ts +19 -0
  978. package/src/operations/transforms/rotate.js +76 -0
  979. package/src/operations/transforms/rotate.test.js +154 -0
  980. package/src/operations/transforms/scale.d.ts +19 -0
  981. package/src/operations/transforms/scale.js +74 -0
  982. package/src/operations/transforms/scale.test.js +151 -0
  983. package/src/operations/transforms/transform.d.ts +7 -0
  984. package/src/operations/transforms/transform.js +32 -0
  985. package/src/operations/transforms/transform.test.js +76 -0
  986. package/src/operations/transforms/translate.d.ts +21 -0
  987. package/src/operations/transforms/translate.js +72 -0
  988. package/src/operations/transforms/translate.test.js +151 -0
  989. package/src/primitives/arc.d.ts +15 -0
  990. package/src/primitives/arc.js +86 -0
  991. package/src/primitives/arc.test.js +223 -0
  992. package/src/primitives/circle.d.ts +14 -0
  993. package/src/primitives/circle.js +38 -0
  994. package/src/primitives/circle.test.js +155 -0
  995. package/src/primitives/commonChecks.js +19 -0
  996. package/src/primitives/cube.d.ts +11 -0
  997. package/src/primitives/cube.js +30 -0
  998. package/src/primitives/cube.test.js +55 -0
  999. package/src/primitives/cuboid.d.ts +11 -0
  1000. package/src/primitives/cuboid.js +55 -0
  1001. package/src/primitives/cuboid.test.js +64 -0
  1002. package/src/primitives/cylinder.d.ts +13 -0
  1003. package/src/primitives/cylinder.js +46 -0
  1004. package/src/primitives/cylinder.test.js +90 -0
  1005. package/src/primitives/cylinderElliptic.d.ts +16 -0
  1006. package/src/primitives/cylinderElliptic.js +132 -0
  1007. package/src/primitives/cylinderElliptic.test.js +213 -0
  1008. package/src/primitives/ellipse.d.ts +14 -0
  1009. package/src/primitives/ellipse.js +78 -0
  1010. package/src/primitives/ellipse.test.js +146 -0
  1011. package/src/primitives/ellipsoid.d.ts +13 -0
  1012. package/src/primitives/ellipsoid.js +99 -0
  1013. package/src/primitives/ellipsoid.test.js +216 -0
  1014. package/src/primitives/geodesicSphere.d.ts +10 -0
  1015. package/src/primitives/geodesicSphere.js +140 -0
  1016. package/src/primitives/geodesicSphere.test.js +60 -0
  1017. package/src/primitives/index.d.ts +23 -0
  1018. package/src/primitives/index.js +31 -0
  1019. package/src/primitives/line.d.ts +6 -0
  1020. package/src/primitives/line.js +19 -0
  1021. package/src/primitives/line.test.js +17 -0
  1022. package/src/primitives/polygon.d.ts +12 -0
  1023. package/src/primitives/polygon.js +81 -0
  1024. package/src/primitives/polygon.test.js +63 -0
  1025. package/src/primitives/polyhedron.d.ts +14 -0
  1026. package/src/primitives/polyhedron.js +72 -0
  1027. package/src/primitives/polyhedron.test.js +44 -0
  1028. package/src/primitives/rectangle.d.ts +11 -0
  1029. package/src/primitives/rectangle.js +44 -0
  1030. package/src/primitives/rectangle.test.js +59 -0
  1031. package/src/primitives/roundedCuboid.d.ts +13 -0
  1032. package/src/primitives/roundedCuboid.js +193 -0
  1033. package/src/primitives/roundedCuboid.test.js +248 -0
  1034. package/src/primitives/roundedCylinder.d.ts +14 -0
  1035. package/src/primitives/roundedCylinder.js +147 -0
  1036. package/src/primitives/roundedCylinder.test.js +165 -0
  1037. package/src/primitives/roundedRectangle.d.ts +13 -0
  1038. package/src/primitives/roundedRectangle.js +76 -0
  1039. package/src/primitives/roundedRectangle.test.js +124 -0
  1040. package/src/primitives/sphere.d.ts +13 -0
  1041. package/src/primitives/sphere.js +35 -0
  1042. package/src/primitives/sphere.test.js +172 -0
  1043. package/src/primitives/square.d.ts +11 -0
  1044. package/src/primitives/square.js +31 -0
  1045. package/src/primitives/square.test.js +51 -0
  1046. package/src/primitives/star.d.ts +15 -0
  1047. package/src/primitives/star.js +88 -0
  1048. package/src/primitives/star.test.js +148 -0
  1049. package/src/primitives/torus.d.ts +15 -0
  1050. package/src/primitives/torus.js +64 -0
  1051. package/src/primitives/torus.test.js +59 -0
  1052. package/src/primitives/triangle.d.ts +10 -0
  1053. package/src/primitives/triangle.js +163 -0
  1054. package/src/primitives/triangle.test.js +103 -0
  1055. package/src/text/fonts/single-line/hershey/simplex.js +101 -0
  1056. package/src/text/index.d.ts +4 -0
  1057. package/src/text/index.js +12 -0
  1058. package/src/text/text.test.js +187 -0
  1059. package/src/text/vectorChar.d.ts +22 -0
  1060. package/src/text/vectorChar.js +60 -0
  1061. package/src/text/vectorParams.js +26 -0
  1062. package/src/text/vectorText.d.ts +21 -0
  1063. package/src/text/vectorText.js +92 -0
  1064. package/src/utils/areAllShapesTheSameType.d.ts +5 -0
  1065. package/src/utils/areAllShapesTheSameType.js +25 -0
  1066. package/src/utils/areAllShapesTheSameType.test.js +17 -0
  1067. package/src/utils/corners.d.ts +1 -0
  1068. package/src/utils/degToRad.d.ts +3 -0
  1069. package/src/utils/degToRad.js +9 -0
  1070. package/src/utils/degToRad.test.js +19 -0
  1071. package/src/utils/flatten.d.ts +5 -0
  1072. package/src/utils/flatten.js +25 -0
  1073. package/src/utils/flatten.test.js +94 -0
  1074. package/src/utils/fnNumberSort.d.ts +3 -0
  1075. package/src/utils/fnNumberSort.js +6 -0
  1076. package/src/utils/index.d.ts +9 -0
  1077. package/src/utils/index.js +15 -0
  1078. package/src/utils/insertSorted.d.ts +3 -0
  1079. package/src/utils/insertSorted.js +21 -0
  1080. package/src/utils/padArrayToLength.d.ts +3 -0
  1081. package/src/utils/padArrayToLength.js +17 -0
  1082. package/src/utils/padArrayToLength.test.js +27 -0
  1083. package/src/utils/radToDeg.d.ts +3 -0
  1084. package/src/utils/radToDeg.js +9 -0
  1085. package/src/utils/radToDeg.test.js +19 -0
  1086. package/src/utils/radiusToSegments.d.ts +3 -0
  1087. package/src/utils/radiusToSegments.js +18 -0
  1088. package/src/utils/radiusToSegments.test.js +28 -0
  1089. package/src/utils/recursiveArray.d.ts +3 -0
  1090. package/test/helpers/asserts.js +126 -0
  1091. package/test/helpers/comparePoints.js +16 -0
  1092. package/test/helpers/comparePolygonLists.js +10 -0
  1093. package/test/helpers/comparePolygons.js +16 -0
  1094. package/test/helpers/comparePolygonsAsPoints.js +23 -0
  1095. package/test/helpers/compareVectors.js +36 -0
  1096. package/test/helpers/index.js +8 -0
  1097. package/test/helpers/nearlyEqual.js +34 -0
@@ -0,0 +1,29 @@
1
+ const test = require('ava')
2
+
3
+ const { TAU } = require('../constants')
4
+
5
+ const { isOnlyTransformScale, create, fromTranslation, fromTaitBryanRotation, fromScaling, invert, multiply } = require('./index')
6
+
7
+ test('mat4: isOnlyTransformScale() should return true for right angles', (t) => {
8
+ let someRotation = fromTaitBryanRotation(create(), TAU / 2, 0, 0)
9
+ t.true(isOnlyTransformScale(someRotation))
10
+ t.true(isOnlyTransformScale(invert(create(), someRotation)))
11
+
12
+ someRotation = fromTaitBryanRotation(create(), 0, 0, 0)
13
+ t.true(isOnlyTransformScale(someRotation))
14
+ })
15
+
16
+ test('mat4: isOnlyTransformScale() should return correct values', (t) => {
17
+ const identity = create() // identity matrix
18
+ t.true(isOnlyTransformScale(identity))
19
+
20
+ const someTranslation = fromTranslation(create(), [5, 5, 5])
21
+ t.true(isOnlyTransformScale(someTranslation))
22
+
23
+ const someScaling = fromScaling(create(), [5, 5, 5])
24
+ t.true(isOnlyTransformScale(someScaling))
25
+ t.true(isOnlyTransformScale(invert(create(), someScaling)))
26
+
27
+ const combined = multiply(create(), someTranslation, someScaling)
28
+ t.true(isOnlyTransformScale(combined))
29
+ })
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec2 from '../vec2/type'
3
+
4
+ export default leftMultiplyVec2
5
+
6
+ declare function leftMultiplyVec2(vector: Vec2, matrix: Mat4): Vec2
@@ -0,0 +1,28 @@
1
+ const fromValues = require('../vec2/fromValues')
2
+
3
+ /*
4
+ * Multiply the input matrix by a Vector2 (interpreted as 2 column, 1 row)
5
+ * (result = v*M)
6
+ * Fourth element is set to 1
7
+ * @param {vec2} vector the input vector
8
+ * @param {mat4} matrix the input matrix
9
+ * @returns {vec2} output
10
+ */
11
+ const leftMultiplyVec2 = (vector, matrix) => {
12
+ const [v0, v1] = vector
13
+ const v2 = 0
14
+ const v3 = 1
15
+ let x = v0 * matrix[0] + v1 * matrix[4] + v2 * matrix[8] + v3 * matrix[12]
16
+ let y = v0 * matrix[1] + v1 * matrix[5] + v2 * matrix[9] + v3 * matrix[13]
17
+ const w = v0 * matrix[3] + v1 * matrix[7] + v2 * matrix[11] + v3 * matrix[15]
18
+
19
+ // scale such that fourth element becomes 1:
20
+ if (w !== 1) {
21
+ const invw = 1.0 / w
22
+ x *= invw
23
+ y *= invw
24
+ }
25
+ return fromValues(x, y)
26
+ }
27
+
28
+ module.exports = leftMultiplyVec2
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec3 from '../vec3/type'
3
+
4
+ export default leftMultiplyVec3
5
+
6
+ declare function leftMultiplyVec3(vector: Vec3, matrix: Mat4): Vec3
@@ -0,0 +1,29 @@
1
+ const fromValues = require('../vec3/fromValues')
2
+
3
+ /*
4
+ * Multiply the input matrix by a Vector3 (interpreted as 3 column, 1 row)
5
+ * (result = v*M)
6
+ * Fourth element is set to 1
7
+ * @param {vec3} vector the input vector
8
+ * @param {mat4} matrix the input matrix
9
+ * @returns {vec3} output
10
+ */
11
+ const leftMultiplyVec3 = (vector, matrix) => {
12
+ const [v0, v1, v2] = vector
13
+ const v3 = 1
14
+ let x = v0 * matrix[0] + v1 * matrix[4] + v2 * matrix[8] + v3 * matrix[12]
15
+ let y = v0 * matrix[1] + v1 * matrix[5] + v2 * matrix[9] + v3 * matrix[13]
16
+ let z = v0 * matrix[2] + v1 * matrix[6] + v2 * matrix[10] + v3 * matrix[14]
17
+ const w = v0 * matrix[3] + v1 * matrix[7] + v2 * matrix[11] + v3 * matrix[15]
18
+
19
+ // scale such that fourth element becomes 1:
20
+ if (w !== 1) {
21
+ const invw = 1.0 / w
22
+ x *= invw
23
+ y *= invw
24
+ z *= invw
25
+ }
26
+ return fromValues(x, y, z)
27
+ }
28
+
29
+ module.exports = leftMultiplyVec3
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec3 from '../vec3/type'
3
+
4
+ export default mirror
5
+
6
+ declare function mirror(out: Mat4, vec: Vec3, matrix: Mat4): Mat4
@@ -0,0 +1,34 @@
1
+ /*
2
+ * m the mat4 by the dimensions in the given vec3
3
+ * create an affine matrix for mirroring into an arbitrary plane:
4
+ *
5
+ * @param {mat4} out - the receiving matrix
6
+ * @param {vec3} vector - the vec3 to mirror the matrix by
7
+ * @param {mat4} matrix - the matrix to mirror
8
+ * @returns {mat4} out
9
+ */
10
+ const mirror = (out, vector, matrix) => {
11
+ const x = vector[0]
12
+ const y = vector[1]
13
+ const z = vector[2]
14
+
15
+ out[0] = matrix[0] * x
16
+ out[1] = matrix[1] * x
17
+ out[2] = matrix[2] * x
18
+ out[3] = matrix[3] * x
19
+ out[4] = matrix[4] * y
20
+ out[5] = matrix[5] * y
21
+ out[6] = matrix[6] * y
22
+ out[7] = matrix[7] * y
23
+ out[8] = matrix[8] * z
24
+ out[9] = matrix[9] * z
25
+ out[10] = matrix[10] * z
26
+ out[11] = matrix[11] * z
27
+ out[12] = matrix[12]
28
+ out[13] = matrix[13]
29
+ out[14] = matrix[14]
30
+ out[15] = matrix[15]
31
+ return out
32
+ }
33
+
34
+ module.exports = mirror
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Plane from '../plane/type'
3
+
4
+ export default mirrorByPlane
5
+
6
+ declare function mirrorByPlane(out: Mat4, plane: Plane): Mat4
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Create a matrix for mirroring about the given plane.
3
+ *
4
+ * @param {mat4} out - receiving matrix
5
+ * @param {vec4} plane - plane of which to mirror the matrix
6
+ * @returns {mat4} out
7
+ * @alias module:modeling/maths/mat4.mirrorByPlane
8
+ */
9
+ const mirrorByPlane = (out, plane) => {
10
+ const [nx, ny, nz, w] = plane
11
+
12
+ out[0] = (1.0 - 2.0 * nx * nx)
13
+ out[1] = (-2.0 * ny * nx)
14
+ out[2] = (-2.0 * nz * nx)
15
+ out[3] = 0
16
+ out[4] = (-2.0 * nx * ny)
17
+ out[5] = (1.0 - 2.0 * ny * ny)
18
+ out[6] = (-2.0 * nz * ny)
19
+ out[7] = 0
20
+ out[8] = (-2.0 * nx * nz)
21
+ out[9] = (-2.0 * ny * nz)
22
+ out[10] = (1.0 - 2.0 * nz * nz)
23
+ out[11] = 0
24
+ out[12] = (2.0 * nx * w)
25
+ out[13] = (2.0 * ny * w)
26
+ out[14] = (2.0 * nz * w)
27
+ out[15] = 1
28
+
29
+ return out
30
+ }
31
+
32
+ module.exports = mirrorByPlane
@@ -0,0 +1,28 @@
1
+ const test = require('ava')
2
+
3
+ const plane = require('../plane')
4
+
5
+ const { mirrorByPlane, create } = require('./index')
6
+
7
+ const { compareVectors } = require('../../../test/helpers')
8
+
9
+ test('mat4: mirrorByPlane() called with out parameter should return a new mat4 with correct values', (t) => {
10
+ const planeX = plane.fromPoints(plane.create(), [0, 0, 0], [0, 1, 1], [0, 1, 0])
11
+ const planeY = plane.fromPoints(plane.create(), [0, 0, 0], [1, 0, 0], [1, 0, 1])
12
+ const planeZ = plane.fromPoints(plane.create(), [0, 0, 0], [1, 0, 0], [1, 1, 0])
13
+
14
+ const out1 = create()
15
+ const ret1 = mirrorByPlane(out1, planeX)
16
+ t.true(compareVectors(out1, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
17
+ t.true(compareVectors(ret1, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
18
+
19
+ const out2 = create()
20
+ const ret2 = mirrorByPlane(out2, planeY)
21
+ t.true(compareVectors(out2, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
22
+ t.true(compareVectors(ret2, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
23
+
24
+ const out3 = create()
25
+ const ret3 = mirrorByPlane(out3, planeZ)
26
+ t.true(compareVectors(out3, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
27
+ t.true(compareVectors(ret3, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
28
+ })
@@ -0,0 +1,5 @@
1
+ import Mat4 from './type'
2
+
3
+ export default multiply
4
+
5
+ declare function multiply(out: Mat4, a: Mat4, b: Mat4): Mat4
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Multiplies the two matrices.
3
+ *
4
+ * @param {mat4} out - receiving matrix
5
+ * @param {mat4} a - first operand
6
+ * @param {mat4} b - second operand
7
+ * @returns {mat4} out
8
+ * @alias module:modeling/maths/mat4.multiply
9
+ */
10
+ const multiply = (out, a, b) => {
11
+ const a00 = a[0]
12
+ const a01 = a[1]
13
+ const a02 = a[2]
14
+ const a03 = a[3]
15
+ const a10 = a[4]
16
+ const a11 = a[5]
17
+ const a12 = a[6]
18
+ const a13 = a[7]
19
+ const a20 = a[8]
20
+ const a21 = a[9]
21
+ const a22 = a[10]
22
+ const a23 = a[11]
23
+ const a30 = a[12]
24
+ const a31 = a[13]
25
+ const a32 = a[14]
26
+ const a33 = a[15]
27
+
28
+ // Cache only the current line of the second matrix
29
+ let b0 = b[0]
30
+ let b1 = b[1]
31
+ let b2 = b[2]
32
+ let b3 = b[3]
33
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30
34
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31
35
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32
36
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33
37
+
38
+ b0 = b[4]
39
+ b1 = b[5]
40
+ b2 = b[6]
41
+ b3 = b[7]
42
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30
43
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31
44
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32
45
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33
46
+
47
+ b0 = b[8]
48
+ b1 = b[9]
49
+ b2 = b[10]
50
+ b3 = b[11]
51
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30
52
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31
53
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32
54
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33
55
+
56
+ b0 = b[12]
57
+ b1 = b[13]
58
+ b2 = b[14]
59
+ b3 = b[15]
60
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30
61
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31
62
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32
63
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33
64
+ return out
65
+ }
66
+
67
+ module.exports = multiply
@@ -0,0 +1,28 @@
1
+ const test = require('ava')
2
+ const { multiply } = require('./index')
3
+
4
+ const { compareVectors } = require('../../../test/helpers/index')
5
+
6
+ test('mat4: multiply() called with out parameter should return a new mat4 with correct values', (t) => {
7
+ const obs1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
8
+ const ret1 = multiply(obs1,
9
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
10
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
11
+ t.true(compareVectors(obs1, [90, 100, 110, 120, 202, 228, 254, 280, 314, 356, 398, 440, 426, 484, 542, 600]))
12
+ t.true(compareVectors(ret1, [90, 100, 110, 120, 202, 228, 254, 280, 314, 356, 398, 440, 426, 484, 542, 600]))
13
+ t.is(obs1, ret1)
14
+
15
+ const obs2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
16
+ const ret2 = multiply(obs2,
17
+ [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16],
18
+ [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16])
19
+ t.true(compareVectors(obs2, [90, 100, 110, 120, 202, 228, 254, 280, 314, 356, 398, 440, 426, 484, 542, 600]))
20
+ t.true(compareVectors(ret2, [90, 100, 110, 120, 202, 228, 254, 280, 314, 356, 398, 440, 426, 484, 542, 600]))
21
+
22
+ const obs3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
23
+ const ret3 = multiply(obs3,
24
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
25
+ [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16])
26
+ t.true(compareVectors(obs3, [-90, -100, -110, -120, -202, -228, -254, -280, -314, -356, -398, -440, -426, -484, -542, -600]))
27
+ t.true(compareVectors(ret3, [-90, -100, -110, -120, -202, -228, -254, -280, -314, -356, -398, -440, -426, -484, -542, -600]))
28
+ })
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec2 from '../vec2/type'
3
+
4
+ export default rightMultiplyVec2
5
+
6
+ declare function rightMultiplyVec2(vector: Vec2, matrix: Mat4): Vec2
@@ -0,0 +1,29 @@
1
+ const fromValues = require('../vec2/fromValues')
2
+
3
+ /**
4
+ * Multiply a 2D vector by a matrix (interpreted as 2 row, 1 column).
5
+ *
6
+ * Calculation: result = v*M, where the fourth element is set to 1.
7
+ * @param {vec2} vector - input vector
8
+ * @param {mat4} matrix - input matrix
9
+ * @returns {vec2} a new vector
10
+ * @alias module:modeling/maths/mat4.rightMultiplyVec2
11
+ */
12
+ const rightMultiplyVec2 = (vector, matrix) => {
13
+ const [v0, v1] = vector
14
+ const v2 = 0
15
+ const v3 = 1
16
+ let x = v0 * matrix[0] + v1 * matrix[1] + v2 * matrix[2] + v3 * matrix[3]
17
+ let y = v0 * matrix[4] + v1 * matrix[5] + v2 * matrix[6] + v3 * matrix[7]
18
+ const w = v0 * matrix[12] + v1 * matrix[13] + v2 * matrix[14] + v3 * matrix[15]
19
+
20
+ // scale such that fourth element becomes 1:
21
+ if (w !== 1) {
22
+ const invw = 1.0 / w
23
+ x *= invw
24
+ y *= invw
25
+ }
26
+ return fromValues(x, y)
27
+ }
28
+
29
+ module.exports = rightMultiplyVec2
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec3 from '../vec3/type'
3
+
4
+ export default rightMultiplyVec3
5
+
6
+ declare function rightMultiplyVec3(vector: Vec3, matrix: Mat4): Vec3
@@ -0,0 +1,30 @@
1
+ const fromValues = require('../vec3/fromValues')
2
+
3
+ /**
4
+ * Multiply a 3D vector by a matrix (interpreted as 3 row, 1 column)
5
+ *
6
+ * Calculation: result = v*M, where the fourth element is set to 1.
7
+ * @param {vec3} vector - input vector
8
+ * @param {mat4} matrix - input matrix
9
+ * @returns {vec3} a new vector
10
+ * @alias module:modeling/maths/mat4.rightMultiplyVec3
11
+ */
12
+ const rightMultiplyVec3 = (vector, matrix) => {
13
+ const [v0, v1, v2] = vector
14
+ const v3 = 1
15
+ let x = v0 * matrix[0] + v1 * matrix[1] + v2 * matrix[2] + v3 * matrix[3]
16
+ let y = v0 * matrix[4] + v1 * matrix[5] + v2 * matrix[6] + v3 * matrix[7]
17
+ let z = v0 * matrix[8] + v1 * matrix[9] + v2 * matrix[10] + v3 * matrix[11]
18
+ const w = v0 * matrix[12] + v1 * matrix[13] + v2 * matrix[14] + v3 * matrix[15]
19
+
20
+ // scale such that fourth element becomes 1:
21
+ if (w !== 1) {
22
+ const invw = 1.0 / w
23
+ x *= invw
24
+ y *= invw
25
+ z *= invw
26
+ }
27
+ return fromValues(x, y, z)
28
+ }
29
+
30
+ module.exports = rightMultiplyVec3
@@ -0,0 +1,6 @@
1
+ import Mat4 from './type'
2
+ import Vec3 from '../vec3/type'
3
+
4
+ export default rotate
5
+
6
+ declare function rotate(out: Mat4, matrix: Mat4, radians: number, axis: Vec3): Mat4
@@ -0,0 +1,82 @@
1
+ const { EPS } = require('../constants')
2
+
3
+ const { sin, cos } = require('../utils/trigonometry')
4
+
5
+ const copy = require('./copy')
6
+
7
+ /**
8
+ * Rotates a matrix by the given angle about the given axis.
9
+ *
10
+ * @param {mat4} out - receiving matrix
11
+ * @param {mat4} matrix - matrix to rotate
12
+ * @param {Number} radians - angle to rotate the matrix by
13
+ * @param {vec3} axis - axis to rotate around
14
+ * @returns {mat4} out
15
+ * @alias module:modeling/maths/mat4.rotate
16
+ */
17
+ const rotate = (out, matrix, radians, axis) => {
18
+ let [x, y, z] = axis
19
+ const lengthSquared = x * x + y * y + z * z
20
+
21
+ if (Math.abs(lengthSquared) < EPS) {
22
+ // axis is 0,0,0 or almost
23
+ return copy(out, matrix)
24
+ }
25
+
26
+ const len = 1 / Math.sqrt(lengthSquared)
27
+ x *= len
28
+ y *= len
29
+ z *= len
30
+
31
+ const s = sin(radians)
32
+ const c = cos(radians)
33
+ const t = 1 - c
34
+
35
+ const a00 = matrix[0]
36
+ const a01 = matrix[1]
37
+ const a02 = matrix[2]
38
+ const a03 = matrix[3]
39
+ const a10 = matrix[4]
40
+ const a11 = matrix[5]
41
+ const a12 = matrix[6]
42
+ const a13 = matrix[7]
43
+ const a20 = matrix[8]
44
+ const a21 = matrix[9]
45
+ const a22 = matrix[10]
46
+ const a23 = matrix[11]
47
+
48
+ // Construct the elements of the rotation matrix
49
+ const b00 = x * x * t + c
50
+ const b01 = y * x * t + z * s
51
+ const b02 = z * x * t - y * s
52
+ const b10 = x * y * t - z * s
53
+ const b11 = y * y * t + c
54
+ const b12 = z * y * t + x * s
55
+ const b20 = x * z * t + y * s
56
+ const b21 = y * z * t - x * s
57
+ const b22 = z * z * t + c
58
+
59
+ // Perform rotation-specific matrix multiplication
60
+ out[0] = a00 * b00 + a10 * b01 + a20 * b02
61
+ out[1] = a01 * b00 + a11 * b01 + a21 * b02
62
+ out[2] = a02 * b00 + a12 * b01 + a22 * b02
63
+ out[3] = a03 * b00 + a13 * b01 + a23 * b02
64
+ out[4] = a00 * b10 + a10 * b11 + a20 * b12
65
+ out[5] = a01 * b10 + a11 * b11 + a21 * b12
66
+ out[6] = a02 * b10 + a12 * b11 + a22 * b12
67
+ out[7] = a03 * b10 + a13 * b11 + a23 * b12
68
+ out[8] = a00 * b20 + a10 * b21 + a20 * b22
69
+ out[9] = a01 * b20 + a11 * b21 + a21 * b22
70
+ out[10] = a02 * b20 + a12 * b21 + a22 * b22
71
+ out[11] = a03 * b20 + a13 * b21 + a23 * b22
72
+
73
+ if (matrix !== out) { // If the source and destination differ, copy the unchanged last row
74
+ out[12] = matrix[12]
75
+ out[13] = matrix[13]
76
+ out[14] = matrix[14]
77
+ out[15] = matrix[15]
78
+ }
79
+ return out
80
+ }
81
+
82
+ module.exports = rotate
@@ -0,0 +1,27 @@
1
+ const test = require('ava')
2
+ const { rotate, create } = require('./index')
3
+
4
+ const { compareVectors } = require('../../../test/helpers/index')
5
+
6
+ test('mat4: rotate() called with out parameter should return a new mat4 with correct values', (t) => {
7
+ const rotation = 90 * 0.017453292519943295
8
+
9
+ const idn = create()
10
+
11
+ // invalid condition when axis is 0,0,0
12
+ const out1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
13
+ const ret1 = rotate(out1, idn, rotation, [0, 0, 0])
14
+ t.is(out1, ret1)
15
+ t.true(compareVectors(out1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
16
+
17
+ const out2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
18
+ const ret2 = rotate(out2, idn, rotation, [0, 0, 1])
19
+ t.true(compareVectors(out2, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
20
+ t.true(compareVectors(ret2, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
21
+ t.is(out2, ret2)
22
+
23
+ const out3 = create()
24
+ const ret3 = rotate(out3, out3, -rotation, [0, 0, 1])
25
+ t.true(compareVectors(out3, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
26
+ t.true(compareVectors(ret3, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
27
+ })
@@ -0,0 +1,5 @@
1
+ import Mat4 from './type'
2
+
3
+ export default rotateX
4
+
5
+ declare function rotateX(out: Mat4, matrix: Mat4, radians: number): Mat4
@@ -0,0 +1,47 @@
1
+ const { sin, cos } = require('../utils/trigonometry')
2
+
3
+ /**
4
+ * Rotates a matrix by the given angle around the X axis.
5
+ *
6
+ * @param {mat4} out - receiving matrix
7
+ * @param {mat4} matrix - matrix to rotate
8
+ * @param {Number} radians - angle to rotate the matrix by
9
+ * @returns {mat4} out
10
+ * @alias module:modeling/maths/mat4.rotateX
11
+ */
12
+ const rotateX = (out, matrix, radians) => {
13
+ const s = sin(radians)
14
+ const c = cos(radians)
15
+ const a10 = matrix[4]
16
+ const a11 = matrix[5]
17
+ const a12 = matrix[6]
18
+ const a13 = matrix[7]
19
+ const a20 = matrix[8]
20
+ const a21 = matrix[9]
21
+ const a22 = matrix[10]
22
+ const a23 = matrix[11]
23
+
24
+ if (matrix !== out) { // If the source and destination differ, copy the unchanged rows
25
+ out[0] = matrix[0]
26
+ out[1] = matrix[1]
27
+ out[2] = matrix[2]
28
+ out[3] = matrix[3]
29
+ out[12] = matrix[12]
30
+ out[13] = matrix[13]
31
+ out[14] = matrix[14]
32
+ out[15] = matrix[15]
33
+ }
34
+
35
+ // Perform axis-specific matrix multiplication
36
+ out[4] = a10 * c + a20 * s
37
+ out[5] = a11 * c + a21 * s
38
+ out[6] = a12 * c + a22 * s
39
+ out[7] = a13 * c + a23 * s
40
+ out[8] = a20 * c - a10 * s
41
+ out[9] = a21 * c - a11 * s
42
+ out[10] = a22 * c - a12 * s
43
+ out[11] = a23 * c - a13 * s
44
+ return out
45
+ }
46
+
47
+ module.exports = rotateX
@@ -0,0 +1,21 @@
1
+ const test = require('ava')
2
+ const { rotateX, create } = require('./index')
3
+
4
+ const { compareVectors } = require('../../../test/helpers/index')
5
+
6
+ test('mat4: rotateX() called with out parameter should return a new mat4 with correct values', (t) => {
7
+ const rotation = 90 * 0.017453292519943295
8
+
9
+ const idn = create()
10
+
11
+ const out2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
12
+ const ret2 = rotateX(out2, idn, rotation)
13
+ t.true(compareVectors(out2, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
14
+ t.true(compareVectors(ret2, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
15
+ t.is(out2, ret2)
16
+
17
+ const out3 = create()
18
+ const ret3 = rotateX(out3, out3, -rotation)
19
+ t.true(compareVectors(out3, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
20
+ t.true(compareVectors(ret3, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
21
+ })
@@ -0,0 +1,5 @@
1
+ import Mat4 from './type'
2
+
3
+ export default rotateY
4
+
5
+ declare function rotateY(out: Mat4, matrix: Mat4, radians: number): Mat4
@@ -0,0 +1,47 @@
1
+ const { sin, cos } = require('../utils/trigonometry')
2
+
3
+ /**
4
+ * Rotates a matrix by the given angle around the Y axis.
5
+ *
6
+ * @param {mat4} out - receiving matrix
7
+ * @param {mat4} matrix - matrix to rotate
8
+ * @param {Number} radians - angle to rotate the matrix by
9
+ * @returns {mat4} out
10
+ * @alias module:modeling/maths/mat4.rotateY
11
+ */
12
+ const rotateY = (out, matrix, radians) => {
13
+ const s = sin(radians)
14
+ const c = cos(radians)
15
+ const a00 = matrix[0]
16
+ const a01 = matrix[1]
17
+ const a02 = matrix[2]
18
+ const a03 = matrix[3]
19
+ const a20 = matrix[8]
20
+ const a21 = matrix[9]
21
+ const a22 = matrix[10]
22
+ const a23 = matrix[11]
23
+
24
+ if (matrix !== out) { // If the source and destination differ, copy the unchanged rows
25
+ out[4] = matrix[4]
26
+ out[5] = matrix[5]
27
+ out[6] = matrix[6]
28
+ out[7] = matrix[7]
29
+ out[12] = matrix[12]
30
+ out[13] = matrix[13]
31
+ out[14] = matrix[14]
32
+ out[15] = matrix[15]
33
+ }
34
+
35
+ // Perform axis-specific matrix multiplication
36
+ out[0] = a00 * c - a20 * s
37
+ out[1] = a01 * c - a21 * s
38
+ out[2] = a02 * c - a22 * s
39
+ out[3] = a03 * c - a23 * s
40
+ out[8] = a00 * s + a20 * c
41
+ out[9] = a01 * s + a21 * c
42
+ out[10] = a02 * s + a22 * c
43
+ out[11] = a03 * s + a23 * c
44
+ return out
45
+ }
46
+
47
+ module.exports = rotateY
@@ -0,0 +1,21 @@
1
+ const test = require('ava')
2
+ const { rotateY, create } = require('./index')
3
+
4
+ const { compareVectors } = require('../../../test/helpers/index')
5
+
6
+ test('mat4: rotateY() called with out parameter should return a new mat4 with correct values', (t) => {
7
+ const rotation = 90 * 0.017453292519943295
8
+
9
+ const idn = create()
10
+
11
+ const out2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
12
+ const ret2 = rotateY(out2, idn, rotation)
13
+ t.true(compareVectors(out2, [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]))
14
+ t.true(compareVectors(ret2, [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]))
15
+ t.is(out2, ret2)
16
+
17
+ const out3 = create()
18
+ const ret3 = rotateY(out3, out3, -rotation)
19
+ t.true(compareVectors(out3, [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]))
20
+ t.true(compareVectors(ret3, [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]))
21
+ })
@@ -0,0 +1,5 @@
1
+ import Mat4 from './type'
2
+
3
+ export default rotateZ
4
+
5
+ declare function rotateZ(out: Mat4, matrix: Mat4, radians: number): Mat4