@jscad/modeling 3.0.1-alpha.0 → 3.0.3-alpha.0
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.
- package/CHANGELOG.md +22 -0
- package/dist/jscad-modeling.es.js +2 -2
- package/dist/jscad-modeling.min.js +2 -2
- package/package.json +2 -2
- package/src/colors/colorize.test.js +1 -1
- package/src/geometries/geom2/index.d.ts +0 -2
- package/src/geometries/geom2/index.js +0 -2
- package/src/geometries/geom3/applyTransforms.test.js +2 -2
- package/src/geometries/geom3/clone.test.js +2 -2
- package/src/geometries/geom3/create.js +1 -9
- package/src/geometries/geom3/{fromPoints.d.ts → fromVertices.d.ts} +1 -1
- package/src/geometries/geom3/{fromPoints.js → fromVertices.js} +3 -2
- package/src/geometries/geom3/{fromPoints.test.js → fromVertices.test.js} +6 -6
- package/src/geometries/geom3/{fromPointsConvex.d.ts → fromVerticesConvex.d.ts} +1 -1
- package/src/geometries/geom3/fromVerticesConvex.js +25 -0
- package/src/geometries/geom3/{fromPointsConvex.test.js → fromVerticesConvex.test.js} +3 -3
- package/src/geometries/geom3/index.d.ts +3 -5
- package/src/geometries/geom3/index.js +4 -6
- package/src/geometries/geom3/invert.test.js +2 -2
- package/src/geometries/geom3/isA.test.js +2 -2
- package/src/geometries/geom3/toString.test.js +2 -2
- package/src/geometries/geom3/{toPoints.d.ts → toVertices.d.ts} +1 -1
- package/src/geometries/geom3/{toPoints.js → toVertices.js} +3 -2
- package/src/geometries/geom3/{toPoints.test.js → toVertices.test.js} +4 -4
- package/src/geometries/geom3/transform.test.js +2 -2
- package/src/geometries/geom3/validate.test.js +4 -4
- package/src/geometries/index.d.ts +1 -0
- package/src/geometries/index.js +1 -0
- package/src/geometries/path2/appendBezier.js +1 -1
- package/src/geometries/path2/create.js +1 -10
- package/src/geometries/path2/index.d.ts +0 -2
- package/src/geometries/path2/index.js +0 -2
- package/src/geometries/path3/applyTransforms.js +22 -0
- package/src/geometries/path3/applyTransforms.test.js +28 -0
- package/src/geometries/path3/close.d.ts +3 -0
- package/src/geometries/path3/close.js +31 -0
- package/src/geometries/path3/close.test.js +43 -0
- package/src/geometries/path3/concat.d.ts +3 -0
- package/src/geometries/path3/concat.js +36 -0
- package/src/geometries/path3/concat.test.js +35 -0
- package/src/geometries/path3/create.d.ts +4 -0
- package/src/geometries/path3/create.js +30 -0
- package/src/geometries/path3/create.test.js +8 -0
- package/src/geometries/path3/equals.d.ts +3 -0
- package/src/geometries/path3/equals.js +48 -0
- package/src/geometries/path3/equals.test.js +38 -0
- package/src/geometries/path3/fromVertices.d.ts +8 -0
- package/src/geometries/path3/fromVertices.js +45 -0
- package/src/geometries/path3/fromVertices.test.js +33 -0
- package/src/geometries/path3/index.d.ts +13 -0
- package/src/geometries/path3/index.js +21 -0
- package/src/geometries/path3/isA.d.ts +3 -0
- package/src/geometries/path3/isA.js +20 -0
- package/src/geometries/path3/isA.test.js +19 -0
- package/src/geometries/path3/reverse.d.ts +3 -0
- package/src/geometries/path3/reverse.js +19 -0
- package/src/geometries/path3/reverse.test.js +9 -0
- package/src/geometries/path3/toString.d.ts +3 -0
- package/src/geometries/path3/toString.js +24 -0
- package/src/geometries/path3/toVertices.d.ts +4 -0
- package/src/geometries/path3/toVertices.js +16 -0
- package/src/geometries/path3/toVertices.test.js +13 -0
- package/src/geometries/path3/transform.d.ts +4 -0
- package/src/geometries/path3/transform.js +21 -0
- package/src/geometries/path3/transform.test.js +50 -0
- package/src/geometries/path3/type.d.ts +10 -0
- package/src/geometries/path3/validate.d.ts +1 -0
- package/src/geometries/path3/validate.js +41 -0
- package/src/geometries/poly2/create.js +1 -6
- package/src/geometries/poly3/create.js +1 -6
- package/src/geometries/poly3/index.js +1 -1
- package/src/geometries/poly3/measureBoundingBox.js +2 -0
- package/src/geometries/poly3/measureBoundingSphere.d.ts +2 -1
- package/src/geometries/poly3/measureBoundingSphere.js +25 -8
- package/src/geometries/poly3/measureBoundingSphere.test.js +12 -8
- package/src/index.js +41 -0
- package/src/measurements/measureBoundingSphere.js +2 -6
- package/src/operations/booleans/intersectGeom3.test.js +4 -4
- package/src/operations/booleans/martinez/compareEvents.js +2 -7
- package/src/operations/booleans/martinez/connectEdges.js +30 -41
- package/src/operations/booleans/martinez/contour.js +1 -1
- package/src/operations/booleans/martinez/divideSegment.js +12 -11
- package/src/operations/booleans/martinez/fillQueue.js +24 -28
- package/src/operations/booleans/martinez/index.js +2 -1
- package/src/operations/booleans/martinez/possibleIntersection.js +41 -30
- package/src/operations/booleans/martinez/segmentIntersection.js +7 -9
- package/src/operations/booleans/martinez/splaytree.js +59 -457
- package/src/operations/booleans/martinez/subdivideSegments.js +4 -4
- package/src/operations/booleans/martinez/sweepEvent.js +3 -17
- package/src/operations/booleans/subtractGeom3.test.js +4 -4
- package/src/operations/booleans/trees/Node.js +25 -27
- package/src/operations/booleans/trees/PolygonTreeNode.js +153 -106
- package/src/operations/booleans/trees/Tree.js +9 -4
- package/src/operations/booleans/trees/splitLineSegmentByPlane.js +5 -3
- package/src/operations/booleans/trees/splitPolygonByPlane.js +39 -34
- package/src/operations/booleans/unionGeom3.test.js +5 -5
- package/src/operations/extrusions/extrudeFromSlices.test.js +6 -6
- package/src/operations/extrusions/extrudeLinear.test.js +8 -8
- package/src/operations/extrusions/extrudeRotate.test.js +12 -12
- package/src/operations/extrusions/extrudeWalls.js +3 -1
- package/src/operations/hulls/hull.test.js +5 -5
- package/src/operations/hulls/hullChain.test.js +5 -5
- package/src/operations/hulls/hullPoints2.js +20 -28
- package/src/operations/hulls/toUniquePoints.js +2 -2
- package/src/operations/modifiers/generalize.test.js +6 -6
- package/src/operations/modifiers/insertTjunctions.test.js +2 -2
- package/src/operations/modifiers/mergePolygons.js +2 -3
- package/src/operations/modifiers/reTesselateCoplanarPolygons.js +7 -7
- package/src/operations/modifiers/retessellate.test.js +10 -10
- package/src/operations/modifiers/snap.test.js +4 -4
- package/src/operations/offsets/offsetGeom3.test.js +4 -4
- package/src/operations/transforms/center.test.js +7 -7
- package/src/operations/transforms/mirror.test.js +7 -7
- package/src/operations/transforms/rotate.test.js +7 -7
- package/src/operations/transforms/scale.test.js +7 -7
- package/src/operations/transforms/transform.test.js +2 -2
- package/src/operations/transforms/translate.test.js +7 -7
- package/src/primitives/cube.test.js +4 -4
- package/src/primitives/cuboid.test.js +4 -4
- package/src/primitives/cylinder.test.js +5 -5
- package/src/primitives/cylinderElliptic.test.js +9 -9
- package/src/primitives/ellipsoid.test.js +5 -5
- package/src/primitives/geodesicSphere.test.js +4 -4
- package/src/primitives/polyhedron.test.js +2 -2
- package/src/primitives/roundedCuboid.test.js +7 -7
- package/src/primitives/roundedCylinder.test.js +9 -9
- package/src/primitives/sphere.test.js +5 -5
- package/src/primitives/torus.test.js +4 -4
- package/src/geometries/geom2/fromCompactBinary.d.ts +0 -3
- package/src/geometries/geom2/fromCompactBinary.js +0 -40
- package/src/geometries/geom2/fromToCompactBinary.test.js +0 -100
- package/src/geometries/geom2/toCompactBinary.d.ts +0 -3
- package/src/geometries/geom2/toCompactBinary.js +0 -56
- package/src/geometries/geom3/fromCompactBinary.d.ts +0 -3
- package/src/geometries/geom3/fromCompactBinary.js +0 -42
- package/src/geometries/geom3/fromPointsConvex.js +0 -25
- package/src/geometries/geom3/fromToCompactBinary.test.js +0 -139
- package/src/geometries/geom3/toCompactBinary.d.ts +0 -3
- package/src/geometries/geom3/toCompactBinary.js +0 -66
- package/src/geometries/path2/fromCompactBinary.d.ts +0 -3
- package/src/geometries/path2/fromCompactBinary.js +0 -31
- package/src/geometries/path2/fromToCompactBinary.test.js +0 -114
- package/src/geometries/path2/toCompactBinary.d.ts +0 -3
- package/src/geometries/path2/toCompactBinary.js +0 -50
|
@@ -67,7 +67,6 @@ const calculateAngle = (prevVertex, midVertex, nextVertex, normal) => {
|
|
|
67
67
|
|
|
68
68
|
// create a polygon starting from the given edge (if possible)
|
|
69
69
|
const createPolygonAnd = (edge) => {
|
|
70
|
-
let polygon
|
|
71
70
|
const vertices = []
|
|
72
71
|
while (edge.next) {
|
|
73
72
|
const next = edge.next
|
|
@@ -81,8 +80,8 @@ const createPolygonAnd = (edge) => {
|
|
|
81
80
|
|
|
82
81
|
edge = next
|
|
83
82
|
}
|
|
84
|
-
if (vertices.length > 0)
|
|
85
|
-
return
|
|
83
|
+
if (vertices.length > 0) return poly3.create(vertices)
|
|
84
|
+
return null
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
/*
|
|
@@ -31,7 +31,7 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
31
31
|
// Make a list of all encountered y coordinates
|
|
32
32
|
// And build a map of all polygons that have a vertex at a certain y coordinate:
|
|
33
33
|
const yCoordinateBins = new Map()
|
|
34
|
-
const yCoordinateBinningFactor = 10 / EPS
|
|
34
|
+
const yCoordinateBinningFactor = 10 / EPS // FIXME
|
|
35
35
|
for (let polygonIndex = 0; polygonIndex < numPolygons; polygonIndex++) {
|
|
36
36
|
const poly3d = sourcePolygons[polygonIndex]
|
|
37
37
|
let vertices2d = []
|
|
@@ -68,7 +68,7 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
68
68
|
}
|
|
69
69
|
let polygonIndexes = yCoordinateToPolygonIndexes.get(y)
|
|
70
70
|
if (!polygonIndexes) {
|
|
71
|
-
polygonIndexes =
|
|
71
|
+
polygonIndexes = []
|
|
72
72
|
yCoordinateToPolygonIndexes.set(y, polygonIndexes)
|
|
73
73
|
}
|
|
74
74
|
polygonIndexes[polygonIndex] = true
|
|
@@ -242,7 +242,7 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
242
242
|
const prevOutPolygon = newOutPolygonRow[newOutPolygonRow.length - 1]
|
|
243
243
|
const d1 = vec2.distance(outPolygon.topLeft, prevOutPolygon.topRight)
|
|
244
244
|
const d2 = vec2.distance(outPolygon.bottomLeft, prevOutPolygon.bottomRight)
|
|
245
|
-
if ((d1 < EPS) && (d2 < EPS)) {
|
|
245
|
+
if ((d1 < EPS) && (d2 < EPS)) { // FIXME
|
|
246
246
|
// we can join this polygon with the one to the left:
|
|
247
247
|
outPolygon.topLeft = prevOutPolygon.topLeft
|
|
248
248
|
outPolygon.leftLine = prevOutPolygon.leftLine
|
|
@@ -263,8 +263,8 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
263
263
|
// We have a match if the sidelines are equal or if the top coordinates
|
|
264
264
|
// are on the sidelines of the previous polygon
|
|
265
265
|
const prevPolygon = prevOutPolygonRow[ii]
|
|
266
|
-
if (vec2.distance(prevPolygon.bottomLeft, thisPolygon.topLeft) < EPS) {
|
|
267
|
-
if (vec2.distance(prevPolygon.bottomRight, thisPolygon.topRight) < EPS) {
|
|
266
|
+
if (vec2.distance(prevPolygon.bottomLeft, thisPolygon.topLeft) < EPS) { // FIXME
|
|
267
|
+
if (vec2.distance(prevPolygon.bottomRight, thisPolygon.topRight) < EPS) { // FIXME
|
|
268
268
|
// Yes, the top of this polygon matches the bottom of the previous:
|
|
269
269
|
matchedIndexes.add(ii)
|
|
270
270
|
// Now check if the joined polygon would remain convex:
|
|
@@ -300,7 +300,7 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
300
300
|
// Finish the polygon with the last point(s):
|
|
301
301
|
const prevPolygon = prevOutPolygonRow[ii]
|
|
302
302
|
prevPolygon.outPolygon.rightPoints.push(prevPolygon.bottomRight)
|
|
303
|
-
if (vec2.distance(prevPolygon.bottomRight, prevPolygon.bottomLeft) > EPS) {
|
|
303
|
+
if (vec2.distance(prevPolygon.bottomRight, prevPolygon.bottomLeft) > EPS) { // FIXME
|
|
304
304
|
// polygon ends with a horizontal line:
|
|
305
305
|
prevPolygon.outPolygon.leftPoints.push(prevPolygon.bottomLeft)
|
|
306
306
|
}
|
|
@@ -324,7 +324,7 @@ export const reTesselateCoplanarPolygons = (sourcePolygons) => {
|
|
|
324
324
|
rightPoints: []
|
|
325
325
|
}
|
|
326
326
|
thisPolygon.outPolygon.leftPoints.push(thisPolygon.topLeft)
|
|
327
|
-
if (vec2.distance(thisPolygon.topLeft, thisPolygon.topRight) > EPS) {
|
|
327
|
+
if (vec2.distance(thisPolygon.topLeft, thisPolygon.topRight) > EPS) { // FIXME
|
|
328
328
|
// we have a horizontal line at the top:
|
|
329
329
|
thisPolygon.outPolygon.rightPoints.push(thisPolygon.topRight)
|
|
330
330
|
}
|
|
@@ -82,15 +82,15 @@ test('geom3: retessellate() should create proper geometry from solid geometries'
|
|
|
82
82
|
[[10.0, -5.0, -5.0], [10.0, 5.0, -5.0], [10.0, 5.0, 5.0], [10.0, -5.0, 5.0]] // end
|
|
83
83
|
]
|
|
84
84
|
|
|
85
|
-
const obj1 = geom3.
|
|
86
|
-
const obj2 = geom3.
|
|
87
|
-
const obj3 = geom3.
|
|
88
|
-
const obj4 = geom3.
|
|
89
|
-
const obj5 = geom3.
|
|
85
|
+
const obj1 = geom3.fromVertices(box1)
|
|
86
|
+
const obj2 = geom3.fromVertices(box1.concat(box2)) // combined geometry
|
|
87
|
+
const obj3 = geom3.fromVertices(box3)
|
|
88
|
+
const obj4 = geom3.fromVertices(box4)
|
|
89
|
+
const obj5 = geom3.fromVertices(box5)
|
|
90
90
|
|
|
91
91
|
// one solid geometry
|
|
92
92
|
const ret1 = retessellate(obj1)
|
|
93
|
-
const pts1 = geom3.
|
|
93
|
+
const pts1 = geom3.toVertices(ret1)
|
|
94
94
|
const exp1 = [
|
|
95
95
|
[[-5, -5, -5], [-5, -5, 5], [-5, 5, 5], [-5, 5, -5]],
|
|
96
96
|
[[5, -5, -5], [5, 5, -5], [5, 5, 5], [5, -5, 5]],
|
|
@@ -103,7 +103,7 @@ test('geom3: retessellate() should create proper geometry from solid geometries'
|
|
|
103
103
|
|
|
104
104
|
// two non-overlapping geometries
|
|
105
105
|
const ret2 = retessellate(obj2)
|
|
106
|
-
const pts2 = geom3.
|
|
106
|
+
const pts2 = geom3.toVertices(ret2)
|
|
107
107
|
const exp2 = [
|
|
108
108
|
[[-5, -5, -5], [-5, -5, 5], [-5, 5, 5], [-5, 5, -5]],
|
|
109
109
|
[[5, -5, -5], [5, 5, -5], [5, 5, 5], [5, -5, 5]],
|
|
@@ -122,7 +122,7 @@ test('geom3: retessellate() should create proper geometry from solid geometries'
|
|
|
122
122
|
|
|
123
123
|
// two touching geometries (faces)
|
|
124
124
|
const ret3 = retessellate(obj3)
|
|
125
|
-
const pts3 = geom3.
|
|
125
|
+
const pts3 = geom3.toVertices(ret3)
|
|
126
126
|
const exp3 = [
|
|
127
127
|
[[-5, 5, 15], [-5, 5, -5], [-5, -5, -5], [-5, -5, 15]],
|
|
128
128
|
[[5, -5, 15], [5, -5, -5], [5, 5, -5], [5, 5, 15]],
|
|
@@ -135,7 +135,7 @@ test('geom3: retessellate() should create proper geometry from solid geometries'
|
|
|
135
135
|
|
|
136
136
|
// two overlapping geometries
|
|
137
137
|
const ret4 = retessellate(obj4)
|
|
138
|
-
const pts4 = geom3.
|
|
138
|
+
const pts4 = geom3.toVertices(ret4)
|
|
139
139
|
const exp4 = [
|
|
140
140
|
[[-5, -5, -5], [-5, -5, 5], [-5, 5, 5], [-5, 5, -5]],
|
|
141
141
|
[[-5, -5, -5], [5, -5, -5], [5, -5, 5], [-5, -5, 5]],
|
|
@@ -160,7 +160,7 @@ test('geom3: retessellate() should create proper geometry from solid geometries'
|
|
|
160
160
|
|
|
161
161
|
// coplanar polygons
|
|
162
162
|
const ret5 = retessellate(obj5)
|
|
163
|
-
const pts5 = geom3.
|
|
163
|
+
const pts5 = geom3.toVertices(ret5)
|
|
164
164
|
const exp5 = [
|
|
165
165
|
[[-5, -5, -5], [-5, -5, 5], [-5, 5, 5], [-5, 5, -5]],
|
|
166
166
|
[[10, -5, -5], [10, -5, 5], [-5, -5, 5], [-5, -5, -5]],
|
|
@@ -117,11 +117,11 @@ test('snap: snap of a geom3 produces an expected geom3', (t) => {
|
|
|
117
117
|
const results = snap(geometry1, geometry2, geometry3, geometry4)
|
|
118
118
|
t.is(results.length, 4)
|
|
119
119
|
|
|
120
|
-
let pts = geom3.
|
|
120
|
+
let pts = geom3.toVertices(results[0])
|
|
121
121
|
let exp = []
|
|
122
122
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
123
123
|
|
|
124
|
-
pts = geom3.
|
|
124
|
+
pts = geom3.toVertices(results[1])
|
|
125
125
|
exp = [
|
|
126
126
|
[[-0.5, -0.5, -0.5], [-0.5, -0.5, 0.5], [-0.5, 0.5, 0.5], [-0.5, 0.5, -0.5]],
|
|
127
127
|
[[0.5, -0.5, -0.5], [0.5, 0.5, -0.5], [0.5, 0.5, 0.5], [0.5, -0.5, 0.5]],
|
|
@@ -132,7 +132,7 @@ test('snap: snap of a geom3 produces an expected geom3', (t) => {
|
|
|
132
132
|
]
|
|
133
133
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
134
134
|
|
|
135
|
-
pts = geom3.
|
|
135
|
+
pts = geom3.toVertices(results[2])
|
|
136
136
|
exp = [
|
|
137
137
|
[[-0.6666666666666667, -0.6666666666666667, -0.6666666666666667], [-0.6666666666666667, -0.6666666666666667, 0.6666666666666667],
|
|
138
138
|
[-0.6666666666666667, 0.6666666666666667, 0.6666666666666667], [-0.6666666666666667, 0.6666666666666667, -0.6666666666666667]],
|
|
@@ -149,7 +149,7 @@ test('snap: snap of a geom3 produces an expected geom3', (t) => {
|
|
|
149
149
|
]
|
|
150
150
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
151
151
|
|
|
152
|
-
pts = geom3.
|
|
152
|
+
pts = geom3.toVertices(results[3])
|
|
153
153
|
exp = [
|
|
154
154
|
[[-1570.7963267948967, -1570.7963267948967, -1570.7963267948967], [-1570.7963267948967, -1570.7963267948967, 1570.7963267948967],
|
|
155
155
|
[-1570.7963267948967, 1570.7963267948967, 1570.7963267948967], [-1570.7963267948967, 1570.7963267948967, -1570.7963267948967]],
|
|
@@ -19,7 +19,7 @@ test('offset: offset empty geom3', (t) => {
|
|
|
19
19
|
t.is(measureArea(result), 0)
|
|
20
20
|
t.is(measureVolume(result), 0)
|
|
21
21
|
t.is(geom3.toPolygons(result).length, 0)
|
|
22
|
-
t.is(geom3.
|
|
22
|
+
t.is(geom3.toVertices(result).length, 0)
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
test('offset: offset geom3 preserves color', (t) => {
|
|
@@ -37,10 +37,10 @@ test('offset: offset of a geom3 produces expected changes to polygons', (t) => {
|
|
|
37
37
|
[[-5, -5, -5], [-5, 15, -5], [15, 15, -5], [15, -5, -5]],
|
|
38
38
|
[[-5, -5, 15], [15, -5, 15], [15, 15, 15], [-5, 15, 15]]
|
|
39
39
|
]
|
|
40
|
-
const geometry = geom3.
|
|
40
|
+
const geometry = geom3.fromVertices(polygonsAsPoints)
|
|
41
41
|
|
|
42
42
|
const obs = offset({ delta: 2, corners: 'round', segments: 8 }, geometry)
|
|
43
|
-
const pts = geom3.
|
|
43
|
+
const pts = geom3.toVertices(obs)
|
|
44
44
|
const exp0 = [
|
|
45
45
|
[-7, -5, -5],
|
|
46
46
|
[-7, -5, 15],
|
|
@@ -62,7 +62,7 @@ test('offset: offset of a geom3 produces expected changes to polygons', (t) => {
|
|
|
62
62
|
|
|
63
63
|
const geometry2 = sphere({ radius: 5, segments: 8 })
|
|
64
64
|
const obs2 = offset({ delta: 5 }, geometry2)
|
|
65
|
-
const pts2 = geom3.
|
|
65
|
+
const pts2 = geom3.toVertices(obs2)
|
|
66
66
|
t.notThrows.skip(() => geom3.validate(obs2))
|
|
67
67
|
t.is(measureArea(obs), 3178.8059464475555)
|
|
68
68
|
t.is(measureVolume(obs), 13504.574121271067)
|
|
@@ -53,11 +53,11 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
53
53
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
54
54
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
55
55
|
]
|
|
56
|
-
const geometry = geom3.
|
|
56
|
+
const geometry = geom3.fromVertices(points)
|
|
57
57
|
|
|
58
58
|
// center about X
|
|
59
59
|
let centered = center({ axes: [true, false, false] }, geometry)
|
|
60
|
-
let pts = geom3.
|
|
60
|
+
let pts = geom3.toVertices(centered)
|
|
61
61
|
let exp = [
|
|
62
62
|
[[-5, -7, -12], [-5, -7, 18], [-5, 13, 18], [-5, 13, -12]],
|
|
63
63
|
[[5, -7, -12], [5, 13, -12], [5, 13, 18], [5, -7, 18]],
|
|
@@ -71,14 +71,14 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
71
71
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
72
72
|
|
|
73
73
|
centered = centerX(geometry)
|
|
74
|
-
pts = geom3.
|
|
74
|
+
pts = geom3.toVertices(centered)
|
|
75
75
|
t.notThrows(() => geom3.validate(centered))
|
|
76
76
|
t.is(measureVolume(centered), measureVolume(geometry))
|
|
77
77
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
78
78
|
|
|
79
79
|
// center about Y
|
|
80
80
|
centered = center({ axes: [false, true, false] }, geometry)
|
|
81
|
-
pts = geom3.
|
|
81
|
+
pts = geom3.toVertices(centered)
|
|
82
82
|
exp = [
|
|
83
83
|
[[-2, -10, -12], [-2, -10, 18], [-2, 10, 18], [-2, 10, -12]],
|
|
84
84
|
[[8, -10, -12], [8, 10, -12], [8, 10, 18], [8, -10, 18]],
|
|
@@ -92,14 +92,14 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
92
92
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
93
93
|
|
|
94
94
|
centered = centerY(geometry)
|
|
95
|
-
pts = geom3.
|
|
95
|
+
pts = geom3.toVertices(centered)
|
|
96
96
|
t.notThrows(() => geom3.validate(centered))
|
|
97
97
|
t.is(measureVolume(centered), measureVolume(geometry))
|
|
98
98
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
99
99
|
|
|
100
100
|
// center about Z
|
|
101
101
|
centered = center({ axes: [false, false, true] }, geometry)
|
|
102
|
-
pts = geom3.
|
|
102
|
+
pts = geom3.toVertices(centered)
|
|
103
103
|
exp = [
|
|
104
104
|
[[-2, -7, -15], [-2, -7, 15], [-2, 13, 15], [-2, 13, -15]],
|
|
105
105
|
[[8, -7, -15], [8, 13, -15], [8, 13, 15], [8, -7, 15]],
|
|
@@ -113,7 +113,7 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
113
113
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
114
114
|
|
|
115
115
|
centered = centerZ(geometry)
|
|
116
|
-
pts = geom3.
|
|
116
|
+
pts = geom3.toVertices(centered)
|
|
117
117
|
t.notThrows(() => geom3.validate(centered))
|
|
118
118
|
t.is(measureVolume(centered), measureVolume(geometry))
|
|
119
119
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
@@ -77,11 +77,11 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
77
77
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
78
78
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
79
79
|
]
|
|
80
|
-
const geometry = geom3.
|
|
80
|
+
const geometry = geom3.fromVertices(points)
|
|
81
81
|
|
|
82
82
|
// mirror about X
|
|
83
83
|
let mirrored = mirror({ normal: [1, 0, 0] }, geometry)
|
|
84
|
-
let obs = geom3.
|
|
84
|
+
let obs = geom3.toVertices(mirrored)
|
|
85
85
|
let exp = [
|
|
86
86
|
[[2, 13, -12], [2, 13, 18], [2, -7, 18], [2, -7, -12]],
|
|
87
87
|
[[-8, -7, 18], [-8, 13, 18], [-8, 13, -12], [-8, -7, -12]],
|
|
@@ -96,14 +96,14 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
96
96
|
t.deepEqual(obs, exp)
|
|
97
97
|
|
|
98
98
|
mirrored = mirrorX(geometry)
|
|
99
|
-
obs = geom3.
|
|
99
|
+
obs = geom3.toVertices(mirrored)
|
|
100
100
|
t.notThrows(() => geom3.validate(mirrored))
|
|
101
101
|
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
102
102
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
103
103
|
|
|
104
104
|
// mirror about Y
|
|
105
105
|
mirrored = mirror({ normal: [0, 1, 0] }, geometry)
|
|
106
|
-
obs = geom3.
|
|
106
|
+
obs = geom3.toVertices(mirrored)
|
|
107
107
|
exp = [
|
|
108
108
|
[[-2, -13, -12], [-2, -13, 18], [-2, 7, 18], [-2, 7, -12]],
|
|
109
109
|
[[8, 7, 18], [8, -13, 18], [8, -13, -12], [8, 7, -12]],
|
|
@@ -117,14 +117,14 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
117
117
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
118
118
|
|
|
119
119
|
mirrored = mirrorY(geometry)
|
|
120
|
-
obs = geom3.
|
|
120
|
+
obs = geom3.toVertices(mirrored)
|
|
121
121
|
t.notThrows(() => geom3.validate(mirrored))
|
|
122
122
|
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
123
123
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
124
124
|
|
|
125
125
|
// mirror about Z
|
|
126
126
|
mirrored = mirror({ normal: [0, 0, 1] }, geometry)
|
|
127
|
-
obs = geom3.
|
|
127
|
+
obs = geom3.toVertices(mirrored)
|
|
128
128
|
exp = [
|
|
129
129
|
[[-2, 13, 12], [-2, 13, -18], [-2, -7, -18], [-2, -7, 12]],
|
|
130
130
|
[[8, -7, -18], [8, 13, -18], [8, 13, 12], [8, -7, 12]],
|
|
@@ -138,7 +138,7 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
138
138
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
139
139
|
|
|
140
140
|
mirrored = mirrorZ(geometry)
|
|
141
|
-
obs = geom3.
|
|
141
|
+
obs = geom3.toVertices(mirrored)
|
|
142
142
|
t.notThrows(() => geom3.validate(mirrored))
|
|
143
143
|
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
144
144
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
@@ -60,11 +60,11 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
60
60
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
61
61
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
62
62
|
]
|
|
63
|
-
const geometry = geom3.
|
|
63
|
+
const geometry = geom3.fromVertices(points)
|
|
64
64
|
|
|
65
65
|
// rotate about X
|
|
66
66
|
let rotated = rotate([TAU / 4], geometry)
|
|
67
|
-
let obs = geom3.
|
|
67
|
+
let obs = geom3.toVertices(rotated)
|
|
68
68
|
let exp = [
|
|
69
69
|
[[-2, 12, -7.000000000000001], [-2, -18, -6.999999999999999],
|
|
70
70
|
[-2, -18, 13.000000000000002], [-2, 12, 13]],
|
|
@@ -84,14 +84,14 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
84
84
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
85
85
|
|
|
86
86
|
rotated = rotateX(TAU / 4, geometry)
|
|
87
|
-
obs = geom3.
|
|
87
|
+
obs = geom3.toVertices(rotated)
|
|
88
88
|
t.notThrows(() => geom3.validate(rotated))
|
|
89
89
|
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
90
90
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
91
91
|
|
|
92
92
|
// rotate about Y
|
|
93
93
|
rotated = rotate([0, -TAU / 4], geometry)
|
|
94
|
-
obs = geom3.
|
|
94
|
+
obs = geom3.toVertices(rotated)
|
|
95
95
|
exp = [
|
|
96
96
|
[[12, -7, -2.000000000000001], [-18, -7, -1.999999999999999],
|
|
97
97
|
[-18, 13, -1.999999999999999], [12, 13, -2.000000000000001]],
|
|
@@ -111,14 +111,14 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
111
111
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
112
112
|
|
|
113
113
|
rotated = rotateY(-TAU / 4, geometry)
|
|
114
|
-
obs = geom3.
|
|
114
|
+
obs = geom3.toVertices(rotated)
|
|
115
115
|
t.notThrows(() => geom3.validate(rotated))
|
|
116
116
|
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
117
117
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
118
118
|
|
|
119
119
|
// rotate about Z
|
|
120
120
|
rotated = rotate([0, 0, TAU / 2], geometry)
|
|
121
|
-
obs = geom3.
|
|
121
|
+
obs = geom3.toVertices(rotated)
|
|
122
122
|
exp = [
|
|
123
123
|
[[2.000000000000001, 7, -12], [2.000000000000001, 7, 18],
|
|
124
124
|
[1.9999999999999984, -13, 18], [1.9999999999999984, -13, -12]],
|
|
@@ -138,7 +138,7 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
138
138
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
139
139
|
|
|
140
140
|
rotated = rotateZ(TAU / 2, geometry)
|
|
141
|
-
obs = geom3.
|
|
141
|
+
obs = geom3.toVertices(rotated)
|
|
142
142
|
t.notThrows(() => geom3.validate(rotated))
|
|
143
143
|
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
144
144
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
@@ -77,11 +77,11 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
|
|
|
77
77
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
78
78
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
79
79
|
]
|
|
80
|
-
const geometry = geom3.
|
|
80
|
+
const geometry = geom3.fromVertices(points)
|
|
81
81
|
|
|
82
82
|
// scale X
|
|
83
83
|
let scaled = scale([3], geometry)
|
|
84
|
-
let obs = geom3.
|
|
84
|
+
let obs = geom3.toVertices(scaled)
|
|
85
85
|
let exp = [
|
|
86
86
|
[[-6, -7, -12], [-6, -7, 18], [-6, 13, 18], [-6, 13, -12]],
|
|
87
87
|
[[24, -7, -12], [24, 13, -12], [24, 13, 18], [24, -7, 18]],
|
|
@@ -95,14 +95,14 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
|
|
|
95
95
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
96
96
|
|
|
97
97
|
scaled = scaleX(3, geometry)
|
|
98
|
-
obs = geom3.
|
|
98
|
+
obs = geom3.toVertices(scaled)
|
|
99
99
|
t.notThrows(() => geom3.validate(scaled))
|
|
100
100
|
t.is(measureVolume(scaled), 3 * measureVolume(geometry))
|
|
101
101
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
102
102
|
|
|
103
103
|
// scale Y
|
|
104
104
|
scaled = scale([1, 0.5], geometry)
|
|
105
|
-
obs = geom3.
|
|
105
|
+
obs = geom3.toVertices(scaled)
|
|
106
106
|
exp = [
|
|
107
107
|
[[-2, -3.5, -12], [-2, -3.5, 18], [-2, 6.5, 18], [-2, 6.5, -12]],
|
|
108
108
|
[[8, -3.5, -12], [8, 6.5, -12], [8, 6.5, 18], [8, -3.5, 18]],
|
|
@@ -116,14 +116,14 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
|
|
|
116
116
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
117
117
|
|
|
118
118
|
scaled = scaleY(0.5, geometry)
|
|
119
|
-
obs = geom3.
|
|
119
|
+
obs = geom3.toVertices(scaled)
|
|
120
120
|
t.notThrows(() => geom3.validate(scaled))
|
|
121
121
|
t.is(measureVolume(scaled), 0.5 * measureVolume(geometry))
|
|
122
122
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
123
123
|
|
|
124
124
|
// scale Z
|
|
125
125
|
scaled = scale([1, 1, 5], geometry)
|
|
126
|
-
obs = geom3.
|
|
126
|
+
obs = geom3.toVertices(scaled)
|
|
127
127
|
exp = [
|
|
128
128
|
[[-2, -7, -60], [-2, -7, 90], [-2, 13, 90], [-2, 13, -60]],
|
|
129
129
|
[[8, -7, -60], [8, 13, -60], [8, 13, 90], [8, -7, 90]],
|
|
@@ -137,7 +137,7 @@ test('scale: scaling of a geom3 produces expected changes to polygons', (t) => {
|
|
|
137
137
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
138
138
|
|
|
139
139
|
scaled = scaleZ(5, geometry)
|
|
140
|
-
obs = geom3.
|
|
140
|
+
obs = geom3.toVertices(scaled)
|
|
141
141
|
t.notThrows(() => geom3.validate(scaled))
|
|
142
142
|
t.is(measureVolume(scaled), 5 * measureVolume(geometry))
|
|
143
143
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
@@ -40,9 +40,9 @@ test('transform: transforming of a geom3 produces expected changes to polygons',
|
|
|
40
40
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
41
41
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
42
42
|
]
|
|
43
|
-
let geometry = geom3.
|
|
43
|
+
let geometry = geom3.fromVertices(points)
|
|
44
44
|
geometry = transform(matrix, geometry)
|
|
45
|
-
const obs = geom3.
|
|
45
|
+
const obs = geom3.toVertices(geometry)
|
|
46
46
|
const exp = [
|
|
47
47
|
[[-5, -10, -15], [-5, -10, 15], [-5, 10, 15], [-5, 10, -15]],
|
|
48
48
|
[[5, -10, -15], [5, 10, -15], [5, 10, 15], [5, -10, 15]],
|
|
@@ -77,11 +77,11 @@ test('translate: translating of a geom3 produces expected changes to polygons',
|
|
|
77
77
|
[[-2, -7, -12], [-2, 13, -12], [8, 13, -12], [8, -7, -12]],
|
|
78
78
|
[[-2, -7, 18], [8, -7, 18], [8, 13, 18], [-2, 13, 18]]
|
|
79
79
|
]
|
|
80
|
-
const geometry = geom3.
|
|
80
|
+
const geometry = geom3.fromVertices(points)
|
|
81
81
|
|
|
82
82
|
// translate X
|
|
83
83
|
let translated = translate([3], geometry)
|
|
84
|
-
let obs = geom3.
|
|
84
|
+
let obs = geom3.toVertices(translated)
|
|
85
85
|
let exp = [
|
|
86
86
|
[[1, -7, -12], [1, -7, 18], [1, 13, 18], [1, 13, -12]],
|
|
87
87
|
[[11, -7, -12], [11, 13, -12], [11, 13, 18], [11, -7, 18]],
|
|
@@ -95,14 +95,14 @@ test('translate: translating of a geom3 produces expected changes to polygons',
|
|
|
95
95
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
96
96
|
|
|
97
97
|
translated = translateX(3, geometry)
|
|
98
|
-
obs = geom3.
|
|
98
|
+
obs = geom3.toVertices(translated)
|
|
99
99
|
t.notThrows(() => geom3.validate(translated))
|
|
100
100
|
t.is(measureVolume(translated), measureVolume(geometry))
|
|
101
101
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
102
102
|
|
|
103
103
|
// translated Y
|
|
104
104
|
translated = translate([0, 3], geometry)
|
|
105
|
-
obs = geom3.
|
|
105
|
+
obs = geom3.toVertices(translated)
|
|
106
106
|
exp = [
|
|
107
107
|
[[-2, -4, -12], [-2, -4, 18], [-2, 16, 18], [-2, 16, -12]],
|
|
108
108
|
[[8, -4, -12], [8, 16, -12], [8, 16, 18], [8, -4, 18]],
|
|
@@ -116,14 +116,14 @@ test('translate: translating of a geom3 produces expected changes to polygons',
|
|
|
116
116
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
117
117
|
|
|
118
118
|
translated = translateY(3, geometry)
|
|
119
|
-
obs = geom3.
|
|
119
|
+
obs = geom3.toVertices(translated)
|
|
120
120
|
t.notThrows(() => geom3.validate(translated))
|
|
121
121
|
t.is(measureVolume(translated), measureVolume(geometry))
|
|
122
122
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
123
123
|
|
|
124
124
|
// translate Z
|
|
125
125
|
translated = translate([0, 0, 3], geometry)
|
|
126
|
-
obs = geom3.
|
|
126
|
+
obs = geom3.toVertices(translated)
|
|
127
127
|
exp = [
|
|
128
128
|
[[-2, -7, -9], [-2, -7, 21], [-2, 13, 21], [-2, 13, -9]],
|
|
129
129
|
[[8, -7, -9], [8, 13, -9], [8, 13, 21], [8, -7, 21]],
|
|
@@ -137,7 +137,7 @@ test('translate: translating of a geom3 produces expected changes to polygons',
|
|
|
137
137
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
138
138
|
|
|
139
139
|
translated = translateZ(3, geometry)
|
|
140
|
-
obs = geom3.
|
|
140
|
+
obs = geom3.toVertices(translated)
|
|
141
141
|
t.notThrows(() => geom3.validate(translated))
|
|
142
142
|
t.is(measureVolume(translated), measureVolume(geometry))
|
|
143
143
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
@@ -10,7 +10,7 @@ import { comparePolygonsAsPoints } from '../../test/helpers/index.js'
|
|
|
10
10
|
|
|
11
11
|
test('cube (defaults)', (t) => {
|
|
12
12
|
const obs = cube()
|
|
13
|
-
const pts = geom3.
|
|
13
|
+
const pts = geom3.toVertices(obs)
|
|
14
14
|
t.notThrows(() => geom3.validate(obs))
|
|
15
15
|
t.is(measureArea(obs), 24)
|
|
16
16
|
t.is(measureVolume(obs), 7.999999999999999)
|
|
@@ -20,7 +20,7 @@ test('cube (defaults)', (t) => {
|
|
|
20
20
|
test('cube (options)', (t) => {
|
|
21
21
|
// test center
|
|
22
22
|
let obs = cube({ size: 7, center: [6.5, 6.5, 6.5] })
|
|
23
|
-
let pts = geom3.
|
|
23
|
+
let pts = geom3.toVertices(obs)
|
|
24
24
|
let exp = [
|
|
25
25
|
[[3, 3, 3], [3, 3, 10], [3, 10, 10], [3, 10, 3]],
|
|
26
26
|
[[10, 3, 3], [10, 10, 3], [10, 10, 10], [10, 3, 10]],
|
|
@@ -38,7 +38,7 @@ test('cube (options)', (t) => {
|
|
|
38
38
|
|
|
39
39
|
// test size
|
|
40
40
|
obs = cube({ size: 7 })
|
|
41
|
-
pts = geom3.
|
|
41
|
+
pts = geom3.toVertices(obs)
|
|
42
42
|
exp = [
|
|
43
43
|
[[-3.5, -3.5, -3.5], [-3.5, -3.5, 3.5], [-3.5, 3.5, 3.5], [-3.5, 3.5, -3.5]],
|
|
44
44
|
[[3.5, -3.5, -3.5], [3.5, 3.5, -3.5], [3.5, 3.5, 3.5], [3.5, -3.5, 3.5]],
|
|
@@ -57,7 +57,7 @@ test('cube (options)', (t) => {
|
|
|
57
57
|
|
|
58
58
|
test('cube (zero size)', (t) => {
|
|
59
59
|
const obs = cube({ size: 0 })
|
|
60
|
-
const pts = geom3.
|
|
60
|
+
const pts = geom3.toVertices(obs)
|
|
61
61
|
t.notThrows(() => geom3.validate(obs))
|
|
62
62
|
t.is(measureArea(obs), 0)
|
|
63
63
|
t.is(measureVolume(obs), 0)
|
|
@@ -10,7 +10,7 @@ import { comparePolygonsAsPoints } from '../../test/helpers/index.js'
|
|
|
10
10
|
|
|
11
11
|
test('cuboid (defaults)', (t) => {
|
|
12
12
|
const obs = cuboid()
|
|
13
|
-
const pts = geom3.
|
|
13
|
+
const pts = geom3.toVertices(obs)
|
|
14
14
|
const exp = [
|
|
15
15
|
[[-1, -1, -1], [-1, -1, 1], [-1, 1, 1], [-1, 1, -1]],
|
|
16
16
|
[[1, -1, -1], [1, 1, -1], [1, 1, 1], [1, -1, 1]],
|
|
@@ -29,7 +29,7 @@ test('cuboid (defaults)', (t) => {
|
|
|
29
29
|
test('cuboid (options)', (t) => {
|
|
30
30
|
// test center
|
|
31
31
|
let obs = cuboid({ size: [6, 6, 6], center: [3, 5, 7] })
|
|
32
|
-
let pts = geom3.
|
|
32
|
+
let pts = geom3.toVertices(obs)
|
|
33
33
|
let exp = [
|
|
34
34
|
[[0, 2, 4], [0, 2, 10], [0, 8, 10], [0, 8, 4]],
|
|
35
35
|
[[6, 2, 4], [6, 8, 4], [6, 8, 10], [6, 2, 10]],
|
|
@@ -47,7 +47,7 @@ test('cuboid (options)', (t) => {
|
|
|
47
47
|
|
|
48
48
|
// test size
|
|
49
49
|
obs = cuboid({ size: [4.5, 1.5, 7] })
|
|
50
|
-
pts = geom3.
|
|
50
|
+
pts = geom3.toVertices(obs)
|
|
51
51
|
exp = [
|
|
52
52
|
[[-2.25, -0.75, -3.5], [-2.25, -0.75, 3.5], [-2.25, 0.75, 3.5], [-2.25, 0.75, -3.5]],
|
|
53
53
|
[[2.25, -0.75, -3.5], [2.25, 0.75, -3.5], [2.25, 0.75, 3.5], [2.25, -0.75, 3.5]],
|
|
@@ -66,7 +66,7 @@ test('cuboid (options)', (t) => {
|
|
|
66
66
|
|
|
67
67
|
test('cuboid (zero size)', (t) => {
|
|
68
68
|
const obs = cuboid({ size: [1, 1, 0] })
|
|
69
|
-
const pts = geom3.
|
|
69
|
+
const pts = geom3.toVertices(obs)
|
|
70
70
|
t.notThrows(() => geom3.validate(obs))
|
|
71
71
|
t.is(measureArea(obs), 0)
|
|
72
72
|
t.is(measureVolume(obs), 0)
|
|
@@ -10,7 +10,7 @@ import { comparePolygonsAsPoints } from '../../test/helpers/index.js'
|
|
|
10
10
|
|
|
11
11
|
test('cylinder (defaults)', (t) => {
|
|
12
12
|
const obs = cylinder()
|
|
13
|
-
const pts = geom3.
|
|
13
|
+
const pts = geom3.toVertices(obs)
|
|
14
14
|
|
|
15
15
|
t.notThrows(() => geom3.validate(obs))
|
|
16
16
|
t.is(measureArea(obs), 18.789084266699856)
|
|
@@ -20,7 +20,7 @@ test('cylinder (defaults)', (t) => {
|
|
|
20
20
|
|
|
21
21
|
test('cylinder (zero height)', (t) => {
|
|
22
22
|
const obs = cylinder({ height: 0 })
|
|
23
|
-
const pts = geom3.
|
|
23
|
+
const pts = geom3.toVertices(obs)
|
|
24
24
|
t.notThrows(() => geom3.validate(obs))
|
|
25
25
|
t.is(measureArea(obs), 0)
|
|
26
26
|
t.is(measureVolume(obs), 0)
|
|
@@ -29,7 +29,7 @@ test('cylinder (zero height)', (t) => {
|
|
|
29
29
|
|
|
30
30
|
test('cylinder (zero radius)', (t) => {
|
|
31
31
|
const obs = cylinder({ radius: 0 })
|
|
32
|
-
const pts = geom3.
|
|
32
|
+
const pts = geom3.toVertices(obs)
|
|
33
33
|
t.notThrows(() => geom3.validate(obs))
|
|
34
34
|
t.is(measureArea(obs), 0)
|
|
35
35
|
t.is(measureVolume(obs), 0)
|
|
@@ -38,7 +38,7 @@ test('cylinder (zero radius)', (t) => {
|
|
|
38
38
|
|
|
39
39
|
test('cylinder (options)', (t) => {
|
|
40
40
|
let obs = cylinder({ height: 10, radius: 4, segments: 5 })
|
|
41
|
-
let pts = geom3.
|
|
41
|
+
let pts = geom3.toVertices(obs)
|
|
42
42
|
let exp = [
|
|
43
43
|
[[0, 0, -5], [1.2360679774997898, 3.804226065180614, -5], [4, 0, -5]],
|
|
44
44
|
[[1.2360679774997898, 3.804226065180614, -5], [1.2360679774997898, 3.804226065180614, 5],
|
|
@@ -70,7 +70,7 @@ test('cylinder (options)', (t) => {
|
|
|
70
70
|
|
|
71
71
|
// test center
|
|
72
72
|
obs = cylinder({ center: [-5, -5, -5], segments: 5 })
|
|
73
|
-
pts = geom3.
|
|
73
|
+
pts = geom3.toVertices(obs)
|
|
74
74
|
exp = [
|
|
75
75
|
[[-5, -5, -6], [-4.6909830056250525, -4.048943483704846, -6], [-4, -5, -6]],
|
|
76
76
|
[[-4.6909830056250525, -4.048943483704846, -6], [-4.6909830056250525, -4.048943483704846, -4],
|