@jscad/modeling 2.9.0 → 2.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +4 -4
  3. package/dist/jscad-modeling.min.js +437 -428
  4. package/package.json +3 -2
  5. package/src/colors/colorize.test.js +1 -1
  6. package/src/geometries/geom2/index.d.ts +1 -0
  7. package/src/geometries/geom2/index.js +2 -1
  8. package/src/geometries/geom2/toOutlines.js +66 -52
  9. package/src/geometries/geom2/validate.d.ts +3 -0
  10. package/src/geometries/geom2/validate.js +36 -0
  11. package/src/geometries/geom3/create.js +1 -1
  12. package/src/geometries/geom3/create.test.js +1 -1
  13. package/src/geometries/geom3/fromPoints.js +1 -1
  14. package/src/geometries/geom3/index.d.ts +1 -0
  15. package/src/geometries/geom3/index.js +2 -1
  16. package/src/geometries/geom3/isA.js +1 -1
  17. package/src/geometries/geom3/validate.d.ts +3 -0
  18. package/src/geometries/geom3/validate.js +62 -0
  19. package/src/geometries/path2/index.d.ts +1 -1
  20. package/src/geometries/path2/index.js +2 -2
  21. package/src/geometries/path2/validate.d.ts +3 -0
  22. package/src/geometries/path2/validate.js +41 -0
  23. package/src/geometries/poly2/arePointsInside.js +0 -35
  24. package/src/geometries/poly3/create.js +1 -1
  25. package/src/geometries/poly3/index.d.ts +1 -0
  26. package/src/geometries/poly3/index.js +2 -1
  27. package/src/geometries/poly3/measureArea.test.js +16 -16
  28. package/src/geometries/poly3/measureBoundingSphere.test.js +8 -8
  29. package/src/geometries/poly3/validate.d.ts +4 -0
  30. package/src/geometries/poly3/validate.js +64 -0
  31. package/src/maths/constants.d.ts +1 -0
  32. package/src/maths/constants.js +11 -0
  33. package/src/maths/utils/aboutEqualNormals.js +1 -5
  34. package/src/measurements/measureCenterOfMass.test.js +2 -2
  35. package/src/operations/booleans/intersect.test.js +8 -0
  36. package/src/operations/booleans/intersectGeom3.js +2 -1
  37. package/src/operations/booleans/scission.test.js +4 -4
  38. package/src/operations/booleans/subtract.test.js +8 -0
  39. package/src/operations/booleans/subtractGeom3.js +2 -1
  40. package/src/operations/booleans/to3DWalls.js +1 -1
  41. package/src/operations/booleans/trees/Node.js +10 -16
  42. package/src/operations/booleans/trees/PolygonTreeNode.js +13 -14
  43. package/src/operations/booleans/trees/Tree.js +1 -2
  44. package/src/operations/booleans/trees/splitPolygonByPlane.js +2 -3
  45. package/src/operations/booleans/union.test.js +27 -0
  46. package/src/operations/booleans/unionGeom3.js +2 -1
  47. package/src/operations/expansions/expand.test.js +30 -21
  48. package/src/operations/expansions/expandGeom3.test.js +14 -14
  49. package/src/operations/expansions/expandShell.js +5 -4
  50. package/src/operations/expansions/extrudePolygon.js +7 -7
  51. package/src/operations/expansions/offset.test.js +25 -0
  52. package/src/operations/extrusions/earcut/assignHoles.js +7 -3
  53. package/src/operations/extrusions/earcut/assignHoles.test.js +50 -4
  54. package/src/operations/extrusions/earcut/linkedList.js +1 -1
  55. package/src/operations/extrusions/extrudeFromSlices.test.js +16 -10
  56. package/src/operations/extrusions/extrudeLinear.test.js +15 -9
  57. package/src/operations/extrusions/extrudeRectangular.test.js +15 -8
  58. package/src/operations/extrusions/extrudeRotate.js +5 -1
  59. package/src/operations/extrusions/extrudeRotate.test.js +12 -0
  60. package/src/operations/extrusions/extrudeWalls.js +2 -2
  61. package/src/operations/extrusions/project.js +11 -14
  62. package/src/operations/extrusions/project.test.js +55 -55
  63. package/src/operations/hulls/hull.test.js +24 -1
  64. package/src/operations/hulls/hullChain.test.js +6 -4
  65. package/src/operations/hulls/hullGeom2.js +6 -18
  66. package/src/operations/hulls/hullGeom3.js +5 -18
  67. package/src/operations/hulls/hullPath2.js +4 -14
  68. package/src/operations/hulls/hullPath2.test.js +1 -1
  69. package/src/operations/hulls/hullPoints2.js +43 -92
  70. package/src/operations/hulls/toUniquePoints.js +34 -0
  71. package/src/operations/modifiers/generalize.js +2 -13
  72. package/src/operations/modifiers/generalize.test.js +5 -31
  73. package/src/operations/modifiers/insertTjunctions.js +1 -1
  74. package/src/operations/modifiers/insertTjunctions.test.js +21 -21
  75. package/src/operations/modifiers/mergePolygons.js +11 -14
  76. package/src/operations/{booleans → modifiers}/reTesselateCoplanarPolygons.js +1 -1
  77. package/src/operations/{booleans → modifiers}/reTesselateCoplanarPolygons.test.js +5 -5
  78. package/src/operations/{booleans → modifiers}/retessellate.js +2 -9
  79. package/src/operations/{booleans → modifiers}/retessellate.test.js +0 -0
  80. package/src/operations/modifiers/snapPolygons.test.js +12 -12
  81. package/src/operations/modifiers/triangulatePolygons.js +3 -3
  82. package/src/operations/transforms/align.test.js +12 -0
  83. package/src/operations/transforms/center.js +1 -1
  84. package/src/operations/transforms/center.test.js +12 -0
  85. package/src/operations/transforms/mirror.test.js +16 -0
  86. package/src/operations/transforms/rotate.test.js +10 -0
  87. package/src/operations/transforms/scale.test.js +15 -0
  88. package/src/operations/transforms/transform.test.js +5 -0
  89. package/src/operations/transforms/translate.test.js +16 -0
  90. package/src/primitives/arc.test.js +11 -0
  91. package/src/primitives/circle.test.js +15 -9
  92. package/src/primitives/cube.test.js +3 -0
  93. package/src/primitives/cuboid.js +1 -1
  94. package/src/primitives/cuboid.test.js +9 -24
  95. package/src/primitives/cylinder.test.js +7 -4
  96. package/src/primitives/cylinderElliptic.js +14 -7
  97. package/src/primitives/cylinderElliptic.test.js +72 -50
  98. package/src/primitives/ellipse.js +3 -1
  99. package/src/primitives/ellipse.test.js +14 -8
  100. package/src/primitives/ellipsoid.js +8 -6
  101. package/src/primitives/ellipsoid.test.js +84 -80
  102. package/src/primitives/geodesicSphere.test.js +3 -0
  103. package/src/primitives/line.test.js +1 -0
  104. package/src/primitives/polygon.test.js +15 -10
  105. package/src/primitives/polyhedron.js +1 -1
  106. package/src/primitives/polyhedron.test.js +14 -42
  107. package/src/primitives/rectangle.test.js +3 -0
  108. package/src/primitives/roundedCuboid.js +6 -6
  109. package/src/primitives/roundedCuboid.test.js +5 -0
  110. package/src/primitives/roundedCylinder.js +7 -5
  111. package/src/primitives/roundedCylinder.test.js +40 -36
  112. package/src/primitives/roundedRectangle.test.js +5 -0
  113. package/src/primitives/sphere.test.js +52 -73
  114. package/src/primitives/square.test.js +3 -0
  115. package/src/primitives/star.test.js +6 -0
  116. package/src/primitives/torus.test.js +8 -1
  117. package/src/primitives/triangle.js +1 -2
  118. package/src/primitives/triangle.test.js +7 -0
  119. package/src/utils/areAllShapesTheSameType.js +2 -2
  120. package/src/utils/areAllShapesTheSameType.test.js +17 -0
  121. package/src/utils/index.d.ts +1 -0
  122. package/src/utils/index.js +3 -1
  123. package/src/utils/trigonometry.d.ts +2 -0
  124. package/src/utils/trigonometry.js +34 -0
  125. package/src/utils/trigonometry.test.js +25 -0
  126. package/test/helpers/nearlyEqual.js +4 -1
  127. package/src/geometries/path2/eachPoint.d.ts +0 -9
  128. package/src/geometries/path2/eachPoint.js +0 -17
  129. package/src/geometries/path2/eachPoint.test.js +0 -11
  130. package/src/operations/modifiers/edges.js +0 -195
  131. package/src/operations/modifiers/repairTjunctions.js +0 -44
@@ -13,10 +13,12 @@ test('center: centering of a path2 produces expected changes to points', (t) =>
13
13
  let centered = center({ axes: [true, false, false] }, geometry)
14
14
  let pts = path2.toPoints(centered)
15
15
  const exp = [[3, 0], [-2, 3], [-3, 0]]
16
+ t.notThrows(() => path2.validate(centered))
16
17
  t.true(comparePoints(pts, exp))
17
18
 
18
19
  centered = centerX(geometry)
19
20
  pts = path2.toPoints(centered)
21
+ t.notThrows(() => path2.validate(centered))
20
22
  t.true(comparePoints(pts, exp))
21
23
  })
22
24
 
@@ -27,10 +29,12 @@ test('center: centering of a geom2 produces expected changes to points', (t) =>
27
29
  let centered = center({ axes: [false, true, false] }, geometry)
28
30
  let pts = geom2.toPoints(centered)
29
31
  const exp = [[0, -5], [10, -5], [0, 5]]
32
+ t.notThrows(() => geom2.validate(centered))
30
33
  t.true(comparePoints(pts, exp))
31
34
 
32
35
  centered = centerY(geometry)
33
36
  pts = geom2.toPoints(centered)
37
+ t.notThrows(() => geom2.validate(centered))
34
38
  t.true(comparePoints(pts, exp))
35
39
  })
36
40
 
@@ -56,10 +60,12 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
56
60
  [[-5, -7, -12], [-5, 13, -12], [5, 13, -12], [5, -7, -12]],
57
61
  [[-5, -7, 18], [5, -7, 18], [5, 13, 18], [-5, 13, 18]]
58
62
  ]
63
+ t.notThrows(() => geom3.validate(centered))
59
64
  t.true(comparePolygonsAsPoints(pts, exp))
60
65
 
61
66
  centered = centerX(geometry)
62
67
  pts = geom3.toPoints(centered)
68
+ t.notThrows(() => geom3.validate(centered))
63
69
  t.true(comparePolygonsAsPoints(pts, exp))
64
70
 
65
71
  // center about Y
@@ -73,10 +79,12 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
73
79
  [[-2, -10, -12], [-2, 10, -12], [8, 10, -12], [8, -10, -12]],
74
80
  [[-2, -10, 18], [8, -10, 18], [8, 10, 18], [-2, 10, 18]]
75
81
  ]
82
+ t.notThrows(() => geom3.validate(centered))
76
83
  t.true(comparePolygonsAsPoints(pts, exp))
77
84
 
78
85
  centered = centerY(geometry)
79
86
  pts = geom3.toPoints(centered)
87
+ t.notThrows(() => geom3.validate(centered))
80
88
  t.true(comparePolygonsAsPoints(pts, exp))
81
89
 
82
90
  // center about Z
@@ -90,10 +98,12 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
90
98
  [[-2, -7, -15], [-2, 13, -15], [8, 13, -15], [8, -7, -15]],
91
99
  [[-2, -7, 15], [8, -7, 15], [8, 13, 15], [-2, 13, 15]]
92
100
  ]
101
+ t.notThrows(() => geom3.validate(centered))
93
102
  t.true(comparePolygonsAsPoints(pts, exp))
94
103
 
95
104
  centered = centerZ(geometry)
96
105
  pts = geom3.toPoints(centered)
106
+ t.notThrows(() => geom3.validate(centered))
97
107
  t.true(comparePolygonsAsPoints(pts, exp))
98
108
  })
99
109
 
@@ -108,9 +118,11 @@ test('center: centering of multiple objects produces expected changes', (t) => {
108
118
 
109
119
  const pts1 = path2.toPoints(centered[1])
110
120
  const exp1 = [[2.5, 20], [12.5, 20], [2.5, 10], [17.5, 10]]
121
+ t.notThrows(() => path2.validate(centered[1]))
111
122
  t.true(comparePoints(pts1, exp1))
112
123
 
113
124
  const pts2 = geom2.toPoints(centered[2])
114
125
  const exp2 = [[2.5, 10], [7.5, 20], [17.5, 10]]
126
+ t.notThrows(() => geom2.validate(centered[2]))
115
127
  t.true(comparePoints(pts2, exp2))
116
128
  })
@@ -13,20 +13,24 @@ test('mirror: mirroring of path2 about X/Y produces expected changes to points',
13
13
  let mirrored = mirror({ normal: [1, 0, 0] }, geometry)
14
14
  let obs = path2.toPoints(mirrored)
15
15
  let exp = [[5, 5], [-5, 5], [5, -5], [-10, -5]]
16
+ t.notThrows(() => path2.validate(mirrored))
16
17
  t.true(comparePoints(obs, exp))
17
18
 
18
19
  mirrored = mirrorX(geometry)
19
20
  obs = path2.toPoints(mirrored)
21
+ t.notThrows(() => path2.validate(mirrored))
20
22
  t.true(comparePoints(obs, exp))
21
23
 
22
24
  // mirror about Y
23
25
  mirrored = mirror({ normal: [0, 1, 0] }, geometry)
24
26
  obs = path2.toPoints(mirrored)
25
27
  exp = [[-5, -5], [5, -5], [-5, 5], [10, 5]]
28
+ t.notThrows(() => path2.validate(mirrored))
26
29
  t.true(comparePoints(obs, exp))
27
30
 
28
31
  mirrored = mirrorY(geometry)
29
32
  obs = path2.toPoints(mirrored)
33
+ t.notThrows(() => path2.validate(mirrored))
30
34
  t.true(comparePoints(obs, exp))
31
35
  })
32
36
 
@@ -37,20 +41,24 @@ test('mirror: mirroring of geom2 about X/Y produces expected changes to points',
37
41
  let mirrored = mirror({ normal: [1, 0, 0] }, geometry)
38
42
  let obs = geom2.toPoints(mirrored)
39
43
  let exp = [[5, -5], [0, 5], [-10, -5]]
44
+ t.notThrows(() => geom2.validate(mirrored))
40
45
  t.true(comparePoints(obs, exp))
41
46
 
42
47
  mirrored = mirrorX(geometry)
43
48
  obs = geom2.toPoints(mirrored)
49
+ t.notThrows(() => geom2.validate(mirrored))
44
50
  t.true(comparePoints(obs, exp))
45
51
 
46
52
  // mirror about Y
47
53
  mirrored = mirror({ normal: [0, 1, 0] }, geometry)
48
54
  obs = geom2.toPoints(mirrored)
49
55
  exp = [[-5, 5], [0, -5], [10, 5]]
56
+ t.notThrows(() => geom2.validate(mirrored))
50
57
  t.true(comparePoints(obs, exp))
51
58
 
52
59
  mirrored = mirrorY(geometry)
53
60
  obs = geom2.toPoints(mirrored)
61
+ t.notThrows(() => geom2.validate(mirrored))
54
62
  t.true(comparePoints(obs, exp))
55
63
  })
56
64
 
@@ -76,11 +84,13 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
76
84
  [[-8, -7, -12], [-8, 13, -12], [2, 13, -12], [2, -7, -12]],
77
85
  [[2, 13, 18], [-8, 13, 18], [-8, -7, 18], [2, -7, 18]]
78
86
  ]
87
+ t.notThrows(() => geom3.validate(mirrored))
79
88
  t.true(comparePolygonsAsPoints(obs, exp))
80
89
  t.deepEqual(obs, exp)
81
90
 
82
91
  mirrored = mirrorX(geometry)
83
92
  obs = geom3.toPoints(mirrored)
93
+ t.notThrows(() => geom3.validate(mirrored))
84
94
  t.true(comparePolygonsAsPoints(obs, exp))
85
95
 
86
96
  // mirror about Y
@@ -94,10 +104,12 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
94
104
  [[8, 7, -12], [8, -13, -12], [-2, -13, -12], [-2, 7, -12]],
95
105
  [[-2, -13, 18], [8, -13, 18], [8, 7, 18], [-2, 7, 18]]
96
106
  ]
107
+ t.notThrows(() => geom3.validate(mirrored))
97
108
  t.true(comparePolygonsAsPoints(obs, exp))
98
109
 
99
110
  mirrored = mirrorY(geometry)
100
111
  obs = geom3.toPoints(mirrored)
112
+ t.notThrows(() => geom3.validate(mirrored))
101
113
  t.true(comparePolygonsAsPoints(obs, exp))
102
114
 
103
115
  // mirror about Z
@@ -111,10 +123,12 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
111
123
  [[8, -7, 12], [8, 13, 12], [-2, 13, 12], [-2, -7, 12]],
112
124
  [[-2, 13, -18], [8, 13, -18], [8, -7, -18], [-2, -7, -18]]
113
125
  ]
126
+ t.notThrows(() => geom3.validate(mirrored))
114
127
  t.true(comparePolygonsAsPoints(obs, exp))
115
128
 
116
129
  mirrored = mirrorZ(geometry)
117
130
  obs = geom3.toPoints(mirrored)
131
+ t.notThrows(() => geom3.validate(mirrored))
118
132
  t.true(comparePolygonsAsPoints(obs, exp))
119
133
  })
120
134
 
@@ -128,9 +142,11 @@ test('mirror: mirroring of multiple objects produces an array of mirrored object
128
142
 
129
143
  let obs = path2.toPoints(mirrored[1])
130
144
  let exp = [[-5, -5], [5, -5], [-5, 5], [10, 5]]
145
+ t.notThrows(() => path2.validate(mirrored[1]))
131
146
  t.true(comparePoints(obs, exp))
132
147
 
133
148
  obs = geom2.toPoints(mirrored[2])
134
149
  exp = [[-5, 5], [0, -5], [10, 5]]
150
+ t.notThrows(() => geom2.validate(mirrored[2]))
135
151
  t.true(comparePoints(obs, exp))
136
152
  })
@@ -21,6 +21,7 @@ test('rotate: rotating of a path2 produces expected changes to points', (t) => {
21
21
 
22
22
  rotated = rotateZ(Math.PI / 2, geometry)
23
23
  obs = path2.toPoints(rotated)
24
+ t.notThrows(() => path2.validate(rotated))
24
25
  t.true(comparePoints(obs, exp))
25
26
  })
26
27
 
@@ -35,10 +36,12 @@ test('rotate: rotating of a geom2 produces expected changes to points', (t) => {
35
36
  new Float32Array([0, -1]),
36
37
  new Float32Array([1, 0])
37
38
  ]
39
+ t.notThrows(() => geom2.validate(rotated))
38
40
  t.true(comparePoints(obs, exp))
39
41
 
40
42
  rotated = rotateZ(-Math.PI / 2, geometry)
41
43
  obs = geom2.toPoints(rotated)
44
+ t.notThrows(() => geom2.validate(rotated))
42
45
  t.true(comparePoints(obs, exp))
43
46
  })
44
47
 
@@ -70,10 +73,12 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
70
73
  [[-2, -18, -6.999999999999999], [8, -18, -6.999999999999999],
71
74
  [8, -18, 13.000000000000002], [-2, -18, 13.000000000000002]]
72
75
  ]
76
+ t.notThrows(() => geom3.validate(rotated))
73
77
  t.true(comparePolygonsAsPoints(obs, exp))
74
78
 
75
79
  rotated = rotateX(Math.PI / 2, geometry)
76
80
  obs = geom3.toPoints(rotated)
81
+ t.notThrows(() => geom3.validate(rotated))
77
82
  t.true(comparePolygonsAsPoints(obs, exp))
78
83
 
79
84
  // rotate about Y
@@ -93,6 +98,7 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
93
98
  [[-18, -7, -1.999999999999999], [-18, -7, 8.000000000000002],
94
99
  [-18, 13, 8.000000000000002], [-18, 13, -1.999999999999999]]
95
100
  ]
101
+ t.notThrows(() => geom3.validate(rotated))
96
102
  t.true(comparePolygonsAsPoints(obs, exp))
97
103
 
98
104
  rotated = rotateY(-Math.PI / 2, geometry)
@@ -116,10 +122,12 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
116
122
  [[2.000000000000001, 7, 18], [-7.999999999999999, 7.000000000000001, 18],
117
123
  [-8.000000000000002, -12.999999999999998, 18], [1.9999999999999984, -13, 18]]
118
124
  ]
125
+ t.notThrows(() => geom3.validate(rotated))
119
126
  t.true(comparePolygonsAsPoints(obs, exp))
120
127
 
121
128
  rotated = rotateZ(Math.PI, geometry)
122
129
  obs = geom3.toPoints(rotated)
130
+ t.notThrows(() => geom3.validate(rotated))
123
131
  t.true(comparePolygonsAsPoints(obs, exp))
124
132
  })
125
133
 
@@ -134,9 +142,11 @@ test('rotate: rotating of multiple objects produces expected changes', (t) => {
134
142
 
135
143
  const obs1 = path2.toPoints(rotated[1])
136
144
  const exp1 = [[-5, -5], [-5, 5], [5, -5], [5.000000000000001, 10]]
145
+ t.notThrows(() => path2.validate(rotated[1]))
137
146
  t.true(comparePoints(obs1, exp1))
138
147
 
139
148
  const obs2 = geom2.toPoints(rotated[2])
140
149
  const exp2 = [[5, -5], [-5, 3.061616997868383e-16], [5.000000000000001, 10]]
150
+ t.notThrows(() => geom2.validate(rotated[2]))
141
151
  t.true(comparePoints(obs2, exp2))
142
152
  })
@@ -13,20 +13,24 @@ test('scale: scaling of a path2 produces expected changes to points', (t) => {
13
13
  let scaled = scale([3], geometry)
14
14
  let obs = path2.toPoints(scaled)
15
15
  let exp = [[0, 4], [3, 0]]
16
+ t.notThrows(() => path2.validate(scaled))
16
17
  t.true(comparePoints(obs, exp))
17
18
 
18
19
  scaled = scaleX(3, geometry)
19
20
  obs = path2.toPoints(scaled)
21
+ t.notThrows(() => path2.validate(scaled))
20
22
  t.true(comparePoints(obs, exp))
21
23
 
22
24
  // scale Y
23
25
  scaled = scale([1, 0.5], geometry)
24
26
  obs = path2.toPoints(scaled)
25
27
  exp = [[0, 2], [1, 0]]
28
+ t.notThrows(() => path2.validate(scaled))
26
29
  t.true(comparePoints(obs, exp))
27
30
 
28
31
  scaled = scaleY(0.5, geometry)
29
32
  obs = path2.toPoints(scaled)
33
+ t.notThrows(() => path2.validate(scaled))
30
34
  t.true(comparePoints(obs, exp))
31
35
  })
32
36
 
@@ -37,20 +41,24 @@ test('scale: scaling of a geom2 produces expected changes to points', (t) => {
37
41
  let scaled = scale([3], geometry)
38
42
  let obs = geom2.toPoints(scaled)
39
43
  let exp = [[-3, 0], [3, 0], [0, 1]]
44
+ t.notThrows(() => geom2.validate(scaled))
40
45
  t.true(comparePoints(obs, exp))
41
46
 
42
47
  scaled = scaleX(3, geometry)
43
48
  obs = geom2.toPoints(scaled)
49
+ t.notThrows(() => geom2.validate(scaled))
44
50
  t.true(comparePoints(obs, exp))
45
51
 
46
52
  // scale Y
47
53
  scaled = scale([1, 3], geometry)
48
54
  obs = geom2.toPoints(scaled)
49
55
  exp = [[-1, 0], [1, 0], [0, 3]]
56
+ t.notThrows(() => geom2.validate(scaled))
50
57
  t.true(comparePoints(obs, exp))
51
58
 
52
59
  scaled = scaleY(3, geometry)
53
60
  obs = geom2.toPoints(scaled)
61
+ t.notThrows(() => geom2.validate(scaled))
54
62
  t.true(comparePoints(obs, exp))
55
63
  })
56
64
 
@@ -76,10 +84,12 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
76
84
  [[-6, -7, -12], [-6, 13, -12], [24, 13, -12], [24, -7, -12]],
77
85
  [[-6, -7, 18], [24, -7, 18], [24, 13, 18], [-6, 13, 18]]
78
86
  ]
87
+ t.notThrows(() => geom3.validate(scaled))
79
88
  t.true(comparePolygonsAsPoints(obs, exp))
80
89
 
81
90
  scaled = scaleX(3, geometry)
82
91
  obs = geom3.toPoints(scaled)
92
+ t.notThrows(() => geom3.validate(scaled))
83
93
  t.true(comparePolygonsAsPoints(obs, exp))
84
94
 
85
95
  // scale Y
@@ -97,6 +107,7 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
97
107
 
98
108
  scaled = scaleY(0.5, geometry)
99
109
  obs = geom3.toPoints(scaled)
110
+ t.notThrows(() => geom3.validate(scaled))
100
111
  t.true(comparePolygonsAsPoints(obs, exp))
101
112
 
102
113
  // scale Z
@@ -110,10 +121,12 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
110
121
  [[-2, -7, -60], [-2, 13, -60], [8, 13, -60], [8, -7, -60]],
111
122
  [[-2, -7, 90], [8, -7, 90], [8, 13, 90], [-2, 13, 90]]
112
123
  ]
124
+ t.notThrows(() => geom3.validate(scaled))
113
125
  t.true(comparePolygonsAsPoints(obs, exp))
114
126
 
115
127
  scaled = scaleZ(5, geometry)
116
128
  obs = geom3.toPoints(scaled)
129
+ t.notThrows(() => geom3.validate(scaled))
117
130
  t.true(comparePolygonsAsPoints(obs, exp))
118
131
  })
119
132
 
@@ -128,9 +141,11 @@ test('scale: scaling of multiple objects produces expected changes', (t) => {
128
141
 
129
142
  const obs1 = path2.toPoints(scaled[1])
130
143
  const exp1 = [[-15, 5], [15, 5], [-15, -5], [30, -5]]
144
+ t.notThrows(() => path2.validate(scaled[1]))
131
145
  t.true(comparePoints(obs1, exp1))
132
146
 
133
147
  const obs2 = geom2.toPoints(scaled[2])
134
148
  const exp2 = [[-15, -5], [0, 5], [30, -5]]
149
+ t.notThrows(() => geom2.validate(scaled[2]))
135
150
  t.true(comparePoints(obs2, exp2))
136
151
  })
@@ -15,6 +15,7 @@ test('transform: transforming of a path2 produces expected changes to points', (
15
15
  geometry = transform(matrix, geometry)
16
16
  const obs = path2.toPoints(geometry)
17
17
  const exp = [[2, 2], [3, 2]]
18
+ t.notThrows(() => path2.validate(geometry))
18
19
  t.true(comparePoints(obs, exp))
19
20
  })
20
21
 
@@ -25,6 +26,7 @@ test('transform: transforming of a geom2 produces expected changes to sides', (t
25
26
  geometry = transform(matrix, geometry)
26
27
  const obs = geom2.toPoints(geometry)
27
28
  const exp = [[0, 0], [5, 0], [0, 5]]
29
+ t.notThrows(() => geom2.validate(geometry))
28
30
  t.true(comparePoints(obs, exp))
29
31
  })
30
32
 
@@ -49,6 +51,7 @@ test('transform: transforming of a geom3 produces expected changes to polygons',
49
51
  [[-5, -10, -15], [-5, 10, -15], [5, 10, -15], [5, -10, -15]],
50
52
  [[-5, -10, 15], [5, -10, 15], [5, 10, 15], [-5, 10, 15]]
51
53
  ]
54
+ t.notThrows(() => geom3.validate(geometry))
52
55
  t.true(comparePolygonsAsPoints(obs, exp))
53
56
  })
54
57
 
@@ -63,9 +66,11 @@ test('transform: transforming of multiple objects produces expected changes', (t
63
66
 
64
67
  let obs = path2.toPoints(transformed[1])
65
68
  let exp = [[-3, 7], [7, 7], [-3, -3], [12, -3]]
69
+ t.notThrows(() => path2.validate(transformed[1]))
66
70
  t.true(comparePoints(obs, exp))
67
71
 
68
72
  obs = geom2.toPoints(transformed[2])
69
73
  exp = [[-3, -3], [2, 7], [12, -3]]
74
+ t.notThrows(() => geom2.validate(transformed[2]))
70
75
  t.true(comparePoints(obs, exp))
71
76
  })
@@ -13,20 +13,24 @@ test('translate: translating of a path2 produces expected changes to points', (t
13
13
  let translated = translate([1], line)
14
14
  let obs = path2.toPoints(translated)
15
15
  let exp = [[1, 0], [2, 0]]
16
+ t.notThrows(() => path2.validate(translated))
16
17
  t.true(comparePoints(obs, exp))
17
18
 
18
19
  translated = translateX(1, line)
19
20
  obs = path2.toPoints(translated)
21
+ t.notThrows(() => path2.validate(translated))
20
22
  t.true(comparePoints(obs, exp))
21
23
 
22
24
  // translate Y
23
25
  translated = translate([0, 1], line)
24
26
  obs = path2.toPoints(translated)
25
27
  exp = [[0, 1], [1, 1]]
28
+ t.notThrows(() => path2.validate(translated))
26
29
  t.true(comparePoints(obs, exp))
27
30
 
28
31
  translated = translateY(1, line)
29
32
  obs = path2.toPoints(translated)
33
+ t.notThrows(() => path2.validate(translated))
30
34
  t.true(comparePoints(obs, exp))
31
35
  })
32
36
 
@@ -37,20 +41,24 @@ test('translate: translating of a geom2 produces expected changes to points', (t
37
41
  let translated = translate([1], geometry)
38
42
  let obs = geom2.toPoints(translated)
39
43
  let exp = [[1, 0], [2, 0], [1, 1]]
44
+ t.notThrows(() => geom2.validate(translated))
40
45
  t.true(comparePoints(obs, exp))
41
46
 
42
47
  translated = translateX(1, geometry)
43
48
  obs = geom2.toPoints(translated)
49
+ t.notThrows(() => geom2.validate(translated))
44
50
  t.true(comparePoints(obs, exp))
45
51
 
46
52
  // translate Y
47
53
  translated = translate([0, 1], geometry)
48
54
  obs = geom2.toPoints(translated)
49
55
  exp = [[0, 1], [1, 1], [0, 2]]
56
+ t.notThrows(() => geom2.validate(translated))
50
57
  t.true(comparePoints(obs, exp))
51
58
 
52
59
  translated = translateY(1, geometry)
53
60
  obs = geom2.toPoints(translated)
61
+ t.notThrows(() => geom2.validate(translated))
54
62
  t.true(comparePoints(obs, exp))
55
63
  })
56
64
 
@@ -76,10 +84,12 @@ test('translate: translating of a geom3 produces expected changes to polygons',
76
84
  [[1, -7, -12], [1, 13, -12], [11, 13, -12], [11, -7, -12]],
77
85
  [[1, -7, 18], [11, -7, 18], [11, 13, 18], [1, 13, 18]]
78
86
  ]
87
+ t.notThrows(() => geom3.validate(translated))
79
88
  t.true(comparePolygonsAsPoints(obs, exp))
80
89
 
81
90
  translated = translateX(3, geometry)
82
91
  obs = geom3.toPoints(translated)
92
+ t.notThrows(() => geom3.validate(translated))
83
93
  t.true(comparePolygonsAsPoints(obs, exp))
84
94
 
85
95
  // translated Y
@@ -93,10 +103,12 @@ test('translate: translating of a geom3 produces expected changes to polygons',
93
103
  [[-2, -4, -12], [-2, 16, -12], [8, 16, -12], [8, -4, -12]],
94
104
  [[-2, -4, 18], [8, -4, 18], [8, 16, 18], [-2, 16, 18]]
95
105
  ]
106
+ t.notThrows(() => geom3.validate(translated))
96
107
  t.true(comparePolygonsAsPoints(obs, exp))
97
108
 
98
109
  translated = translateY(3, geometry)
99
110
  obs = geom3.toPoints(translated)
111
+ t.notThrows(() => geom3.validate(translated))
100
112
  t.true(comparePolygonsAsPoints(obs, exp))
101
113
 
102
114
  // translate Z
@@ -110,10 +122,12 @@ test('translate: translating of a geom3 produces expected changes to polygons',
110
122
  [[-2, -7, -9], [-2, 13, -9], [8, 13, -9], [8, -7, -9]],
111
123
  [[-2, -7, 21], [8, -7, 21], [8, 13, 21], [-2, 13, 21]]
112
124
  ]
125
+ t.notThrows(() => geom3.validate(translated))
113
126
  t.true(comparePolygonsAsPoints(obs, exp))
114
127
 
115
128
  translated = translateZ(3, geometry)
116
129
  obs = geom3.toPoints(translated)
130
+ t.notThrows(() => geom3.validate(translated))
117
131
  t.true(comparePolygonsAsPoints(obs, exp))
118
132
  })
119
133
 
@@ -127,9 +141,11 @@ test('translate: translating of multiple objects produces expected changes', (t)
127
141
 
128
142
  let obs = path2.toPoints(translated[1])
129
143
  let exp = [[-2, 8], [8, 8], [-2, -2], [13, -2]]
144
+ t.notThrows(() => path2.validate(translated[1]))
130
145
  t.true(comparePoints(obs, exp))
131
146
 
132
147
  obs = geom2.toPoints(translated[2])
133
148
  exp = [[-2, -2], [3, 8], [13, -2]]
149
+ t.notThrows(() => geom2.validate(translated[2]))
134
150
  t.true(comparePoints(obs, exp))
135
151
  })
@@ -10,6 +10,7 @@ test('arc (defaults)', (t) => {
10
10
  const geometry = arc()
11
11
  const obs = path2.toPoints(geometry)
12
12
 
13
+ t.notThrows(() => path2.validate(geometry))
13
14
  t.deepEqual(obs.length, 33)
14
15
  })
15
16
 
@@ -37,6 +38,7 @@ test('arc (options)', (t) => {
37
38
  let geometry = arc({ center: [2, 2], segments: 16 })
38
39
  let obs = path2.toPoints(geometry)
39
40
 
41
+ t.notThrows(() => path2.validate(geometry))
40
42
  t.deepEqual(obs.length, 17)
41
43
  t.true(comparePoints(obs, exp))
42
44
 
@@ -63,6 +65,7 @@ test('arc (options)', (t) => {
63
65
  geometry = arc({ radius: 2, segments: 16 })
64
66
  obs = path2.toPoints(geometry)
65
67
 
68
+ t.notThrows(() => path2.validate(geometry))
66
69
  t.deepEqual(obs.length, 17)
67
70
  t.true(comparePoints(obs, exp))
68
71
 
@@ -86,6 +89,7 @@ test('arc (options)', (t) => {
86
89
  geometry = arc({ startAngle: Math.PI / 2, segments: 16 })
87
90
  obs = path2.toPoints(geometry)
88
91
 
92
+ t.notThrows(() => path2.validate(geometry))
89
93
  t.deepEqual(obs.length, 14)
90
94
  t.true(comparePoints(obs, exp))
91
95
 
@@ -101,6 +105,7 @@ test('arc (options)', (t) => {
101
105
  geometry = arc({ endAngle: Math.PI / 2, segments: 16 })
102
106
  obs = path2.toPoints(geometry)
103
107
 
108
+ t.notThrows(() => path2.validate(geometry))
104
109
  t.deepEqual(obs.length, 6)
105
110
  t.true(comparePoints(obs, exp))
106
111
 
@@ -129,6 +134,7 @@ test('arc (options)', (t) => {
129
134
  geometry = arc({ makeTangent: true, segments: 16 })
130
135
  obs = path2.toPoints(geometry)
131
136
 
137
+ t.notThrows(() => path2.validate(geometry))
132
138
  t.deepEqual(obs.length, 19)
133
139
  t.true(comparePoints(obs, exp))
134
140
 
@@ -147,6 +153,7 @@ test('arc (options)', (t) => {
147
153
  geometry = arc({ segments: 8 })
148
154
  obs = path2.toPoints(geometry)
149
155
 
156
+ t.notThrows(() => path2.validate(geometry))
150
157
  t.deepEqual(obs.length, 9)
151
158
  t.true(comparePoints(obs, exp))
152
159
  })
@@ -163,6 +170,7 @@ test('arc (rotations)', (t) => {
163
170
  let geometry = arc({ startAngle: Math.PI / 2, endAngle: Math.PI, segments: 16 })
164
171
  let obs = path2.toPoints(geometry)
165
172
 
173
+ t.notThrows(() => path2.validate(geometry))
166
174
  t.deepEqual(obs.length, 6)
167
175
  t.true(comparePoints(obs, exp))
168
176
 
@@ -181,6 +189,7 @@ test('arc (rotations)', (t) => {
181
189
  geometry = arc({ startAngle: Math.PI, endAngle: Math.PI * 2, segments: 16 })
182
190
  obs = path2.toPoints(geometry)
183
191
 
192
+ t.notThrows(() => path2.validate(geometry))
184
193
  t.deepEqual(obs.length, 10)
185
194
  t.true(comparePoints(obs, exp))
186
195
 
@@ -199,6 +208,7 @@ test('arc (rotations)', (t) => {
199
208
  geometry = arc({ startAngle: Math.PI * 2 * 0.75, endAngle: Math.PI / 2, segments: 16 })
200
209
  obs = path2.toPoints(geometry)
201
210
 
211
+ t.notThrows(() => path2.validate(geometry))
202
212
  t.deepEqual(obs.length, 10)
203
213
  t.true(comparePoints(obs, exp))
204
214
 
@@ -206,6 +216,7 @@ test('arc (rotations)', (t) => {
206
216
  geometry = arc({ startAngle: Math.PI * 2 * 0.75, endAngle: 270.000000005 * 0.017453292519943295, segments: 16 })
207
217
  obs = path2.toPoints(geometry)
208
218
 
219
+ t.notThrows(() => path2.validate(geometry))
209
220
  t.deepEqual(obs.length, 1)
210
221
  t.true(comparePoints(obs, exp))
211
222
  })
@@ -10,6 +10,7 @@ test('circle (defaults)', (t) => {
10
10
  const geometry = circle()
11
11
  const pts = geom2.toPoints(geometry)
12
12
 
13
+ t.notThrows(() => geom2.validate(geometry))
13
14
  t.deepEqual(pts.length, 32)
14
15
  })
15
16
 
@@ -42,7 +43,7 @@ test('circle (options)', (t) => {
42
43
  [4.555504184431392, 3.5898563569410915],
43
44
  [5.160607986722184, 3.266421636210497],
44
45
  [5.817183872943549, 3.067251518588694],
45
- [6.499999999999999, 3],
46
+ [6.5, 3],
46
47
  [7.182816127056449, 3.0672515185886935],
47
48
  [7.8393920132778145, 3.266421636210497],
48
49
  [8.444495815568606, 3.589856356941091],
@@ -52,6 +53,7 @@ test('circle (options)', (t) => {
52
53
  [9.932748481411306, 5.817183872943549]
53
54
  ]
54
55
 
56
+ t.notThrows(() => geom2.validate(geometry))
55
57
  t.deepEqual(pts.length, 32)
56
58
  t.true(comparePoints(pts, exp))
57
59
 
@@ -63,20 +65,21 @@ test('circle (options)', (t) => {
63
65
  [3.2335783637895035, 1.3393920132778143],
64
66
  [2.4748737341529163, 2.474873734152916],
65
67
  [1.3393920132778145, 3.2335783637895035],
66
- [2.143131898507868e-16, 3.5],
68
+ [0, 3.5],
67
69
  [-1.339392013277814, 3.2335783637895035],
68
70
  [-2.474873734152916, 2.4748737341529163],
69
71
  [-3.2335783637895035, 1.3393920132778145],
70
- [-3.5, 4.286263797015736e-16],
72
+ [-3.5, 0],
71
73
  [-3.233578363789504, -1.3393920132778139],
72
74
  [-2.474873734152917, -2.474873734152916],
73
75
  [-1.339392013277816, -3.233578363789503],
74
- [-6.429395695523604e-16, -3.5],
76
+ [0, -3.5],
75
77
  [1.339392013277815, -3.233578363789503],
76
78
  [2.474873734152916, -2.474873734152917],
77
79
  [3.233578363789503, -1.3393920132778163]
78
80
  ]
79
81
 
82
+ t.notThrows(() => geom2.validate(geometry))
80
83
  t.deepEqual(pts.length, 16)
81
84
  t.true(comparePoints(pts, exp))
82
85
 
@@ -84,22 +87,23 @@ test('circle (options)', (t) => {
84
87
  geometry = circle({ radius: 3.5, startAngle: Math.PI / 2, segments: 16 })
85
88
  pts = geom2.toPoints(geometry)
86
89
  exp = [
87
- [2.143131898507868e-16, 3.5],
90
+ [0, 3.5],
88
91
  [-1.339392013277814, 3.2335783637895035],
89
92
  [-2.474873734152916, 2.4748737341529163],
90
93
  [-3.2335783637895035, 1.3393920132778145],
91
- [-3.5, 4.286263797015736e-16],
94
+ [-3.5, 0],
92
95
  [-3.233578363789504, -1.3393920132778139],
93
96
  [-2.474873734152917, -2.474873734152916],
94
97
  [-1.339392013277816, -3.233578363789503],
95
- [-6.429395695523604e-16, -3.5],
98
+ [0, -3.5],
96
99
  [1.339392013277815, -3.233578363789503],
97
100
  [2.474873734152916, -2.474873734152917],
98
101
  [3.233578363789503, -1.3393920132778163],
99
- [3.5, -8.572527594031472e-16],
102
+ [3.5, 0],
100
103
  [0, 0]
101
104
  ]
102
105
 
106
+ t.notThrows(() => geom2.validate(geometry))
103
107
  t.deepEqual(pts.length, 14)
104
108
  t.true(comparePoints(pts, exp))
105
109
 
@@ -111,10 +115,11 @@ test('circle (options)', (t) => {
111
115
  [3.2335783637895035, 1.3393920132778143],
112
116
  [2.4748737341529163, 2.474873734152916],
113
117
  [1.3393920132778145, 3.2335783637895035],
114
- [2.143131898507868e-16, 3.5],
118
+ [0, 3.5],
115
119
  [0, 0]
116
120
  ]
117
121
 
122
+ t.notThrows(() => geom2.validate(geometry))
118
123
  t.deepEqual(pts.length, 6)
119
124
  t.true(comparePoints(pts, exp))
120
125
 
@@ -129,6 +134,7 @@ test('circle (options)', (t) => {
129
134
  [1.0815594803123152, -3.3286978070330377]
130
135
  ]
131
136
 
137
+ t.notThrows(() => geom2.validate(geometry))
132
138
  t.deepEqual(pts.length, 5)
133
139
  t.true(comparePoints(pts, exp))
134
140
  })
@@ -9,6 +9,7 @@ const comparePolygonsAsPoints = require('../../test/helpers/comparePolygonsAsPoi
9
9
  test('cube (defaults)', (t) => {
10
10
  const obs = cube()
11
11
  const pts = geom3.toPoints(obs)
12
+ t.notThrows(() => geom3.validate(obs))
12
13
  t.is(pts.length, 6)
13
14
  })
14
15
 
@@ -25,6 +26,7 @@ test('cube (options)', (t) => {
25
26
  [[3, 3, 10], [10, 3, 10], [10, 10, 10], [3, 10, 10]]
26
27
  ]
27
28
 
29
+ t.notThrows(() => geom3.validate(obs))
28
30
  t.is(pts.length, 6)
29
31
  t.true(comparePolygonsAsPoints(pts, exp))
30
32
 
@@ -40,6 +42,7 @@ test('cube (options)', (t) => {
40
42
  [[-3.5, -3.5, 3.5], [3.5, -3.5, 3.5], [3.5, 3.5, 3.5], [-3.5, 3.5, 3.5]]
41
43
  ]
42
44
 
45
+ t.notThrows(() => geom3.validate(obs))
43
46
  t.is(pts.length, 6)
44
47
  t.true(comparePolygonsAsPoints(pts, exp))
45
48
  })
@@ -43,7 +43,7 @@ const cuboid = (options) => {
43
43
  ]
44
44
  return pos
45
45
  })
46
- return poly3.fromPoints(points)
46
+ return poly3.create(points)
47
47
  })
48
48
  )
49
49
  return result