@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
@@ -7,42 +7,47 @@ const { polygon } = require('./index')
7
7
  const comparePoints = require('../../test/helpers/comparePoints')
8
8
 
9
9
  test('polygon: providing only object.points creates expected geometry', (t) => {
10
- let geo = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]] })
10
+ let geometry = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]] })
11
11
 
12
- let obs = geom2.toPoints(geo)
12
+ let obs = geom2.toPoints(geometry)
13
13
  let exp = [[0, 0], [100, 0], [130, 50], [30, 50]]
14
14
 
15
+ t.notThrows(() => geom2.validate(geometry))
15
16
  t.true(comparePoints(obs, exp))
16
17
 
17
- geo = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]] })
18
+ geometry = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]] })
18
19
 
19
- obs = geom2.toPoints(geo)
20
+ obs = geom2.toPoints(geometry)
20
21
  exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
21
22
 
23
+ t.notThrows(() => geom2.validate(geometry))
22
24
  t.true(comparePoints(obs, exp))
23
25
  })
24
26
 
25
27
  test('polygon: providing object.points (array) and object.path (array) creates expected geometry', (t) => {
26
- let geo = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]], paths: [[3, 2, 1, 0]] })
28
+ let geometry = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]], paths: [[3, 2, 1, 0]] })
27
29
 
28
- let obs = geom2.toPoints(geo)
30
+ let obs = geom2.toPoints(geometry)
29
31
  let exp = [[30, 50], [130, 50], [100, 0], [0, 0]]
30
32
 
33
+ t.notThrows(() => geom2.validate(geometry))
31
34
  t.true(comparePoints(obs, exp))
32
35
 
33
36
  // multiple paths
34
- geo = polygon({ points: [[0, 0], [100, 0], [0, 100], [10, 10], [80, 10], [10, 80]], paths: [[0, 1, 2], [3, 4, 5]] })
37
+ geometry = polygon({ points: [[0, 0], [100, 0], [0, 100], [10, 10], [80, 10], [10, 80]], paths: [[0, 1, 2], [3, 4, 5]] })
35
38
 
36
- obs = geom2.toPoints(geo)
39
+ obs = geom2.toPoints(geometry)
37
40
  exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
38
41
 
42
+ t.notThrows(() => geom2.validate(geometry))
39
43
  t.true(comparePoints(obs, exp))
40
44
 
41
45
  // multiple points and paths
42
- geo = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]], paths: [[0, 1, 2], [3, 4, 5]] })
46
+ geometry = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]], paths: [[0, 1, 2], [3, 4, 5]] })
43
47
 
44
- obs = geom2.toPoints(geo)
48
+ obs = geom2.toPoints(geometry)
45
49
  exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
46
50
 
51
+ t.notThrows(() => geom2.validate(geometry))
47
52
  t.true(comparePoints(obs, exp))
48
53
  })
@@ -11,7 +11,7 @@ const { isNumberArray } = require('./commonChecks')
11
11
  * @param {Array} options.points - list of points in 3D space
12
12
  * @param {Array} options.faces - list of faces, where each face is a set of indexes into the points
13
13
  * @param {Array} [options.colors=undefined] - list of RGBA colors to apply to each face
14
- * @param {Array} [options.orientation='outward'] - orientation of faces
14
+ * @param {String} [options.orientation='outward'] - orientation of faces
15
15
  * @returns {geom3} new 3D geometry
16
16
  * @alias module:modeling/primitives.polyhedron
17
17
  *
@@ -14,31 +14,14 @@ test('polyhedron (points and faces)', (t) => {
14
14
  let obs = polyhedron({ points, faces, colors })
15
15
  let pts = geom3.toPoints(obs)
16
16
  let exp = [
17
- [[-1.0000000, -1.0000000, -1.0000000],
18
- [-1.0000000, -1.0000000, 1.0000000],
19
- [-1.0000000, 1.0000000, 1.0000000],
20
- [-1.0000000, 1.0000000, -1.0000000]],
21
- [[1.0000000, -1.0000000, -1.0000000],
22
- [1.0000000, 1.0000000, -1.0000000],
23
- [1.0000000, 1.0000000, 1.0000000],
24
- [1.0000000, -1.0000000, 1.0000000]],
25
- [[-1.0000000, -1.0000000, -1.0000000],
26
- [1.0000000, -1.0000000, -1.0000000],
27
- [1.0000000, -1.0000000, 1.0000000],
28
- [-1.0000000, -1.0000000, 1.0000000]],
29
- [[-1.0000000, 1.0000000, -1.0000000],
30
- [-1.0000000, 1.0000000, 1.0000000],
31
- [1.0000000, 1.0000000, 1.0000000],
32
- [1.0000000, 1.0000000, -1.0000000]],
33
- [[-1.0000000, -1.0000000, -1.0000000],
34
- [-1.0000000, 1.0000000, -1.0000000],
35
- [1.0000000, 1.0000000, -1.0000000],
36
- [1.0000000, -1.0000000, -1.0000000]],
37
- [[-1.0000000, -1.0000000, 1.0000000],
38
- [1.0000000, -1.0000000, 1.0000000],
39
- [1.0000000, 1.0000000, 1.0000000],
40
- [-1.0000000, 1.0000000, 1.0000000]]
17
+ [[-1, -1, -1], [-1, -1, 1], [-1, 1, 1], [-1, 1, -1]],
18
+ [[1, -1, -1], [1, 1, -1], [1, 1, 1], [1, -1, 1]],
19
+ [[-1, -1, -1], [1, -1, -1], [1, -1, 1], [-1, -1, 1]],
20
+ [[-1, 1, -1], [-1, 1, 1], [1, 1, 1], [1, 1, -1]],
21
+ [[-1, -1, -1], [-1, 1, -1], [1, 1, -1], [1, -1, -1]],
22
+ [[-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]]
41
23
  ]
24
+ t.notThrows(() => geom3.validate(obs))
42
25
  t.deepEqual(pts.length, 6)
43
26
  t.true(comparePolygonsAsPoints(pts, exp))
44
27
 
@@ -48,25 +31,14 @@ test('polyhedron (points and faces)', (t) => {
48
31
  obs = polyhedron({ points: points, faces: faces, orientation: 'inward' })
49
32
  pts = geom3.toPoints(obs)
50
33
  exp = [
51
- [[0, 0, 10],
52
- [10, -10, 0],
53
- [10, 10, 0]],
54
- [[0, 0, 10],
55
- [-10, -10, 0],
56
- [10, -10, 0]],
57
- [[0, 0, 10],
58
- [-10, 10, 0],
59
- [-10, -10, 0]],
60
- [[0, 0, 10],
61
- [10, 10, 0],
62
- [-10, 10, 0]],
63
- [[-10, 10, 0],
64
- [10, 10, 0],
65
- [10, -10, 0]],
66
- [[-10, 10, 0],
67
- [10, -10, 0],
68
- [-10, -10, 0]]
34
+ [[0, 0, 10], [10, -10, 0], [10, 10, 0]],
35
+ [[0, 0, 10], [-10, -10, 0], [10, -10, 0]],
36
+ [[0, 0, 10], [-10, 10, 0], [-10, -10, 0]],
37
+ [[0, 0, 10], [10, 10, 0], [-10, 10, 0]],
38
+ [[-10, 10, 0], [10, 10, 0], [10, -10, 0]],
39
+ [[-10, 10, 0], [10, -10, 0], [-10, -10, 0]]
69
40
  ]
41
+ t.notThrows(() => geom3.validate(obs))
70
42
  t.deepEqual(pts.length, 6)
71
43
  t.true(comparePolygonsAsPoints(pts, exp))
72
44
  })
@@ -16,6 +16,7 @@ test('rectangle (defaults)', (t) => {
16
16
  [-1, 1]
17
17
  ]
18
18
 
19
+ t.notThrows(() => geom2.validate(geometry))
19
20
  t.deepEqual(obs.length, 4)
20
21
  t.true(comparePoints(obs, exp))
21
22
  })
@@ -31,6 +32,7 @@ test('rectangle (options)', (t) => {
31
32
  [-5, -3]
32
33
  ]
33
34
 
35
+ t.notThrows(() => geom2.validate(geometry))
34
36
  t.deepEqual(obs.length, 4)
35
37
  t.true(comparePoints(obs, exp))
36
38
 
@@ -44,6 +46,7 @@ test('rectangle (options)', (t) => {
44
46
  [-3, 5]
45
47
  ]
46
48
 
49
+ t.notThrows(() => geom2.validate(geometry))
47
50
  t.deepEqual(obs.length, 4)
48
51
  t.true(comparePoints(obs, exp))
49
52
  })
@@ -10,6 +10,7 @@ test('roundedCuboid (defaults)', (t) => {
10
10
  const obs = roundedCuboid()
11
11
  const pts = geom3.toPoints(obs)
12
12
 
13
+ t.notThrows(() => geom3.validate(obs))
13
14
  t.deepEqual(pts.length, 614)
14
15
  })
15
16
 
@@ -19,6 +20,7 @@ test('roundedCuboid (options)', (t) => {
19
20
  let pts = geom3.toPoints(obs)
20
21
  let exp = []
21
22
 
23
+ t.notThrows(() => geom3.validate(obs))
22
24
  t.is(pts.length, 62)
23
25
 
24
26
  // test center
@@ -27,6 +29,7 @@ test('roundedCuboid (options)', (t) => {
27
29
  exp = [
28
30
  ]
29
31
 
32
+ t.notThrows(() => geom3.validate(obs))
30
33
  t.is(pts.length, 62)
31
34
 
32
35
  // test size
@@ -126,6 +129,7 @@ test('roundedCuboid (options)', (t) => {
126
129
  [[3.8, -4.8, -6], [-3.8, -4.8, -6],
127
130
  [-3.8, 4.8, -6], [3.8, 4.8, -6]]
128
131
  ]
132
+ t.notThrows(() => geom3.validate(obs))
129
133
  t.deepEqual(pts.length, 62)
130
134
  t.true(comparePolygonsAsPoints(pts, exp))
131
135
 
@@ -224,6 +228,7 @@ test('roundedCuboid (options)', (t) => {
224
228
  [[2, 3, 6], [-2, 3, 6], [-2, -3, 6], [2, -3, 6]],
225
229
  [[2, -3, -6], [-2, -3, -6], [-2, 3, -6], [2, 3, -6]]
226
230
  ]
231
+ t.notThrows(() => geom3.validate(obs))
227
232
  t.deepEqual(pts.length, 62)
228
233
  t.true(comparePolygonsAsPoints(pts, exp))
229
234
  })
@@ -5,6 +5,8 @@ const vec3 = require('../maths/vec3')
5
5
  const geom3 = require('../geometries/geom3')
6
6
  const poly3 = require('../geometries/poly3')
7
7
 
8
+ const { sin, cos } = require('../utils/trigonometry')
9
+
8
10
  const { isGT, isGTE, isNumberArray } = require('./commonChecks')
9
11
 
10
12
  /**
@@ -72,8 +74,8 @@ const roundedCylinder = (options) => {
72
74
  const v2 = vec3.create()
73
75
  let prevcylinderpoint
74
76
  for (let slice1 = 0; slice1 <= segments; slice1++) {
75
- const angle = Math.PI * 2.0 * slice1 / segments
76
- const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector, Math.cos(angle)), vec3.scale(v2, yvector, Math.sin(angle)))
77
+ const angle = 2 * Math.PI * slice1 / segments
78
+ const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector, cos(angle)), vec3.scale(v2, yvector, sin(angle)))
77
79
  if (slice1 > 0) {
78
80
  // cylinder wall
79
81
  let points = []
@@ -86,8 +88,8 @@ const roundedCylinder = (options) => {
86
88
  let prevcospitch, prevsinpitch
87
89
  for (let slice2 = 0; slice2 <= qsegments; slice2++) {
88
90
  const pitch = 0.5 * Math.PI * slice2 / qsegments
89
- const cospitch = Math.cos(pitch)
90
- const sinpitch = Math.sin(pitch)
91
+ const cospitch = cos(pitch)
92
+ const sinpitch = sin(pitch)
91
93
  if (slice2 > 0) {
92
94
  // cylinder rounding, start
93
95
  points = []
@@ -10,6 +10,7 @@ test('roundedCylinder (defaults)', (t) => {
10
10
  const obs = roundedCylinder()
11
11
  const pts = geom3.toPoints(obs)
12
12
 
13
+ t.notThrows(() => geom3.validate(obs))
13
14
  t.is(pts.length, 544)
14
15
  })
15
16
 
@@ -20,6 +21,7 @@ test('roundedCylinder (options)', (t) => {
20
21
  let exp = [
21
22
  ]
22
23
 
24
+ t.notThrows(() => geom3.validate(obs))
23
25
  t.is(pts.length, 15)
24
26
 
25
27
  // test center
@@ -48,6 +50,7 @@ test('roundedCylinder (options)', (t) => {
48
50
  [[-5, -5, -4], [-5, -4, -4.2], [-5.951056516295154, -4.6909830056250525, -4.2]]
49
51
  ]
50
52
 
53
+ t.notThrows(() => geom3.validate(obs))
51
54
  t.is(pts.length, 15)
52
55
  t.true(comparePolygonsAsPoints(pts, exp))
53
56
 
@@ -57,26 +60,27 @@ test('roundedCylinder (options)', (t) => {
57
60
  exp = [
58
61
  [[0.9510565162951535, 0.30901699437494745, -9.8], [0, 1, -9.8],
59
62
  [0, 1, 9.8], [0.9510565162951535, 0.30901699437494745, 9.8]],
60
- [[0, 1, -9.8], [0.9510565162951535, 0.30901699437494745, -9.8], [0, 6.123233995736766e-17, -10]],
61
- [[0, 6.123233995736766e-17, 10], [0.9510565162951535, 0.30901699437494745, 9.8], [0, 1, 9.8]],
63
+ [[0, 1, -9.8], [0.9510565162951535, 0.30901699437494745, -9.8], [0, 0, -10]],
64
+ [[0, 0, 10], [0.9510565162951535, 0.30901699437494745, 9.8], [0, 1, 9.8]],
62
65
  [[0.5877852522924732, -0.8090169943749473, -9.8], [0.9510565162951535, 0.30901699437494745, -9.8],
63
66
  [0.9510565162951535, 0.30901699437494745, 9.8], [0.5877852522924732, -0.8090169943749473, 9.8]],
64
- [[0.9510565162951535, 0.30901699437494745, -9.8], [0.5877852522924732, -0.8090169943749473, -9.8], [5.823541592445462e-17, 1.8921833652170753e-17, -10]],
65
- [[5.823541592445462e-17, 1.8921833652170753e-17, 10], [0.5877852522924732, -0.8090169943749473, 9.8], [0.9510565162951535, 0.30901699437494745, 9.8]],
67
+ [[0.9510565162951535, 0.30901699437494745, -9.8], [0.5877852522924732, -0.8090169943749473, -9.8], [0, 0, -10]],
68
+ [[0, 0, 10], [0.5877852522924732, -0.8090169943749473, 9.8], [0.9510565162951535, 0.30901699437494745, 9.8]],
66
69
  [[-0.587785252292473, -0.8090169943749475, -9.8], [0.5877852522924732, -0.8090169943749473, -9.8],
67
70
  [0.5877852522924732, -0.8090169943749473, 9.8], [-0.587785252292473, -0.8090169943749475, 9.8]],
68
- [[0.5877852522924732, -0.8090169943749473, -9.8], [-0.587785252292473, -0.8090169943749475, -9.8], [3.599146639029984e-17, -4.9538003630854574e-17, -10]],
69
- [[3.599146639029984e-17, -4.9538003630854574e-17, 10], [-0.587785252292473, -0.8090169943749475, 9.8], [0.5877852522924732, -0.8090169943749473, 9.8]],
71
+ [[0.5877852522924732, -0.8090169943749473, -9.8], [-0.587785252292473, -0.8090169943749475, -9.8], [0, 0, -10]],
72
+ [[0, 0, 10], [-0.587785252292473, -0.8090169943749475, 9.8], [0.5877852522924732, -0.8090169943749473, 9.8]],
70
73
  [[-0.9510565162951536, 0.30901699437494723, -9.8], [-0.587785252292473, -0.8090169943749475, -9.8],
71
74
  [-0.587785252292473, -0.8090169943749475, 9.8], [-0.9510565162951536, 0.30901699437494723, 9.8]],
72
- [[-0.587785252292473, -0.8090169943749475, -9.8], [-0.9510565162951536, 0.30901699437494723, -9.8], [-3.5991466390299825e-17, -4.953800363085458e-17, -10]],
73
- [[-3.5991466390299825e-17, -4.953800363085458e-17, 10], [-0.9510565162951536, 0.30901699437494723, 9.8], [-0.587785252292473, -0.8090169943749475, 9.8]],
74
- [[-2.4492935982947064e-16, 1, -9.8], [-0.9510565162951536, 0.30901699437494723, -9.8],
75
- [-0.9510565162951536, 0.30901699437494723, 9.8], [-2.4492935982947064e-16, 1, 9.8]],
76
- [[-0.9510565162951536, 0.30901699437494723, -9.8], [-2.4492935982947064e-16, 1, -9.8], [-5.823541592445463e-17, 1.8921833652170737e-17, -10]],
77
- [[-5.823541592445463e-17, 1.8921833652170737e-17, 10], [-2.4492935982947064e-16, 1, 9.8], [-0.9510565162951536, 0.30901699437494723, 9.8]]
75
+ [[-0.587785252292473, -0.8090169943749475, -9.8], [-0.9510565162951536, 0.30901699437494723, -9.8], [0, 0, -10]],
76
+ [[0, 0, 10], [-0.9510565162951536, 0.30901699437494723, 9.8], [-0.587785252292473, -0.8090169943749475, 9.8]],
77
+ [[0, 1, -9.8], [-0.9510565162951536, 0.30901699437494723, -9.8],
78
+ [-0.9510565162951536, 0.30901699437494723, 9.8], [0, 1, 9.8]],
79
+ [[-0.9510565162951536, 0.30901699437494723, -9.8], [0, 1, -9.8], [0, 0, -10]],
80
+ [[0, 0, 10], [0, 1, 9.8], [-0.9510565162951536, 0.30901699437494723, 9.8]]
78
81
  ]
79
82
 
83
+ t.notThrows(() => geom3.validate(obs))
80
84
  t.is(pts.length, 15)
81
85
  t.true(comparePolygonsAsPoints(pts, exp))
82
86
 
@@ -86,26 +90,26 @@ test('roundedCylinder (options)', (t) => {
86
90
  exp = [
87
91
  [[9.510565162951535, 3.0901699437494745, -0.8], [0, 10, -0.8],
88
92
  [0, 10, 0.8], [9.510565162951535, 3.0901699437494745, 0.8]],
89
- [[0, 10, -0.8], [9.510565162951535, 3.0901699437494745, -0.8], [0, 6.123233995736766e-16, -1]],
90
- [[0, 6.123233995736766e-16, 1], [9.510565162951535, 3.0901699437494745, 0.8], [0, 10, 0.8]],
93
+ [[0, 10, -0.8], [9.510565162951535, 3.0901699437494745, -0.8], [0, 0, -1]],
94
+ [[0, 0, 1], [9.510565162951535, 3.0901699437494745, 0.8], [0, 10, 0.8]],
91
95
  [[5.877852522924733, -8.090169943749473, -0.8], [9.510565162951535, 3.0901699437494745, -0.8],
92
96
  [9.510565162951535, 3.0901699437494745, 0.8], [5.877852522924733, -8.090169943749473, 0.8]],
93
- [[9.510565162951535, 3.0901699437494745, -0.8], [5.877852522924733, -8.090169943749473, -0.8], [5.823541592445461e-16, 1.8921833652170753e-16, -1]],
94
- [[5.823541592445461e-16, 1.8921833652170753e-16, 1], [5.877852522924733, -8.090169943749473, 0.8], [9.510565162951535, 3.0901699437494745, 0.8]],
97
+ [[9.510565162951535, 3.0901699437494745, -0.8], [5.877852522924733, -8.090169943749473, -0.8], [0, 0, -1]],
98
+ [[0, 0, 1], [5.877852522924733, -8.090169943749473, 0.8], [9.510565162951535, 3.0901699437494745, 0.8]],
95
99
  [[-5.87785252292473, -8.090169943749475, -0.8], [5.877852522924733, -8.090169943749473, -0.8],
96
100
  [5.877852522924733, -8.090169943749473, 0.8], [-5.87785252292473, -8.090169943749475, 0.8]],
97
- [[5.877852522924733, -8.090169943749473, -0.8], [-5.87785252292473, -8.090169943749475, -0.8], [3.599146639029984e-16, -4.953800363085457e-16, -1]],
98
- [[3.599146639029984e-16, -4.953800363085457e-16, 1], [-5.87785252292473, -8.090169943749475, 0.8], [5.877852522924733, -8.090169943749473, 0.8]],
101
+ [[5.877852522924733, -8.090169943749473, -0.8], [-5.87785252292473, -8.090169943749475, -0.8], [0, 0, -1]],
102
+ [[0, 0, 1], [-5.87785252292473, -8.090169943749475, 0.8], [5.877852522924733, -8.090169943749473, 0.8]],
99
103
  [[-9.510565162951536, 3.0901699437494723, -0.8], [-5.87785252292473, -8.090169943749475, -0.8],
100
104
  [-5.87785252292473, -8.090169943749475, 0.8], [-9.510565162951536, 3.0901699437494723, 0.8]],
101
- [[-5.87785252292473, -8.090169943749475, -0.8], [-9.510565162951536, 3.0901699437494723, -0.8], [-3.5991466390299825e-16, -4.953800363085459e-16, -1]],
102
- [[-3.5991466390299825e-16, -4.953800363085459e-16, 1], [-9.510565162951536, 3.0901699437494723, 0.8], [-5.87785252292473, -8.090169943749475, 0.8]],
103
- [[-2.4492935982947065e-15, 10, -0.8], [-9.510565162951536, 3.0901699437494723, -0.8],
104
- [-9.510565162951536, 3.0901699437494723, 0.8], [-2.4492935982947065e-15, 10, 0.8]],
105
- [[-9.510565162951536, 3.0901699437494723, -0.8], [-2.4492935982947065e-15, 10, -0.8], [-5.823541592445462e-16, 1.8921833652170739e-16, -1]],
106
- [[-5.823541592445462e-16, 1.8921833652170739e-16, 1], [-2.4492935982947065e-15, 10, 0.8], [-9.510565162951536, 3.0901699437494723, 0.8]]
105
+ [[-5.87785252292473, -8.090169943749475, -0.8], [-9.510565162951536, 3.0901699437494723, -0.8], [0, 0, -1]],
106
+ [[0, 0, 1], [-9.510565162951536, 3.0901699437494723, 0.8], [-5.87785252292473, -8.090169943749475, 0.8]],
107
+ [[0, 10, -0.8], [-9.510565162951536, 3.0901699437494723, -0.8], [-9.510565162951536, 3.0901699437494723, 0.8], [0, 10, 0.8]],
108
+ [[-9.510565162951536, 3.0901699437494723, -0.8], [0, 10, -0.8], [0, 0, -1]],
109
+ [[0, 0, 1], [0, 10, 0.8], [-9.510565162951536, 3.0901699437494723, 0.8]]
107
110
  ]
108
111
 
112
+ t.notThrows(() => geom3.validate(obs))
109
113
  t.is(pts.length, 15)
110
114
  t.true(comparePolygonsAsPoints(pts, exp))
111
115
 
@@ -115,26 +119,26 @@ test('roundedCylinder (options)', (t) => {
115
119
  exp = [
116
120
  [[4.755282581475767, 1.5450849718747373, -8], [0, 5, -8],
117
121
  [0, 5, 8], [4.755282581475767, 1.5450849718747373, 8]],
118
- [[0, 5, -8], [4.755282581475767, 1.5450849718747373, -8], [0, 3.061616997868383e-16, -10]],
119
- [[0, 3.061616997868383e-16, 10], [4.755282581475767, 1.5450849718747373, 8], [0, 5, 8]],
122
+ [[0, 5, -8], [4.755282581475767, 1.5450849718747373, -8], [0, 0, -10]],
123
+ [[0, 0, 10], [4.755282581475767, 1.5450849718747373, 8], [0, 5, 8]],
120
124
  [[2.9389262614623664, -4.045084971874736, -8], [4.755282581475767, 1.5450849718747373, -8],
121
125
  [4.755282581475767, 1.5450849718747373, 8], [2.9389262614623664, -4.045084971874736, 8]],
122
- [[4.755282581475767, 1.5450849718747373, -8], [2.9389262614623664, -4.045084971874736, -8], [2.9117707962227305e-16, 9.460916826085377e-17, -10]],
123
- [[2.9117707962227305e-16, 9.460916826085377e-17, 10], [2.9389262614623664, -4.045084971874736, 8], [4.755282581475767, 1.5450849718747373, 8]],
126
+ [[4.755282581475767, 1.5450849718747373, -8], [2.9389262614623664, -4.045084971874736, -8], [0, 0, -10]],
127
+ [[0, 0, 10], [2.9389262614623664, -4.045084971874736, 8], [4.755282581475767, 1.5450849718747373, 8]],
124
128
  [[-2.938926261462365, -4.045084971874737, -8], [2.9389262614623664, -4.045084971874736, -8],
125
129
  [2.9389262614623664, -4.045084971874736, 8], [-2.938926261462365, -4.045084971874737, 8]],
126
- [[2.9389262614623664, -4.045084971874736, -8], [-2.938926261462365, -4.045084971874737, -8], [1.799573319514992e-16, -2.4769001815427284e-16, -10]],
127
- [[1.799573319514992e-16, -2.4769001815427284e-16, 10], [-2.938926261462365, -4.045084971874737, 8], [2.9389262614623664, -4.045084971874736, 8]],
130
+ [[2.9389262614623664, -4.045084971874736, -8], [-2.938926261462365, -4.045084971874737, -8], [0, 0, -10]],
131
+ [[0, 0, 10], [-2.938926261462365, -4.045084971874737, 8], [2.9389262614623664, -4.045084971874736, 8]],
128
132
  [[-4.755282581475768, 1.5450849718747361, -8], [-2.938926261462365, -4.045084971874737, -8],
129
133
  [-2.938926261462365, -4.045084971874737, 8], [-4.755282581475768, 1.5450849718747361, 8]],
130
- [[-2.938926261462365, -4.045084971874737, -8], [-4.755282581475768, 1.5450849718747361, -8], [-1.7995733195149913e-16, -2.4769001815427294e-16, -10]],
131
- [[-1.7995733195149913e-16, -2.4769001815427294e-16, 10], [-4.755282581475768, 1.5450849718747361, 8], [-2.938926261462365, -4.045084971874737, 8]],
132
- [[-1.2246467991473533e-15, 5, -8], [-4.755282581475768, 1.5450849718747361, -8],
133
- [-4.755282581475768, 1.5450849718747361, 8], [-1.2246467991473533e-15, 5, 8]],
134
- [[-4.755282581475768, 1.5450849718747361, -8], [-1.2246467991473533e-15, 5, -8], [-2.911770796222731e-16, 9.460916826085369e-17, -10]],
135
- [[-2.911770796222731e-16, 9.460916826085369e-17, 10], [-1.2246467991473533e-15, 5, 8], [-4.755282581475768, 1.5450849718747361, 8]]
134
+ [[-2.938926261462365, -4.045084971874737, -8], [-4.755282581475768, 1.5450849718747361, -8], [0, 0, -10]],
135
+ [[0, 0, 10], [-4.755282581475768, 1.5450849718747361, 8], [-2.938926261462365, -4.045084971874737, 8]],
136
+ [[0, 5, -8], [-4.755282581475768, 1.5450849718747361, -8], [-4.755282581475768, 1.5450849718747361, 8], [0, 5, 8]],
137
+ [[-4.755282581475768, 1.5450849718747361, -8], [0, 5, -8], [0, 0, -10]],
138
+ [[0, 0, 10], [0, 5, 8], [-4.755282581475768, 1.5450849718747361, 8]]
136
139
  ]
137
140
 
141
+ t.notThrows(() => geom3.validate(obs))
138
142
  t.is(pts.length, 15)
139
143
  t.true(comparePolygonsAsPoints(pts, exp))
140
144
  })
@@ -10,6 +10,7 @@ test('roundedRectangle (defaults)', (t) => {
10
10
  const geometry = roundedRectangle()
11
11
  const obs = geom2.toPoints(geometry)
12
12
 
13
+ t.notThrows(() => geom2.validate(geometry))
13
14
  t.deepEqual(obs.length, 36)
14
15
  })
15
16
 
@@ -39,6 +40,7 @@ test('roundedRectangle (options)', (t) => {
39
40
  [4.984775906502257, 4.123463313526982],
40
41
  [5, 4.2]
41
42
  ]
43
+ t.notThrows(() => geom2.validate(geometry))
42
44
  t.deepEqual(obs.length, 20)
43
45
  t.true(comparePoints(obs, exp))
44
46
 
@@ -67,6 +69,7 @@ test('roundedRectangle (options)', (t) => {
67
69
  [4.984775906502257, -2.8765366864730177],
68
70
  [5, -2.8]
69
71
  ]
72
+ t.notThrows(() => geom2.validate(geometry))
70
73
  t.deepEqual(obs.length, 20)
71
74
  t.true(comparePoints(obs, exp))
72
75
 
@@ -95,11 +98,13 @@ test('roundedRectangle (options)', (t) => {
95
98
  [4.847759065022574, -1.7653668647301801],
96
99
  [5, -1.0000000000000004]
97
100
  ]
101
+ t.notThrows(() => geom2.validate(geometry))
98
102
  t.deepEqual(obs.length, 20)
99
103
  t.true(comparePoints(obs, exp))
100
104
 
101
105
  // test segments
102
106
  geometry = roundedRectangle({ size: [10, 6], roundRadius: 2, segments: 64 })
103
107
  obs = geom2.toPoints(geometry)
108
+ t.notThrows(() => geom2.validate(geometry))
104
109
  t.deepEqual(obs.length, 68)
105
110
  })
@@ -10,6 +10,7 @@ test('sphere (defaults)', (t) => {
10
10
  const obs = sphere()
11
11
  const pts = geom3.toPoints(obs)
12
12
 
13
+ t.notThrows(() => geom3.validate(obs))
13
14
  t.is(pts.length, 512)
14
15
  })
15
16
 
@@ -18,6 +19,7 @@ test('sphere (options)', (t) => {
18
19
  let obs = sphere({ radius: 5, segments: 12 })
19
20
  let pts = geom3.toPoints(obs)
20
21
  let exp = []
22
+ t.notThrows(() => geom3.validate(obs))
21
23
  t.is(pts.length, 72)
22
24
  // t.true(comparePolygonsAsPoints(pts, exp))
23
25
 
@@ -29,102 +31,78 @@ test('sphere (options)', (t) => {
29
31
  [0.5000000000000001, -0.5, -0.7071067811865475], [0.7071067811865476, 0, -0.7071067811865475]],
30
32
  [[0.7071067811865476, 0, 0.7071067811865475], [0.5000000000000001, -0.5, 0.7071067811865475],
31
33
  [0.7071067811865476, -0.7071067811865475, 0], [1, 0, 0]],
32
- [[0.7071067811865476, 0, -0.7071067811865475], [0.5000000000000001, -0.5, -0.7071067811865475], [6.123233995736766e-17, 0, -1]],
33
- [[6.123233995736766e-17, 0, 1], [0.5000000000000001, -0.5, 0.7071067811865475], [0.7071067811865476, 0, 0.7071067811865475]],
34
- [[0.7071067811865476, -0.7071067811865475, 0], [6.123233995736766e-17, -1, 0],
35
- [4.329780281177467e-17, -0.7071067811865476, -0.7071067811865475], [0.5000000000000001, -0.5, -0.7071067811865475]],
36
- [[0.5000000000000001, -0.5, 0.7071067811865475], [4.329780281177467e-17, -0.7071067811865476, 0.7071067811865475],
37
- [6.123233995736766e-17, -1, 0], [0.7071067811865476, -0.7071067811865475, 0]],
38
- [[0.5000000000000001, -0.5, -0.7071067811865475], [4.329780281177467e-17, -0.7071067811865476, -0.7071067811865475],
39
- [4.329780281177467e-17, -4.329780281177466e-17, -1]],
40
- [[4.329780281177467e-17, -4.329780281177466e-17, 1],
41
- [4.329780281177467e-17, -0.7071067811865476, 0.7071067811865475],
34
+ [[0.7071067811865476, 0, -0.7071067811865475], [0.5000000000000001, -0.5, -0.7071067811865475], [0, 0, -1]],
35
+ [[0, 0, 1], [0.5000000000000001, -0.5, 0.7071067811865475], [0.7071067811865476, 0, 0.7071067811865475]],
36
+ [[0.7071067811865476, -0.7071067811865475, 0], [0, -1, 0],
37
+ [0, -0.7071067811865476, -0.7071067811865475], [0.5000000000000001, -0.5, -0.7071067811865475]],
38
+ [[0.5000000000000001, -0.5, 0.7071067811865475], [0, -0.7071067811865476, 0.7071067811865475],
39
+ [0, -1, 0], [0.7071067811865476, -0.7071067811865475, 0]],
40
+ [[0.5000000000000001, -0.5, -0.7071067811865475],
41
+ [0, -0.7071067811865476, -0.7071067811865475], [0, 0, -1]],
42
+ [[0, 0, 1], [0, -0.7071067811865476, 0.7071067811865475],
42
43
  [0.5000000000000001, -0.5, 0.7071067811865475]],
43
- [[6.123233995736766e-17, -1, 0],
44
- [-0.7071067811865475, -0.7071067811865476, 0],
44
+ [[0, -1, 0], [-0.7071067811865475, -0.7071067811865476, 0],
45
45
  [-0.5, -0.5000000000000001, -0.7071067811865475],
46
- [4.329780281177467e-17, -0.7071067811865476, -0.7071067811865475]],
47
- [[4.329780281177467e-17, -0.7071067811865476, 0.7071067811865475],
46
+ [0, -0.7071067811865476, -0.7071067811865475]],
47
+ [[0, -0.7071067811865476, 0.7071067811865475],
48
48
  [-0.5, -0.5000000000000001, 0.7071067811865475],
49
- [-0.7071067811865475, -0.7071067811865476, 0],
50
- [6.123233995736766e-17, -1, 0]],
51
- [[4.329780281177467e-17, -0.7071067811865476, -0.7071067811865475],
52
- [-0.5, -0.5000000000000001, -0.7071067811865475],
53
- [3.749399456654644e-33, -6.123233995736766e-17, -1]],
54
- [[3.749399456654644e-33, -6.123233995736766e-17, 1],
55
- [-0.5, -0.5000000000000001, 0.7071067811865475],
56
- [4.329780281177467e-17, -0.7071067811865476, 0.7071067811865475]],
57
- [[-0.7071067811865475, -0.7071067811865476, 0],
58
- [-1, -1.2246467991473532e-16, 0],
59
- [-0.7071067811865476, -8.659560562354934e-17, -0.7071067811865475],
49
+ [-0.7071067811865475, -0.7071067811865476, 0], [0, -1, 0]],
50
+ [[0, -0.7071067811865476, -0.7071067811865475],
51
+ [-0.5, -0.5000000000000001, -0.7071067811865475], [0, 0, -1]],
52
+ [[0, 0, 1], [-0.5, -0.5000000000000001, 0.7071067811865475],
53
+ [0, -0.7071067811865476, 0.7071067811865475]],
54
+ [[-0.7071067811865475, -0.7071067811865476, 0], [-1, 0, 0],
55
+ [-0.7071067811865476, 0, -0.7071067811865475],
60
56
  [-0.5, -0.5000000000000001, -0.7071067811865475]],
61
57
  [[-0.5, -0.5000000000000001, 0.7071067811865475],
62
- [-0.7071067811865476, -8.659560562354934e-17, 0.7071067811865475],
63
- [-1, -1.2246467991473532e-16, 0],
58
+ [-0.7071067811865476, 0, 0.7071067811865475], [-1, 0, 0],
64
59
  [-0.7071067811865475, -0.7071067811865476, 0]],
65
60
  [[-0.5, -0.5000000000000001, -0.7071067811865475],
66
- [-0.7071067811865476, -8.659560562354934e-17, -0.7071067811865475],
67
- [-4.329780281177466e-17, -4.329780281177467e-17, -1]],
68
- [[-4.329780281177466e-17, -4.329780281177467e-17, 1],
69
- [-0.7071067811865476, -8.659560562354934e-17, 0.7071067811865475],
61
+ [-0.7071067811865476, 0, -0.7071067811865475], [0, 0, -1]],
62
+ [[0, 0, 1], [-0.7071067811865476, 0, 0.7071067811865475],
70
63
  [-0.5, -0.5000000000000001, 0.7071067811865475]],
71
- [[-1, -1.2246467991473532e-16, 0],
72
- [-0.7071067811865477, 0.7071067811865475, 0],
73
- [-0.5000000000000001, 0.5, -0.7071067811865475],
74
- [-0.7071067811865476, -8.659560562354934e-17, -0.7071067811865475]],
75
- [[-0.7071067811865476, -8.659560562354934e-17, 0.7071067811865475],
76
- [-0.5000000000000001, 0.5, 0.7071067811865475],
77
- [-0.7071067811865477, 0.7071067811865475, 0],
78
- [-1, -1.2246467991473532e-16, 0]],
79
- [[-0.7071067811865476, -8.659560562354934e-17, -0.7071067811865475],
64
+ [[-1, 0, 0], [-0.7071067811865477, 0.7071067811865475, 0],
80
65
  [-0.5000000000000001, 0.5, -0.7071067811865475],
81
- [-6.123233995736766e-17, -7.498798913309288e-33, -1]],
82
- [[-6.123233995736766e-17, -7.498798913309288e-33, 1],
66
+ [-0.7071067811865476, 0, -0.7071067811865475]],
67
+ [[-0.7071067811865476, 0, 0.7071067811865475],
83
68
  [-0.5000000000000001, 0.5, 0.7071067811865475],
84
- [-0.7071067811865476, -8.659560562354934e-17, 0.7071067811865475]],
85
- [[-0.7071067811865477, 0.7071067811865475, 0],
86
- [-1.8369701987210297e-16, 1, 0],
87
- [-1.29893408435324e-16, 0.7071067811865476, -0.7071067811865475],
69
+ [-0.7071067811865477, 0.7071067811865475, 0], [-1, 0, 0]],
70
+ [[-0.7071067811865476, 0, -0.7071067811865475],
71
+ [-0.5000000000000001, 0.5, -0.7071067811865475], [0, 0, -1]],
72
+ [[0, 0, 1], [-0.5000000000000001, 0.5, 0.7071067811865475],
73
+ [-0.7071067811865476, 0, 0.7071067811865475]],
74
+ [[-0.7071067811865477, 0.7071067811865475, 0], [0, 1, 0],
75
+ [0, 0.7071067811865476, -0.7071067811865475],
88
76
  [-0.5000000000000001, 0.5, -0.7071067811865475]],
89
77
  [[-0.5000000000000001, 0.5, 0.7071067811865475],
90
- [-1.29893408435324e-16, 0.7071067811865476, 0.7071067811865475],
91
- [-1.8369701987210297e-16, 1, 0],
78
+ [0, 0.7071067811865476, 0.7071067811865475], [0, 1, 0],
92
79
  [-0.7071067811865477, 0.7071067811865475, 0]],
93
80
  [[-0.5000000000000001, 0.5, -0.7071067811865475],
94
- [-1.29893408435324e-16, 0.7071067811865476, -0.7071067811865475],
95
- [-4.3297802811774677e-17, 4.329780281177466e-17, -1]],
96
- [[-4.3297802811774677e-17, 4.329780281177466e-17, 1],
97
- [-1.29893408435324e-16, 0.7071067811865476, 0.7071067811865475],
81
+ [0, 0.7071067811865476, -0.7071067811865475], [0, 0, -1]],
82
+ [[0, 0, 1], [0, 0.7071067811865476, 0.7071067811865475],
98
83
  [-0.5000000000000001, 0.5, 0.7071067811865475]],
99
- [[-1.8369701987210297e-16, 1, 0],
100
- [0.7071067811865474, 0.7071067811865477, 0],
101
- [0.4999999999999999, 0.5000000000000001, -0.7071067811865475],
102
- [-1.29893408435324e-16, 0.7071067811865476, -0.7071067811865475]],
103
- [[-1.29893408435324e-16, 0.7071067811865476, 0.7071067811865475],
104
- [0.4999999999999999, 0.5000000000000001, 0.7071067811865475],
105
- [0.7071067811865474, 0.7071067811865477, 0],
106
- [-1.8369701987210297e-16, 1, 0]],
107
- [[-1.29893408435324e-16, 0.7071067811865476, -0.7071067811865475],
84
+ [[0, 1, 0], [0.7071067811865474, 0.7071067811865477, 0],
108
85
  [0.4999999999999999, 0.5000000000000001, -0.7071067811865475],
109
- [-1.1248198369963932e-32, 6.123233995736766e-17, -1]],
110
- [[-1.1248198369963932e-32, 6.123233995736766e-17, 1],
86
+ [0, 0.7071067811865476, -0.7071067811865475]],
87
+ [[0, 0.7071067811865476, 0.7071067811865475],
111
88
  [0.4999999999999999, 0.5000000000000001, 0.7071067811865475],
112
- [-1.29893408435324e-16, 0.7071067811865476, 0.7071067811865475]],
113
- [[0.7071067811865474, 0.7071067811865477, 0],
114
- [1, 2.4492935982947064e-16, 0],
115
- [0.7071067811865476, 1.7319121124709868e-16, -0.7071067811865475],
89
+ [0.7071067811865474, 0.7071067811865477, 0], [0, 1, 0]],
90
+ [[0, 0.7071067811865476, -0.7071067811865475],
91
+ [0.4999999999999999, 0.5000000000000001, -0.7071067811865475], [0, 0, -1]],
92
+ [[0, 0, 1], [0.4999999999999999, 0.5000000000000001, 0.7071067811865475],
93
+ [0, 0.7071067811865476, 0.7071067811865475]],
94
+ [[0.7071067811865474, 0.7071067811865477, 0], [1, 0, 0],
95
+ [0.7071067811865476, 0, -0.7071067811865475],
116
96
  [0.4999999999999999, 0.5000000000000001, -0.7071067811865475]],
117
97
  [[0.4999999999999999, 0.5000000000000001, 0.7071067811865475],
118
- [0.7071067811865476, 1.7319121124709868e-16, 0.7071067811865475],
119
- [1, 2.4492935982947064e-16, 0],
98
+ [0.7071067811865476, 0, 0.7071067811865475], [1, 0, 0],
120
99
  [0.7071067811865474, 0.7071067811865477, 0]],
121
100
  [[0.4999999999999999, 0.5000000000000001, -0.7071067811865475],
122
- [0.7071067811865476, 1.7319121124709868e-16, -0.7071067811865475],
123
- [4.329780281177465e-17, 4.3297802811774677e-17, -1]],
124
- [[4.329780281177465e-17, 4.3297802811774677e-17, 1],
125
- [0.7071067811865476, 1.7319121124709868e-16, 0.7071067811865475],
101
+ [0.7071067811865476, 0, -0.7071067811865475], [0, 0, -1]],
102
+ [[0, 0, 1], [0.7071067811865476, 0, 0.7071067811865475],
126
103
  [0.4999999999999999, 0.5000000000000001, 0.7071067811865475]]
127
104
  ]
105
+ t.notThrows(() => geom3.validate(obs))
128
106
  t.is(pts.length, 32)
129
107
  t.true(comparePolygonsAsPoints(pts, exp))
130
108
 
@@ -181,6 +159,7 @@ test('sphere (options)', (t) => {
181
159
  [[-2.5, 5.5, 6.292893218813452], [-2.2928932188134525, 5, 6.292893218813452], [-3, 5, 6]],
182
160
  [[-3, 5, 8], [-2.2928932188134525, 5, 7.707106781186548], [-2.5, 5.5, 7.707106781186548]]
183
161
  ]
162
+ t.notThrows(() => geom3.validate(obs))
184
163
  t.is(pts.length, 32)
185
164
  t.true(comparePolygonsAsPoints(pts, exp))
186
165
  })
@@ -9,6 +9,7 @@ const comparePoints = require('../../test/helpers/comparePoints')
9
9
  test('square (defaults)', (t) => {
10
10
  const geometry = square()
11
11
  const obs = geom2.toPoints(geometry)
12
+ t.notThrows(() => geom2.validate(geometry))
12
13
  t.deepEqual(obs.length, 4)
13
14
  })
14
15
 
@@ -23,6 +24,7 @@ test('square (options)', (t) => {
23
24
  [3, 10]
24
25
  ]
25
26
 
27
+ t.notThrows(() => geom2.validate(obs))
26
28
  t.is(pts.length, 4)
27
29
  t.true(comparePoints(pts, exp))
28
30
 
@@ -36,6 +38,7 @@ test('square (options)', (t) => {
36
38
  [-3.5, 3.5]
37
39
  ]
38
40
 
41
+ t.notThrows(() => geom2.validate(obs))
39
42
  t.is(pts.length, 4)
40
43
  t.true(comparePoints(pts, exp))
41
44
  })