@jscad/modeling 2.7.2 → 2.9.1

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 (238) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/jscad-modeling.min.js +443 -398
  3. package/package.json +2 -2
  4. package/src/curves/bezier/tangentAt.test.js +1 -1
  5. package/src/curves/bezier/valueAt.test.js +1 -1
  6. package/src/geometries/geom2/index.d.ts +1 -0
  7. package/src/geometries/geom2/index.js +12 -1
  8. package/src/geometries/geom2/isA.js +2 -2
  9. package/src/geometries/geom2/toCompactBinary.js +4 -4
  10. package/src/geometries/geom2/toString.js +1 -1
  11. package/src/geometries/geom2/transform.test.js +1 -1
  12. package/src/geometries/geom2/validate.d.ts +3 -0
  13. package/src/geometries/geom2/validate.js +36 -0
  14. package/src/geometries/geom3/fromCompactBinary.js +1 -1
  15. package/src/geometries/geom3/index.d.ts +1 -0
  16. package/src/geometries/geom3/index.js +19 -1
  17. package/src/geometries/geom3/isA.js +2 -2
  18. package/src/geometries/geom3/toCompactBinary.js +4 -4
  19. package/src/geometries/geom3/toString.js +1 -1
  20. package/src/geometries/geom3/transform.test.js +1 -1
  21. package/src/geometries/geom3/validate.d.ts +3 -0
  22. package/src/geometries/geom3/validate.js +62 -0
  23. package/src/geometries/index.js +8 -1
  24. package/src/geometries/path2/eachPoint.js +3 -3
  25. package/src/geometries/path2/index.d.ts +1 -0
  26. package/src/geometries/path2/index.js +13 -1
  27. package/src/geometries/path2/isA.js +2 -2
  28. package/src/geometries/path2/reverse.js +4 -4
  29. package/src/geometries/path2/toCompactBinary.js +6 -6
  30. package/src/geometries/path2/toString.js +1 -1
  31. package/src/geometries/path2/transform.test.js +1 -1
  32. package/src/geometries/path2/validate.d.ts +3 -0
  33. package/src/geometries/path2/validate.js +41 -0
  34. package/src/geometries/poly2/arePointsInside.js +0 -35
  35. package/src/geometries/poly2/arePointsInside.test.js +1 -1
  36. package/src/geometries/poly2/index.js +6 -0
  37. package/src/geometries/poly3/index.d.ts +1 -0
  38. package/src/geometries/poly3/index.js +9 -2
  39. package/src/geometries/poly3/invert.js +7 -1
  40. package/src/geometries/poly3/isA.js +2 -2
  41. package/src/geometries/poly3/isConvex.js +2 -2
  42. package/src/geometries/poly3/measureArea.js +4 -4
  43. package/src/geometries/poly3/measureArea.test.js +16 -16
  44. package/src/geometries/poly3/measureBoundingBox.js +2 -2
  45. package/src/geometries/poly3/measureBoundingSphere.js +2 -2
  46. package/src/geometries/poly3/measureBoundingSphere.test.js +8 -8
  47. package/src/geometries/poly3/measureSignedVolume.js +4 -4
  48. package/src/geometries/poly3/toPoints.js +2 -2
  49. package/src/geometries/poly3/toString.js +2 -2
  50. package/src/geometries/poly3/transform.js +2 -2
  51. package/src/geometries/poly3/validate.d.ts +4 -0
  52. package/src/geometries/poly3/validate.js +50 -0
  53. package/src/maths/index.js +1 -1
  54. package/src/maths/line2/equals.js +2 -2
  55. package/src/maths/line2/fromValues.js +2 -2
  56. package/src/maths/line2/intersectPointOfLines.js +1 -1
  57. package/src/maths/line2/intersectPointOfLines.test.js +1 -1
  58. package/src/maths/line2/reverse.test.js +1 -1
  59. package/src/maths/line2/transform.test.js +1 -1
  60. package/src/maths/line3/equals.js +2 -2
  61. package/src/maths/line3/reverse.test.js +1 -1
  62. package/src/maths/line3/transform.test.js +1 -1
  63. package/src/maths/mat4/fromVectorRotation.js +1 -1
  64. package/src/maths/mat4/fromVectorRotation.test.js +1 -1
  65. package/src/maths/mat4/identity.test.js +1 -1
  66. package/src/maths/mat4/invert.js +18 -18
  67. package/src/maths/mat4/isIdentity.js +1 -1
  68. package/src/maths/mat4/isMirroring.js +4 -4
  69. package/src/maths/mat4/isMirroring.test.js +1 -1
  70. package/src/maths/mat4/leftMultiplyVec3.js +2 -2
  71. package/src/maths/mat4/toString.js +2 -2
  72. package/src/maths/mat4/translate.test.js +1 -1
  73. package/src/maths/plane/flip.test.js +1 -1
  74. package/src/maths/plane/fromPoints.d.ts +1 -1
  75. package/src/maths/plane/fromPoints.js +1 -3
  76. package/src/maths/plane/signedDistanceToPoint.js +1 -1
  77. package/src/maths/plane/transform.test.js +1 -1
  78. package/src/maths/utils/aboutEqualNormals.js +2 -2
  79. package/src/maths/vec2/abs.d.ts +1 -1
  80. package/src/maths/vec2/add.test.js +1 -1
  81. package/src/maths/vec2/angleDegrees.d.ts +1 -1
  82. package/src/maths/vec2/angleRadians.d.ts +1 -1
  83. package/src/maths/vec2/create.js +1 -1
  84. package/src/maths/vec2/cross.test.js +1 -1
  85. package/src/maths/vec2/divide.test.js +1 -1
  86. package/src/maths/vec2/fromAngleDegrees.js +1 -1
  87. package/src/maths/vec2/fromScalar.js +1 -1
  88. package/src/maths/vec2/length.d.ts +1 -1
  89. package/src/maths/vec2/length.js +1 -1
  90. package/src/maths/vec2/lerp.test.js +1 -1
  91. package/src/maths/vec2/multiply.test.js +1 -1
  92. package/src/maths/vec2/negate.test.js +1 -1
  93. package/src/maths/vec2/normal.js +1 -1
  94. package/src/maths/vec2/normalize.d.ts +1 -1
  95. package/src/maths/vec2/normalize.test.js +1 -1
  96. package/src/maths/vec2/rotate.test.js +1 -1
  97. package/src/maths/vec2/squaredLength.d.ts +1 -1
  98. package/src/maths/vec2/squaredLength.js +3 -3
  99. package/src/maths/vec2/subtract.test.js +1 -1
  100. package/src/maths/vec2/toString.js +1 -1
  101. package/src/maths/vec2/transform.test.js +1 -1
  102. package/src/maths/vec3/abs.d.ts +1 -1
  103. package/src/maths/vec3/add.test.js +1 -1
  104. package/src/maths/vec3/cross.test.js +1 -1
  105. package/src/maths/vec3/divide.test.js +1 -1
  106. package/src/maths/vec3/fromScalar.js +1 -1
  107. package/src/maths/vec3/fromVec2.d.ts +1 -1
  108. package/src/maths/vec3/fromVec2.js +3 -3
  109. package/src/maths/vec3/length.d.ts +1 -1
  110. package/src/maths/vec3/length.js +4 -4
  111. package/src/maths/vec3/lerp.test.js +1 -1
  112. package/src/maths/vec3/multiply.test.js +1 -1
  113. package/src/maths/vec3/negate.d.ts +1 -1
  114. package/src/maths/vec3/negate.test.js +1 -1
  115. package/src/maths/vec3/normalize.d.ts +1 -1
  116. package/src/maths/vec3/normalize.test.js +1 -1
  117. package/src/maths/vec3/rotateX.test.js +1 -1
  118. package/src/maths/vec3/rotateY.test.js +1 -1
  119. package/src/maths/vec3/rotateZ.test.js +1 -1
  120. package/src/maths/vec3/scale.test.js +1 -1
  121. package/src/maths/vec3/squaredLength.d.ts +1 -1
  122. package/src/maths/vec3/squaredLength.js +4 -4
  123. package/src/maths/vec3/subtract.test.js +1 -1
  124. package/src/maths/vec3/toString.js +1 -1
  125. package/src/maths/vec3/transform.test.js +1 -1
  126. package/src/maths/vec4/toString.js +1 -1
  127. package/src/maths/vec4/transform.test.js +1 -1
  128. package/src/measurements/measureBoundingSphere.js +4 -4
  129. package/src/measurements/measureCenterOfMass.js +1 -1
  130. package/src/measurements/measureCenterOfMass.test.js +2 -2
  131. package/src/operations/booleans/intersect.test.js +8 -0
  132. package/src/operations/booleans/mayOverlap.js +3 -3
  133. package/src/operations/booleans/retessellate.js +2 -2
  134. package/src/operations/booleans/scission.js +1 -1
  135. package/src/operations/booleans/scission.test.js +4 -4
  136. package/src/operations/booleans/subtract.js +1 -1
  137. package/src/operations/booleans/subtract.test.js +8 -0
  138. package/src/operations/booleans/trees/Node.js +10 -16
  139. package/src/operations/booleans/trees/PolygonTreeNode.js +13 -14
  140. package/src/operations/booleans/trees/Tree.js +1 -2
  141. package/src/operations/booleans/trees/splitPolygonByPlane.js +2 -3
  142. package/src/operations/booleans/union.test.js +28 -1
  143. package/src/operations/booleans/unionGeom3Sub.js +1 -1
  144. package/src/operations/expansions/expand.js +2 -2
  145. package/src/operations/expansions/expand.test.js +32 -55
  146. package/src/operations/expansions/expandShell.js +24 -18
  147. package/src/operations/expansions/offset.js +1 -1
  148. package/src/operations/expansions/offset.test.js +50 -89
  149. package/src/operations/expansions/offsetFromPoints.js +11 -6
  150. package/src/operations/extrusions/earcut/assignHoles.js +91 -0
  151. package/src/operations/extrusions/earcut/assignHoles.test.js +74 -0
  152. package/src/operations/extrusions/earcut/eliminateHoles.js +131 -0
  153. package/src/operations/extrusions/earcut/index.js +252 -0
  154. package/src/operations/extrusions/earcut/linkedList.js +58 -0
  155. package/src/operations/extrusions/earcut/linkedListSort.js +54 -0
  156. package/src/operations/extrusions/earcut/linkedPolygon.js +197 -0
  157. package/src/operations/extrusions/earcut/polygonHierarchy.js +64 -0
  158. package/src/operations/extrusions/earcut/triangle.js +16 -0
  159. package/src/operations/extrusions/extrudeFromSlices.js +10 -3
  160. package/src/operations/extrusions/extrudeFromSlices.test.js +47 -31
  161. package/src/operations/extrusions/extrudeLinear.js +10 -5
  162. package/src/operations/extrusions/extrudeLinear.test.js +91 -35
  163. package/src/operations/extrusions/extrudeLinearGeom2.js +5 -2
  164. package/src/operations/extrusions/extrudeLinearPath2.js +24 -0
  165. package/src/operations/extrusions/extrudeRectangular.js +1 -1
  166. package/src/operations/extrusions/extrudeRectangular.test.js +22 -15
  167. package/src/operations/extrusions/extrudeRotate.test.js +31 -27
  168. package/src/operations/extrusions/project.js +1 -1
  169. package/src/operations/extrusions/project.test.js +5 -5
  170. package/src/operations/extrusions/slice/calculatePlane.js +7 -4
  171. package/src/operations/extrusions/slice/isA.js +2 -2
  172. package/src/operations/extrusions/slice/repairSlice.js +47 -0
  173. package/src/operations/extrusions/slice/toPolygons.js +24 -60
  174. package/src/operations/hulls/hull.test.js +25 -2
  175. package/src/operations/hulls/hullChain.js +1 -1
  176. package/src/operations/hulls/hullChain.test.js +6 -4
  177. package/src/operations/hulls/hullGeom2.js +1 -1
  178. package/src/operations/hulls/hullPath2.js +6 -4
  179. package/src/operations/hulls/hullPath2.test.js +16 -0
  180. package/src/operations/hulls/hullPoints2.test.js +1 -1
  181. package/src/operations/modifiers/edges.js +1 -1
  182. package/src/operations/modifiers/generalize.js +1 -1
  183. package/src/operations/modifiers/generalize.test.js +6 -0
  184. package/src/operations/modifiers/snap.test.js +3 -3
  185. package/src/operations/transforms/align.d.ts +1 -1
  186. package/src/operations/transforms/align.test.js +12 -0
  187. package/src/operations/transforms/center.js +17 -17
  188. package/src/operations/transforms/center.test.js +12 -0
  189. package/src/operations/transforms/mirror.js +12 -12
  190. package/src/operations/transforms/mirror.test.js +16 -0
  191. package/src/operations/transforms/rotate.js +12 -12
  192. package/src/operations/transforms/rotate.test.js +10 -0
  193. package/src/operations/transforms/scale.js +19 -19
  194. package/src/operations/transforms/scale.test.js +15 -0
  195. package/src/operations/transforms/transform.js +3 -3
  196. package/src/operations/transforms/transform.test.js +5 -0
  197. package/src/operations/transforms/translate.js +14 -14
  198. package/src/operations/transforms/translate.test.js +16 -0
  199. package/src/primitives/arc.js +1 -1
  200. package/src/primitives/arc.test.js +11 -0
  201. package/src/primitives/circle.test.js +15 -9
  202. package/src/primitives/cube.test.js +3 -0
  203. package/src/primitives/cuboid.test.js +9 -24
  204. package/src/primitives/cylinder.test.js +7 -4
  205. package/src/primitives/cylinderElliptic.js +13 -6
  206. package/src/primitives/cylinderElliptic.test.js +72 -52
  207. package/src/primitives/ellipse.js +3 -1
  208. package/src/primitives/ellipse.test.js +14 -8
  209. package/src/primitives/ellipsoid.js +7 -5
  210. package/src/primitives/ellipsoid.test.js +84 -82
  211. package/src/primitives/geodesicSphere.d.ts +0 -1
  212. package/src/primitives/geodesicSphere.test.js +3 -0
  213. package/src/primitives/line.test.js +1 -0
  214. package/src/primitives/polygon.test.js +15 -10
  215. package/src/primitives/polyhedron.js +1 -1
  216. package/src/primitives/polyhedron.test.js +14 -42
  217. package/src/primitives/rectangle.test.js +3 -0
  218. package/src/primitives/roundedCuboid.test.js +5 -0
  219. package/src/primitives/roundedCylinder.js +6 -4
  220. package/src/primitives/roundedCylinder.test.js +40 -36
  221. package/src/primitives/roundedRectangle.test.js +5 -0
  222. package/src/primitives/sphere.test.js +52 -73
  223. package/src/primitives/square.test.js +3 -0
  224. package/src/primitives/star.test.js +6 -0
  225. package/src/primitives/torus.d.ts +0 -1
  226. package/src/primitives/torus.test.js +8 -1
  227. package/src/primitives/triangle.js +1 -1
  228. package/src/primitives/triangle.test.js +7 -0
  229. package/src/text/vectorText.js +2 -2
  230. package/src/utils/areAllShapesTheSameType.js +2 -2
  231. package/src/utils/areAllShapesTheSameType.test.js +17 -0
  232. package/src/utils/index.d.ts +1 -0
  233. package/src/utils/index.js +3 -1
  234. package/src/utils/padArrayToLength.js +1 -1
  235. package/src/utils/trigonometry.d.ts +2 -0
  236. package/src/utils/trigonometry.js +35 -0
  237. package/src/utils/trigonometry.test.js +25 -0
  238. package/test/helpers/nearlyEqual.js +4 -1
@@ -2,4 +2,4 @@ import Vec2 from './type'
2
2
 
3
3
  export default angleDegrees
4
4
 
5
- declare function angleDegrees(vec: Vec2): number
5
+ declare function angleDegrees(vector: Vec2): number
@@ -2,4 +2,4 @@ import Vec2 from './type'
2
2
 
3
3
  export default angleRadians
4
4
 
5
- declare function angleRadians(vec: Vec2): number
5
+ declare function angleRadians(vector: Vec2): number
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /**
8
- * Creates a new vector, intialized to [0,0].
8
+ * Creates a new vector, initialized to [0,0].
9
9
  *
10
10
  * @returns {vec2} a new vector
11
11
  * @alias module:modeling/maths/vec2.create
@@ -3,7 +3,7 @@ const { cross } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: cross() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: cross() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = [0, 0, 0]
8
8
  const ret1 = cross(obs1, [0, 0], [0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -3,7 +3,7 @@ const { divide, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: divide() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: divide() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = divide(obs1, [0, 0], [0, 0])
9
9
  t.true(compareVectors(obs1, [0 / 0, 0 / 0]))
@@ -4,7 +4,7 @@ const fromAngleRadians = require('./fromAngleRadians')
4
4
  * Create a new vector in the direction of the given angle.
5
5
  *
6
6
  * @param {vec2} out - receiving vector
7
- * @param {Number} angle - angle in degrees
7
+ * @param {Number} degrees - angle in degrees
8
8
  * @returns {vec2} out
9
9
  * @alias module:modeling/maths/vec2.fromAngleDegrees
10
10
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @param {vec2} out - receiving vector
5
5
  * @param {Number} scalar - the scalar value
6
- * @returns {Vec2} out
6
+ * @returns {vec2} out
7
7
  * @alias module:modeling/maths/vec2.fromScalar
8
8
  */
9
9
  const fromScalar = (out, scalar) => {
@@ -2,4 +2,4 @@ import Vec2 from './type'
2
2
 
3
3
  export default length
4
4
 
5
- declare function length(a: Vec2): number
5
+ declare function length(vector: Vec2): number
@@ -5,6 +5,6 @@
5
5
  * @returns {Number} length
6
6
  * @alias module:modeling/maths/vec2.length
7
7
  */
8
- const length = (a) => Math.hypot(a[0], a[1])
8
+ const length = (vector) => Math.hypot(vector[0], vector[1])
9
9
 
10
10
  module.exports = length
@@ -3,7 +3,7 @@ const { lerp, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: lerp() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: lerp() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = lerp(obs1, [0, 0], [0, 0], 0)
9
9
  t.true(compareVectors(obs1, [0, 0]))
@@ -3,7 +3,7 @@ const { multiply, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: multiply() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: multiply() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = multiply(obs1, [0, 0], [0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0]))
@@ -3,7 +3,7 @@ const { negate, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: negate() called with two paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: negate() called with two parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = negate(obs1, [0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0]))
@@ -3,7 +3,7 @@ const rotate = require('./rotate')
3
3
 
4
4
  /**
5
5
  * Calculates the normal of the given vector.
6
- * The normal value is the given vector rotated 90 degress.
6
+ * The normal value is the given vector rotated 90 degrees.
7
7
  *
8
8
  * @param {vec2} out - receiving vector
9
9
  * @param {vec2} vector - given value
@@ -2,4 +2,4 @@ import Vec2 from './type'
2
2
 
3
3
  export default normalize
4
4
 
5
- declare function normalize(out: Vec2, vec: Vec2): Vec2
5
+ declare function normalize(out: Vec2, vector: Vec2): Vec2
@@ -3,7 +3,7 @@ const { normalize, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: normalize() called with two paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: normalize() called with two parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = normalize(obs1, [0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0]))
@@ -3,7 +3,7 @@ const { rotate, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: rotate() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: rotate() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const radians = 90 * Math.PI / 180
8
8
 
9
9
  const obs1 = fromValues(0, 0)
@@ -2,4 +2,4 @@ import Vec2 from './type'
2
2
 
3
3
  export default squaredLength
4
4
 
5
- declare function squaredLength(vec: Vec2): number
5
+ declare function squaredLength(vector: Vec2): number
@@ -5,9 +5,9 @@
5
5
  * @returns {Number} squared length
6
6
  * @alias module:modeling/maths/vec2.squaredLength
7
7
  */
8
- const squaredLength = (a) => {
9
- const x = a[0]
10
- const y = a[1]
8
+ const squaredLength = (vector) => {
9
+ const x = vector[0]
10
+ const y = vector[1]
11
11
  return x * x + y * y
12
12
  }
13
13
 
@@ -3,7 +3,7 @@ const { subtract, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: subtract() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: subtract() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0)
8
8
  const ret1 = subtract(obs1, [0, 0], [0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0]))
@@ -5,6 +5,6 @@
5
5
  * @returns {String} string representation
6
6
  * @alias module:modeling/maths/vec2.toString
7
7
  */
8
- const toString = (vec) => `[${vec[0].toFixed(7)}, ${vec[1].toFixed(7)}]`
8
+ const toString = (vector) => `[${vector[0].toFixed(7)}, ${vector[1].toFixed(7)}]`
9
9
 
10
10
  module.exports = toString
@@ -3,7 +3,7 @@ const { transform, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec2: transform() called with three paramerters should update a vec2 with correct values', (t) => {
6
+ test('vec2: transform() called with three parameters should update a vec2 with correct values', (t) => {
7
7
  const identityMatrix = [
8
8
  1, 0, 0, 0,
9
9
  0, 1, 0, 0,
@@ -2,4 +2,4 @@ import Vec3 from './type'
2
2
 
3
3
  export default abs
4
4
 
5
- declare function abs(out: Vec3, vec: Vec3): Vec3
5
+ declare function abs(out: Vec3, vector: Vec3): Vec3
@@ -3,7 +3,7 @@ const { add, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: add() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: add() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = add(obs1, [0, 0, 0], [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -3,7 +3,7 @@ const { cross, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: cross() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: cross() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = cross(obs1, [0, 0, 0], [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -3,7 +3,7 @@ const { divide, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: divide() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: divide() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = divide(obs1, [0, 0, 0], [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0 / 0, 0 / 0, 0 / 0]))
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @param {vec3} out - receiving vector
6
6
  * @param {Number} scalar
7
- * @returns {Vec3} out
7
+ * @returns {vec3} out
8
8
  * @alias module:modeling/maths/vec3.fromScalar
9
9
  */
10
10
  const fromScalar = (out, scalar) => {
@@ -3,4 +3,4 @@ import Vec2 from '../vec2/type'
3
3
 
4
4
  export default fromVector2
5
5
 
6
- declare function fromVector2(out: Vec3, vec2: Vec2, z?: number): Vec3
6
+ declare function fromVector2(out: Vec3, vector: Vec2, z?: number): Vec3
@@ -7,9 +7,9 @@
7
7
  * @returns {vec3} out
8
8
  * @alias module:modeling/maths/vec3.fromVec2
9
9
  */
10
- const fromVector2 = (out, vec2, z = 0) => {
11
- out[0] = vec2[0]
12
- out[1] = vec2[1]
10
+ const fromVector2 = (out, vector, z = 0) => {
11
+ out[0] = vector[0]
12
+ out[1] = vector[1]
13
13
  out[2] = z
14
14
  return out
15
15
  }
@@ -2,4 +2,4 @@ import Vec3 from './type'
2
2
 
3
3
  export default length
4
4
 
5
- declare function length(a: Vec3): number
5
+ declare function length(vector: Vec3): number
@@ -5,10 +5,10 @@
5
5
  * @returns {Number} length
6
6
  * @alias module:modeling/maths/vec3.length
7
7
  */
8
- const length = (a) => {
9
- const x = a[0]
10
- const y = a[1]
11
- const z = a[2]
8
+ const length = (vector) => {
9
+ const x = vector[0]
10
+ const y = vector[1]
11
+ const z = vector[2]
12
12
  return Math.hypot(x, y, z)
13
13
  }
14
14
 
@@ -3,7 +3,7 @@ const { lerp, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: lerp() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: lerp() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = lerp(obs1, [0, 0, 0], [0, 0, 0], 0)
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -3,7 +3,7 @@ const { multiply, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: multiply() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: multiply() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = multiply(obs1, [0, 0, 0], [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -2,4 +2,4 @@ import Vec3 from './type'
2
2
 
3
3
  export default negate
4
4
 
5
- declare function negate(out: Vec3, vec: Vec3): Vec3
5
+ declare function negate(out: Vec3, vector: Vec3): Vec3
@@ -3,7 +3,7 @@ const { negate, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: negate() called with two paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: negate() called with two parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = negate(obs1, [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [-0, -0, -0]))
@@ -2,4 +2,4 @@ import Vec3 from './type'
2
2
 
3
3
  export default normalize
4
4
 
5
- declare function normalize(out: Vec3, vec: Vec3): Vec3
5
+ declare function normalize(out: Vec3, vector: Vec3): Vec3
@@ -3,7 +3,7 @@ const { normalize, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: normalize() called with two paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: normalize() called with two parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = normalize(obs1, [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -3,7 +3,7 @@ const { rotateX, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: rotateX() called with four paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: rotateX() called with four parameters should update a vec3 with correct values', (t) => {
7
7
  const radians = 90 * Math.PI / 180
8
8
 
9
9
  const obs1 = fromValues(0, 0, 0)
@@ -3,7 +3,7 @@ const { rotateY, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: rotateY() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: rotateY() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const radians = 90 * Math.PI / 180
8
8
 
9
9
  const obs1 = fromValues(0, 0, 0)
@@ -3,7 +3,7 @@ const { rotateZ, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: rotateZ() called with four paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: rotateZ() called with four parameters should update a vec3 with correct values', (t) => {
7
7
  const radians = 90 * Math.PI / 180
8
8
 
9
9
  const obs1 = fromValues(0, 0, 0)
@@ -3,7 +3,7 @@ const { scale, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: scale() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: scale() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = scale(obs1, [0, 0, 0], 0)
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -2,4 +2,4 @@ import Vec3 from './type'
2
2
 
3
3
  export default squaredLength
4
4
 
5
- declare function squaredLength(vec: Vec3): number
5
+ declare function squaredLength(vector: Vec3): number
@@ -5,10 +5,10 @@
5
5
  * @returns {Number} squared length
6
6
  * @alias module:modeling/maths/vec3.squaredLength
7
7
  */
8
- const squaredLength = (a) => {
9
- const x = a[0]
10
- const y = a[1]
11
- const z = a[2]
8
+ const squaredLength = (vector) => {
9
+ const x = vector[0]
10
+ const y = vector[1]
11
+ const z = vector[2]
12
12
  return x * x + y * y + z * z
13
13
  }
14
14
 
@@ -3,7 +3,7 @@ const { subtract, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: subtract() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: subtract() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const obs1 = fromValues(0, 0, 0)
8
8
  const ret1 = subtract(obs1, [0, 0, 0], [0, 0, 0])
9
9
  t.true(compareVectors(obs1, [0, 0, 0]))
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Convert the given vector to a representative string.
3
- * @param {vec3} vector - vector of reference
3
+ * @param {vec3} vec - vector of reference
4
4
  * @returns {String} string representation
5
5
  * @alias module:modeling/maths/vec3.toString
6
6
  */
@@ -3,7 +3,7 @@ const { transform, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec3: transform() called with three paramerters should update a vec3 with correct values', (t) => {
6
+ test('vec3: transform() called with three parameters should update a vec3 with correct values', (t) => {
7
7
  const identityMatrix = [
8
8
  1, 0, 0, 0,
9
9
  0, 1, 0, 0,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Convert the given vector to a representative string.
3
3
  *
4
- * @param {vec4} vector - vector to convert
4
+ * @param {vec4} vec - vector to convert
5
5
  * @returns {String} representative string
6
6
  * @alias module:modeling/maths/vec4.toString
7
7
  */
@@ -3,7 +3,7 @@ const { transform, fromValues } = require('./index')
3
3
 
4
4
  const { compareVectors } = require('../../../test/helpers/index')
5
5
 
6
- test('vec4: transform() called with three paramerters should update a vec4 with correct values', (t) => {
6
+ test('vec4: transform() called with three parameters should update a vec4 with correct values', (t) => {
7
7
  const identityMatrix = [
8
8
  1, 0, 0, 0,
9
9
  0, 1, 0, 0,
@@ -24,7 +24,7 @@ const measureBoundingSphereOfPath2 = (geometry) => {
24
24
  const points = path2.toPoints(geometry)
25
25
 
26
26
  if (points.length > 0) {
27
- // calculate the centriod of the geometry
27
+ // calculate the centroid of the geometry
28
28
  let numPoints = 0
29
29
  const temp = vec3.create()
30
30
  points.forEach((point) => {
@@ -60,7 +60,7 @@ const measureBoundingSphereOfGeom2 = (geometry) => {
60
60
  const sides = geom2.toSides(geometry)
61
61
 
62
62
  if (sides.length > 0) {
63
- // calculate the centriod of the geometry
63
+ // calculate the centroid of the geometry
64
64
  let numPoints = 0
65
65
  const temp = vec3.create()
66
66
  sides.forEach((side) => {
@@ -96,7 +96,7 @@ const measureBoundingSphereOfGeom3 = (geometry) => {
96
96
  const polygons = geom3.toPolygons(geometry)
97
97
 
98
98
  if (polygons.length > 0) {
99
- // calculate the centriod of the geometry
99
+ // calculate the centroid of the geometry
100
100
  let numPoints = 0
101
101
  polygons.forEach((polygon) => {
102
102
  poly3.toPoints(polygon).forEach((point) => {
@@ -122,7 +122,7 @@ const measureBoundingSphereOfGeom3 = (geometry) => {
122
122
  }
123
123
 
124
124
  /**
125
- * Measure the (aproximate) bounding sphere of the given geometries.
125
+ * Measure the (approximate) bounding sphere of the given geometries.
126
126
  * @see https://en.wikipedia.org/wiki/Bounding_sphere
127
127
  * @param {...Object} geometries - the geometries to measure
128
128
  * @return {Array} the bounding sphere for each geometry, i.e. [centroid, radius]
@@ -61,7 +61,7 @@ const measureCenterOfMassGeom3 = (geometry) => {
61
61
  let totalVolume = 0
62
62
  const vector = vec3.create() // for speed
63
63
  polygons.forEach((polygon) => {
64
- // calculate volume and center of each tetrahedon
64
+ // calculate volume and center of each tetrahedron
65
65
  const vertices = polygon.vertices
66
66
  for (let i = 0; i < vertices.length - 2; i++) {
67
67
  vec3.cross(vector, vertices[i + 1], vertices[i + 2])
@@ -51,8 +51,8 @@ test('measureCenterOfMass (multiple objects)', (t) => {
51
51
  const o = {}
52
52
 
53
53
  let allcenters = measureCenterOfMass(aline, arect, asphere, o)
54
- t.deepEqual(allcenters, [[0, 0, 0], [10, -10, 0], [4.99999999999999, -5.000000000000007, 49.99999999999992], [0, 0, 0]])
54
+ t.deepEqual(allcenters, [[0, 0, 0], [10, -10, 0], [4.999999999999991, -5.000000000000006, 49.999999999999915], [0, 0, 0]])
55
55
 
56
56
  allcenters = measureCenterOfMass(aline, arect, asphere, o)
57
- t.deepEqual(allcenters, [[0, 0, 0], [10, -10, 0], [4.99999999999999, -5.000000000000007, 49.99999999999992], [0, 0, 0]])
57
+ t.deepEqual(allcenters, [[0, 0, 0], [10, -10, 0], [4.999999999999991, -5.000000000000006, 49.999999999999915], [0, 0, 0]])
58
58
  })
@@ -36,6 +36,7 @@ test('intersect: intersect of one or more geom2 objects produces expected geomet
36
36
  [0, -2],
37
37
  [1.4142000000000001, -1.4142000000000001]
38
38
  ]
39
+ t.notThrows(() => geom2.validate(result1))
39
40
  t.is(obs.length, 8)
40
41
  t.true(comparePoints(obs, exp))
41
42
 
@@ -44,6 +45,7 @@ test('intersect: intersect of one or more geom2 objects produces expected geomet
44
45
 
45
46
  const result2 = intersect(geometry1, geometry2)
46
47
  obs = geom2.toPoints(result2)
48
+ t.notThrows(() => geom2.validate(result2))
47
49
  t.is(obs.length, 0)
48
50
 
49
51
  // intersect of two partially overlapping objects
@@ -54,6 +56,7 @@ test('intersect: intersect of one or more geom2 objects produces expected geomet
54
56
  exp = [
55
57
  [9, 9], [8, 9], [8, 8], [9, 8]
56
58
  ]
59
+ t.notThrows(() => geom2.validate(result3))
57
60
  t.is(obs.length, 4)
58
61
  t.true(comparePoints(obs, exp))
59
62
 
@@ -70,6 +73,7 @@ test('intersect: intersect of one or more geom2 objects produces expected geomet
70
73
  [0, -2],
71
74
  [1.4142000000000001, -1.4142000000000001]
72
75
  ]
76
+ t.notThrows(() => geom2.validate(result4))
73
77
  t.is(obs.length, 8)
74
78
  t.true(comparePoints(obs, exp))
75
79
  })
@@ -130,6 +134,7 @@ test('intersect: intersect of one or more geom3 objects produces expected geomet
130
134
  [[0.9999999999999998, 1.0000000000000002, -1.414213562373095], [1.4142135623730951, 3.4638242249419736e-16, -1.414213562373095], [8.65956056235493e-17, 8.659560562354935e-17, -2]],
131
135
  [[8.65956056235493e-17, 8.659560562354935e-17, 2], [1.4142135623730951, 3.4638242249419736e-16, 1.414213562373095], [0.9999999999999998, 1.0000000000000002, 1.414213562373095]]
132
136
  ]
137
+ t.notThrows.skip(() => geom3.validate(result1))
133
138
  t.is(obs.length, 32)
134
139
  t.true(comparePolygonsAsPoints(obs, exp))
135
140
 
@@ -138,6 +143,7 @@ test('intersect: intersect of one or more geom3 objects produces expected geomet
138
143
 
139
144
  const result2 = intersect(geometry1, geometry2)
140
145
  obs = geom3.toPoints(result2)
146
+ t.notThrows(() => geom3.validate(result2))
141
147
  t.is(obs.length, 0)
142
148
 
143
149
  // intersect of two partially overlapping objects
@@ -166,11 +172,13 @@ test('intersect: intersect of one or more geom3 objects produces expected geomet
166
172
  [[9, 8, 8], [8, 8, 8], [8, 9, 8], [9, 9, 8]]
167
173
  ]
168
174
 
175
+ t.notThrows(() => geom3.validate(result3))
169
176
  t.is(obs.length, 6)
170
177
  t.true(comparePolygonsAsPoints(obs, exp))
171
178
 
172
179
  // intersect of two completely overlapping objects
173
180
  const result4 = intersect(geometry1, geometry3)
174
181
  obs = geom3.toPoints(result4)
182
+ t.notThrows.skip(() => geom3.validate(result4))
175
183
  t.is(obs.length, 32)
176
184
  })
@@ -4,9 +4,9 @@ const measureBoundingBox = require('../../measurements/measureBoundingBox')
4
4
 
5
5
  /*
6
6
  * Determine if the given geometries overlap by comparing min and max bounds.
7
- * NOTE: This is used in union for performace gains.
8
- * @param {geom3} geometry1 - geometry for comparision
9
- * @param {geom3} geometry2 - geometry for comparision
7
+ * NOTE: This is used in union for performance gains.
8
+ * @param {geom3} geometry1 - geometry for comparison
9
+ * @param {geom3} geometry2 - geometry for comparison
10
10
  * @returns {boolean} true if the geometries overlap
11
11
  */
12
12
  const mayOverlap = (geometry1, geometry2) => {
@@ -3,8 +3,8 @@ const poly3 = require('../../geometries/poly3')
3
3
 
4
4
  const reTesselateCoplanarPolygons = require('./reTesselateCoplanarPolygons')
5
5
 
6
- // Normals are directional vectors with component values from 0 to 1.0, requiring specialized comparision
7
- // This EPS is derived from a serieas of tests to determine the optimal precision for comparing coplanar polygons,
6
+ // Normals are directional vectors with component values from 0 to 1.0, requiring specialized comparison
7
+ // This EPS is derived from a series of tests to determine the optimal precision for comparing coplanar polygons,
8
8
  // as provided by the sphere primitive at high segmentation
9
9
  // This EPS is for 64 bit Number values
10
10
  const NEPS = 1e-13
@@ -9,7 +9,7 @@ const scissionGeom3 = require('./scissionGeom3')
9
9
  /**
10
10
  * Scission (divide) the given geometry into the component pieces.
11
11
  *
12
- * @param {...Object} geometries - list of geometries
12
+ * @param {...Object} objects - list of geometries
13
13
  * @returns {Array} list of pieces from each geometry
14
14
  * @alias module:modeling/booleans.scission
15
15
  *