@jscad/modeling 2.9.4 → 2.9.5

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 (54) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/jscad-modeling.min.js +125 -128
  3. package/package.json +2 -2
  4. package/src/colors/colorize.d.ts +6 -5
  5. package/src/geometries/geom2/type.d.ts +3 -2
  6. package/src/geometries/geom3/type.d.ts +3 -2
  7. package/src/geometries/path2/type.d.ts +3 -2
  8. package/src/geometries/poly3/measureBoundingSphere.d.ts +2 -2
  9. package/src/geometries/poly3/measureBoundingSphere.js +46 -8
  10. package/src/geometries/poly3/measureBoundingSphere.test.js +16 -26
  11. package/src/geometries/poly3/type.d.ts +3 -2
  12. package/src/geometries/types.d.ts +4 -2
  13. package/src/maths/mat4/fromRotation.js +9 -7
  14. package/src/maths/mat4/fromTaitBryanRotation.js +8 -6
  15. package/src/maths/mat4/fromXRotation.js +4 -2
  16. package/src/maths/mat4/fromYRotation.js +4 -2
  17. package/src/maths/mat4/fromZRotation.js +4 -2
  18. package/src/maths/mat4/rotate.js +9 -5
  19. package/src/maths/mat4/rotateX.js +4 -2
  20. package/src/maths/mat4/rotateY.js +4 -2
  21. package/src/maths/mat4/rotateZ.js +4 -2
  22. package/src/maths/mat4/translate.test.js +2 -3
  23. package/src/maths/utils/index.d.ts +1 -0
  24. package/src/maths/utils/index.js +2 -0
  25. package/src/{utils → maths/utils}/trigonometry.d.ts +0 -0
  26. package/src/{utils → maths/utils}/trigonometry.js +1 -1
  27. package/src/{utils → maths/utils}/trigonometry.test.js +0 -0
  28. package/src/maths/vec2/distance.js +1 -1
  29. package/src/maths/vec2/fromAngleRadians.js +4 -2
  30. package/src/maths/vec2/length.js +1 -1
  31. package/src/maths/vec2/length.test.js +0 -10
  32. package/src/maths/vec3/angle.js +2 -2
  33. package/src/maths/vec3/angle.test.js +0 -12
  34. package/src/maths/vec3/distance.js +1 -1
  35. package/src/maths/vec3/length.js +1 -1
  36. package/src/maths/vec3/length.test.js +0 -10
  37. package/src/operations/booleans/trees/PolygonTreeNode.js +2 -2
  38. package/src/operations/extrusions/extrudeRotate.test.js +42 -42
  39. package/src/operations/extrusions/project.test.js +2 -2
  40. package/src/operations/extrusions/slice/repair.js +1 -1
  41. package/src/primitives/circle.test.js +7 -0
  42. package/src/primitives/cylinderElliptic.js +4 -2
  43. package/src/primitives/cylinderElliptic.test.js +7 -1
  44. package/src/primitives/ellipse.js +1 -1
  45. package/src/primitives/ellipse.test.js +7 -0
  46. package/src/primitives/ellipsoid.js +1 -1
  47. package/src/primitives/geodesicSphere.js +3 -2
  48. package/src/primitives/roundedCuboid.js +4 -2
  49. package/src/primitives/roundedCylinder.js +1 -1
  50. package/src/primitives/torus.test.js +7 -3
  51. package/src/utils/index.d.ts +0 -1
  52. package/src/utils/index.js +1 -3
  53. package/src/maths/mat4/constants.d.ts +0 -1
  54. package/src/maths/mat4/constants.js +0 -5
@@ -22,18 +22,18 @@ test('extrudeRotate: (angle) extruding of a geom2 produces an expected geom3', (
22
22
  let geometry3 = extrudeRotate({ segments: 4, angle: Math.PI / 4 }, geometry2)
23
23
  let pts = geom3.toPoints(geometry3)
24
24
  const exp = [
25
- [[10, 4.898587196589413e-16, 8], [26, 4.898587196589413e-16, 8], [18.38477631085024, 18.384776310850235, 8]],
26
- [[10, 4.898587196589413e-16, 8], [18.38477631085024, 18.384776310850235, 8], [7.0710678118654755, 7.071067811865475, 8]],
27
- [[10, -4.898587196589413e-16, -8], [10, 4.898587196589413e-16, 8], [7.0710678118654755, 7.071067811865475, 8]],
28
- [[10, -4.898587196589413e-16, -8], [7.0710678118654755, 7.071067811865475, 8], [7.0710678118654755, 7.071067811865475, -8]],
29
- [[26, -4.898587196589413e-16, -8], [10, -4.898587196589413e-16, -8], [7.0710678118654755, 7.071067811865475, -8]],
30
- [[26, -4.898587196589413e-16, -8], [7.0710678118654755, 7.071067811865475, -8], [18.38477631085024, 18.384776310850235, -8]],
31
- [[26, 4.898587196589413e-16, 8], [26, -4.898587196589413e-16, -8], [18.38477631085024, 18.384776310850235, -8]],
32
- [[26, 4.898587196589413e-16, 8], [18.38477631085024, 18.384776310850235, -8], [18.38477631085024, 18.384776310850235, 8]],
33
- [[7.071067811865476, 7.0710678118654755, -8], [7.071067811865476, 7.0710678118654755, 8], [18.384776310850242, 18.384776310850235, 8]],
34
- [[18.384776310850242, 18.384776310850235, 8], [18.384776310850242, 18.384776310850235, -8], [7.071067811865476, 7.0710678118654755, -8]],
35
- [[26, 4.898587196589413e-16, 8], [10, 4.898587196589413e-16, 8], [10, -4.898587196589413e-16, -8]],
36
- [[10, -4.898587196589413e-16, -8], [26, -4.898587196589413e-16, -8], [26, 4.898587196589413e-16, 8]]
25
+ [[10, 0, 8], [26, 0, 8], [18.38477631085024, 18.384776310850235, 8]],
26
+ [[10, 0, 8], [18.38477631085024, 18.384776310850235, 8], [7.0710678118654755, 7.071067811865475, 8]],
27
+ [[10, 0, -8], [10, 0, 8], [7.0710678118654755, 7.071067811865475, 8]],
28
+ [[10, 0, -8], [7.0710678118654755, 7.071067811865475, 8], [7.0710678118654755, 7.071067811865475, -8]],
29
+ [[26, 0, -8], [10, 0, -8], [7.0710678118654755, 7.071067811865475, -8]],
30
+ [[26, 0, -8], [7.0710678118654755, 7.071067811865475, -8], [18.38477631085024, 18.384776310850235, -8]],
31
+ [[26, 0, 8], [26, 0, -8], [18.38477631085024, 18.384776310850235, -8]],
32
+ [[26, 0, 8], [18.38477631085024, 18.384776310850235, -8], [18.38477631085024, 18.384776310850235, 8]],
33
+ [[7.0710678118654755, 7.071067811865475, -8], [7.0710678118654755, 7.071067811865475, 8], [18.38477631085024, 18.384776310850235, 8]],
34
+ [[18.38477631085024, 18.384776310850235, 8], [18.38477631085024, 18.384776310850235, -8], [7.0710678118654755, 7.071067811865475, -8]],
35
+ [[26, 0, 8], [10, 0, 8], [10, 0, -8]],
36
+ [[10, 0, -8], [26, 0, -8], [26, 0, 8]]
37
37
  ]
38
38
  t.notThrows(() => geom3.validate(geometry3))
39
39
  t.is(pts.length, 12)
@@ -95,14 +95,14 @@ test('extrudeRotate: (segments) extruding of a geom2 produces an expected geom3'
95
95
  geometry2 = geom2.fromPoints([[0, 0], [2, 1], [1, 2], [1, 3], [3, 4], [0, 5]])
96
96
  geometry3 = extrudeRotate({ segments: 8 }, geometry2)
97
97
  pts = geom3.toPoints(geometry3)
98
- t.notThrows.skip(() => geom3.validate(geometry3))
98
+ t.notThrows(() => geom3.validate(geometry3))
99
99
  t.is(pts.length, 64)
100
100
 
101
101
  // test overlapping edges that produce hollow shape
102
102
  geometry2 = geom2.fromPoints([[30, 0], [30, 60], [0, 60], [0, 50], [10, 40], [10, 30], [0, 20], [0, 10], [10, 0]])
103
103
  geometry3 = extrudeRotate({ segments: 8 }, geometry2)
104
104
  pts = geom3.toPoints(geometry3)
105
- t.notThrows.skip(() => geom3.validate(geometry3))
105
+ t.notThrows(() => geom3.validate(geometry3))
106
106
  t.is(pts.length, 80)
107
107
  })
108
108
 
@@ -113,16 +113,16 @@ test('extrudeRotate: (overlap +/-) extruding of a geom2 produces an expected geo
113
113
  let obs = extrudeRotate({ segments: 4, angle: Math.PI / 2 }, geometry)
114
114
  let pts = geom3.toPoints(obs)
115
115
  let exp = [
116
- [[0, 4.898587196589413e-16, 8], [7, 4.898587196589413e-16, 8], [-6.123233995736767e-17, 7, 8]],
117
- [[7, -4.898587196589413e-16, -8], [4.898587196589413e-16, -2.999519565323715e-32, -8], [9.184850993605148e-16, 7, -8]],
118
- [[7, 4.898587196589413e-16, 8], [7, -4.898587196589413e-16, -8], [9.184850993605148e-16, 7, -8]],
119
- [[7, 4.898587196589413e-16, 8], [9.184850993605148e-16, 7, -8], [-6.123233995736767e-17, 7, 8]],
120
- [[4.898587196589413e-16, -2.999519565323715e-32, -8], [-4.898587196589413e-16, 2.999519565323715e-32, 8], [-6.123233995736767e-17, 7, 8]],
121
- [[-6.123233995736767e-17, 7, 8], [9.184850993605148e-16, 7, -8], [4.898587196589413e-16, -2.999519565323715e-32, -8]],
122
- [[7, 4.898587196589413e-16, 8], [0, 4.898587196589413e-16, 8], [0, -4.898587196589413e-16, -8]],
123
- [[0, -4.898587196589413e-16, -8], [7, -4.898587196589413e-16, -8], [7, 4.898587196589413e-16, 8]]
116
+ [[0, 0, 8], [7, 0, 8], [0, 7, 8]],
117
+ [[7, 0, -8], [0, 0, -8], [0, 7, -8]],
118
+ [[7, 0, 8], [7, 0, -8], [0, 7, -8]],
119
+ [[7, 0, 8], [0, 7, -8], [0, 7, 8]],
120
+ [[0, 0, -8], [0, 0, 8], [0, 7, 8]],
121
+ [[0, 7, 8], [0, 7, -8], [0, 0, -8]],
122
+ [[7, 0, 8], [0, 0, 8], [0, 0, -8]],
123
+ [[0, 0, -8], [7, 0, -8], [7, 0, 8]]
124
124
  ]
125
- t.notThrows.skip(() => geom3.validate(obs))
125
+ t.notThrows(() => geom3.validate(obs))
126
126
  t.is(pts.length, 8)
127
127
  t.true(comparePolygonsAsPoints(pts, exp))
128
128
 
@@ -132,26 +132,26 @@ test('extrudeRotate: (overlap +/-) extruding of a geom2 produces an expected geo
132
132
  obs = extrudeRotate({ segments: 8, angle: Math.PI / 2 }, geometry)
133
133
  pts = geom3.toPoints(obs)
134
134
  exp = [
135
- [[1, -4.898587196589413e-16, -8], [3.4638242249419727e-16, -3.4638242249419736e-16, -8], [0.7071067811865479, 0.7071067811865471, -8]],
136
- [[2, 2.4492935982947064e-16, 4], [1, -4.898587196589413e-16, -8], [0.7071067811865479, 0.7071067811865471, -8]],
137
- [[2, 2.4492935982947064e-16, 4], [0.7071067811865479, 0.7071067811865471, -8], [1.414213562373095, 1.4142135623730951, 4]],
138
- [[1, 4.898587196589413e-16, 8], [2, 2.4492935982947064e-16, 4], [1.414213562373095, 1.4142135623730951, 4]],
139
- [[1, 4.898587196589413e-16, 8], [1.414213562373095, 1.4142135623730951, 4], [0.7071067811865472, 0.7071067811865478, 8]],
140
- [[0, 4.898587196589413e-16, 8], [1, 4.898587196589413e-16, 8], [0.7071067811865472, 0.7071067811865478, 8]],
141
- [[0.7071067811865479, 0.7071067811865471, -8], [4.898587196589413e-16, -2.999519565323715e-32, -8], [5.51091059616309e-16, 1, -8]],
142
- [[1.414213562373095, 1.4142135623730951, 4], [0.7071067811865479, 0.7071067811865471, -8], [5.51091059616309e-16, 1, -8]],
143
- [[1.414213562373095, 1.4142135623730951, 4], [5.51091059616309e-16, 1, -8], [-1.2246467991473532e-16, 2, 4]],
144
- [[0.7071067811865472, 0.7071067811865478, 8], [1.414213562373095, 1.4142135623730951, 4], [-1.2246467991473532e-16, 2, 4]],
145
- [[0.7071067811865472, 0.7071067811865478, 8], [-1.2246467991473532e-16, 2, 4], [-4.286263797015736e-16, 1, 8]],
146
- [[-3.4638242249419727e-16, 3.4638242249419736e-16, 8], [0.7071067811865472, 0.7071067811865478, 8], [-4.286263797015736e-16, 1, 8]],
147
- [[5.51091059616309e-16, 1, -8], [4.898587196589413e-16, -2.999519565323715e-32, -8], [-4.898587196589415e-16, 2.9995195653237163e-32, 8]],
148
- [[-4.898587196589415e-16, 2.9995195653237163e-32, 8], [-4.286263797015738e-16, 1, 8], [-1.2246467991473544e-16, 2, 4]],
149
- [[-1.2246467991473544e-16, 2, 4], [5.51091059616309e-16, 1, -8], [-4.898587196589415e-16, 2.9995195653237163e-32, 8]],
150
- [[0, 4.898587196589413e-16, 8], [0, -4.898587196589413e-16, -8], [1, -4.898587196589413e-16, -8]],
151
- [[2, 2.4492935982947064e-16, 4], [1, 4.898587196589413e-16, 8], [0, 4.898587196589413e-16, 8]],
152
- [[0, 4.898587196589413e-16, 8], [1, -4.898587196589413e-16, -8], [2, 2.4492935982947064e-16, 4]]
135
+ [[1, 0, -8], [0, 0, -8], [0.7071067811865476, 0.7071067811865475, -8]],
136
+ [[2, 0, 4], [1, 0, -8], [0.7071067811865476, 0.7071067811865475, -8]],
137
+ [[2, 0, 4], [0.7071067811865476, 0.7071067811865475, -8], [1.4142135623730951, 1.414213562373095, 4]],
138
+ [[1, 0, 8], [2, 0, 4], [1.4142135623730951, 1.414213562373095, 4]],
139
+ [[1, 0, 8], [1.4142135623730951, 1.414213562373095, 4], [0.7071067811865476, 0.7071067811865475, 8]],
140
+ [[0, 0, 8], [1, 0, 8], [0.7071067811865476, 0.7071067811865475, 8]],
141
+ [[0.7071067811865476, 0.7071067811865475, -8], [0, 0, -8], [0, 1, -8]],
142
+ [[1.4142135623730951, 1.414213562373095, 4], [0.7071067811865476, 0.7071067811865475, -8], [0, 1, -8]],
143
+ [[1.4142135623730951, 1.414213562373095, 4], [0, 1, -8], [0, 2, 4]],
144
+ [[0.7071067811865476, 0.7071067811865475, 8], [1.4142135623730951, 1.414213562373095, 4], [0, 2, 4]],
145
+ [[0.7071067811865476, 0.7071067811865475, 8], [0, 2, 4], [0, 1, 8]],
146
+ [[0, 0, 8], [0.7071067811865476, 0.7071067811865475, 8], [0, 1, 8]],
147
+ [[0, 1, -8], [0, 0, -8], [0, 0, 8]],
148
+ [[0, 0, 8], [0, 1, 8], [0, 2, 4]],
149
+ [[0, 2, 4], [0, 1, -8], [0, 0, 8]],
150
+ [[0, 0, 8], [0, 0, -8], [1, 0, -8]],
151
+ [[2, 0, 4], [1, 0, 8], [0, 0, 8]],
152
+ [[0, 0, 8], [1, 0, -8], [2, 0, 4]]
153
153
  ]
154
- t.notThrows.skip(() => geom3.validate(obs))
154
+ t.notThrows(() => geom3.validate(obs))
155
155
  t.is(pts.length, 18)
156
156
  t.true(comparePolygonsAsPoints(pts, exp))
157
157
  })
@@ -29,10 +29,10 @@ test('project (defaults)', (t) => {
29
29
  [0, -5.000013333333333],
30
30
  [5.000013333333333, 0],
31
31
  [-5.000013333333333, 0],
32
- [-2.9999933333333333, 0],
33
- [2.9999933333333333, 0],
34
32
  [0, 2.9999933333333333],
33
+ [-2.9999933333333333, 0],
35
34
  [0, -2.9999933333333333],
35
+ [2.9999933333333333, 0],
36
36
  [0, 5.000013333333333]
37
37
  ]
38
38
  t.true(comparePoints(pts, exp))
@@ -40,7 +40,7 @@ const repair = (slice) => {
40
40
  let bestReplacement
41
41
  missingOut.forEach((key2) => {
42
42
  const v2 = vertexMap.get(key2)
43
- const distance = Math.hypot(v1[0] - v2[0], v1[1] - v2[1])
43
+ const distance = vec3.distance(v1, v2)
44
44
  if (distance < bestDistance) {
45
45
  bestDistance = distance
46
46
  bestReplacement = v2
@@ -123,6 +123,13 @@ test('circle (options)', (t) => {
123
123
  t.deepEqual(pts.length, 6)
124
124
  t.true(comparePoints(pts, exp))
125
125
 
126
+ // test full rotation with non-zero startAngle
127
+ geometry = circle({ startAngle: 1, endAngle: 1 + 2 * Math.PI })
128
+ pts = geom2.toPoints(geometry)
129
+
130
+ t.notThrows(() => geom2.validate(geometry))
131
+ t.deepEqual(pts.length, 32)
132
+
126
133
  // test segments
127
134
  geometry = circle({ radius: 3.5, segments: 5 })
128
135
  pts = geom2.toPoints(geometry)
@@ -5,7 +5,7 @@ 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')
8
+ const { sin, cos } = require('../maths/utils/trigonometry')
9
9
 
10
10
  const { isGT, isGTE, isNumberArray } = require('./commonChecks')
11
11
 
@@ -96,7 +96,9 @@ const cylinderElliptic = (options) => {
96
96
  const polygons = []
97
97
  for (let i = 0; i < slices; i++) {
98
98
  const t0 = i / slices
99
- const t1 = (i + 1) / slices
99
+ let t1 = (i + 1) / slices
100
+ // fix rounding error when rotating 2 * PI radians
101
+ if (rotation === 2 * Math.PI && i === slices - 1) t1 = 0
100
102
 
101
103
  if (endRadius[0] === startRadius[0] && endRadius[1] === startRadius[1]) {
102
104
  polygons.push(fromPoints(start, point(0, t1, endRadius), point(0, t0, endRadius)))
@@ -137,7 +137,13 @@ test('cylinderElliptic (options)', (t) => {
137
137
 
138
138
  t.notThrows(() => geom3.validate(obs))
139
139
  t.is(pts.length, 28)
140
- // t.true(comparePolygonsAsPoints(pts, exp))
140
+
141
+ // test startAngle and endAngle
142
+ obs = cylinderElliptic({ startAngle: 1, endAngle: 1 + 2 * Math.PI })
143
+ pts = geom3.toPoints(obs)
144
+
145
+ t.notThrows(() => geom3.validate(obs))
146
+ t.is(pts.length, 96)
141
147
 
142
148
  // test segments
143
149
  obs = cylinderElliptic({ segments: 8 })
@@ -4,7 +4,7 @@ const vec2 = require('../maths/vec2')
4
4
 
5
5
  const geom2 = require('../geometries/geom2')
6
6
 
7
- const { sin, cos } = require('../utils/trigonometry')
7
+ const { sin, cos } = require('../maths/utils/trigonometry')
8
8
 
9
9
  const { isGTE, isNumberArray } = require('./commonChecks')
10
10
 
@@ -123,6 +123,13 @@ test('ellipse (options)', (t) => {
123
123
  t.deepEqual(obs.length, 6)
124
124
  t.true(comparePoints(obs, exp))
125
125
 
126
+ // test full rotation with non-zero startAngle
127
+ geometry = ellipse({ startAngle: 1, endAngle: 1 + 2 * Math.PI })
128
+ obs = geom2.toPoints(geometry)
129
+
130
+ t.notThrows(() => geom2.validate(geometry))
131
+ t.deepEqual(obs.length, 32)
132
+
126
133
  // test segments
127
134
  geometry = ellipse({ segments: 72 })
128
135
  obs = geom2.toPoints(geometry)
@@ -3,7 +3,7 @@ const vec3 = require('../maths/vec3')
3
3
  const geom3 = require('../geometries/geom3')
4
4
  const poly3 = require('../geometries/poly3')
5
5
 
6
- const { sin, cos } = require('../utils/trigonometry')
6
+ const { sin, cos } = require('../maths/utils/trigonometry')
7
7
 
8
8
  const { isGTE, isNumberArray } = require('./commonChecks')
9
9
 
@@ -1,4 +1,5 @@
1
1
  const mat4 = require('../maths/mat4')
2
+ const vec3 = require('../maths/vec3')
2
3
 
3
4
  const geom3 = require('../geometries/geom3')
4
5
 
@@ -79,7 +80,7 @@ const geodesicSphere = (options) => {
79
80
 
80
81
  // -- normalize
81
82
  for (let k = 0; k < 3; k++) {
82
- const r = Math.hypot(q[k][0], q[k][1], q[k][2])
83
+ const r = vec3.length(q[k])
83
84
  for (let l = 0; l < 3; l++) {
84
85
  q[k][l] /= r
85
86
  }
@@ -95,7 +96,7 @@ const geodesicSphere = (options) => {
95
96
 
96
97
  // -- normalize
97
98
  for (let k = 0; k < 3; k++) {
98
- const r = Math.hypot(q[k][0], q[k][1], q[k][2])
99
+ const r = vec3.length(q[k])
99
100
  for (let l = 0; l < 3; l++) {
100
101
  q[k][l] /= r
101
102
  }
@@ -6,12 +6,14 @@ const vec3 = require('../maths/vec3')
6
6
  const geom3 = require('../geometries/geom3')
7
7
  const poly3 = require('../geometries/poly3')
8
8
 
9
+ const { sin, cos } = require('../maths/utils/trigonometry')
10
+
9
11
  const { isGT, isGTE, isNumberArray } = require('./commonChecks')
10
12
 
11
13
  const createCorners = (center, size, radius, segments, slice, positive) => {
12
14
  const pitch = (Math.PI / 2) * slice / segments
13
- const cospitch = Math.cos(pitch)
14
- const sinpitch = Math.sin(pitch)
15
+ const cospitch = cos(pitch)
16
+ const sinpitch = sin(pitch)
15
17
 
16
18
  const layersegments = segments - slice
17
19
  let layerradius = radius * cospitch
@@ -5,7 +5,7 @@ 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')
8
+ const { sin, cos } = require('../maths/utils/trigonometry')
9
9
 
10
10
  const { isGT, isGTE, isNumberArray } = require('./commonChecks')
11
11
 
@@ -15,7 +15,6 @@ test('torus (defaults)', (t) => {
15
15
 
16
16
  const bounds = measureBoundingBox(obs)
17
17
  const expectedBounds = [[-5, -5, -1], [5, 5, 1]]
18
- t.notThrows(() => geom3.validate(obs))
19
18
  t.true(comparePoints(bounds, expectedBounds), 'Bounding box was not as expected: ' + JSON.stringify(bounds))
20
19
  })
21
20
 
@@ -27,7 +26,6 @@ test('torus (simple options)', (t) => {
27
26
 
28
27
  const bounds = measureBoundingBox(obs)
29
28
  const expectedBounds = [[-5.5, -5.5, -0.5], [5.5, 5.5, 0.5]]
30
- t.notThrows(() => geom3.validate(obs))
31
29
  t.true(comparePoints(bounds, expectedBounds), 'Bounding box was not as expected: ' + JSON.stringify(bounds))
32
30
  })
33
31
 
@@ -39,10 +37,16 @@ test('torus (complex options)', (t) => {
39
37
 
40
38
  const bounds = measureBoundingBox(obs)
41
39
  const expectedBounds = [[-6, 0, -1], [0, 6, 1]]
42
- t.notThrows(() => geom3.validate(obs))
43
40
  t.true(comparePoints(bounds, expectedBounds), 'Bounding box was not as expected: ' + JSON.stringify(bounds))
44
41
  })
45
42
 
43
+ test('torus (startAngle)', (t) => {
44
+ const obs = torus({ startAngle: 1, endAngle: 1 + 2 * Math.PI })
45
+ const pts = geom3.toPoints(obs)
46
+ t.notThrows(() => geom3.validate(obs))
47
+ t.is(pts.length, 2048)
48
+ })
49
+
46
50
  test('torus (square by square)', (t) => {
47
51
  const obs = torus({ innerSegments: 4, outerSegments: 4, innerRotation: Math.PI / 2 })
48
52
 
@@ -5,6 +5,5 @@ export { default as fnNumberSort } from './fnNumberSort'
5
5
  export { default as insertSorted } from './insertSorted'
6
6
  export { default as radiusToSegments } from './radiusToSegments'
7
7
  export { default as radToDeg } from './radToDeg'
8
- export * from './trigonometry'
9
8
 
10
9
  export as namespace utils
@@ -6,12 +6,10 @@
6
6
  */
7
7
  module.exports = {
8
8
  areAllShapesTheSameType: require('./areAllShapesTheSameType'),
9
- cos: require('./trigonometry').cos,
10
9
  degToRad: require('./degToRad'),
11
10
  flatten: require('./flatten'),
12
11
  fnNumberSort: require('./fnNumberSort'),
13
12
  insertSorted: require('./insertSorted'),
14
13
  radiusToSegments: require('./radiusToSegments'),
15
- radToDeg: require('./radToDeg'),
16
- sin: require('./trigonometry').sin
14
+ radToDeg: require('./radToDeg')
17
15
  }
@@ -1 +0,0 @@
1
- export const EPSILON: number
@@ -1,5 +0,0 @@
1
- const EPSILON = 0.000001
2
-
3
- module.exports = {
4
- EPSILON
5
- }