@jscad/modeling 2.7.2 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/jscad-modeling.min.js +443 -398
- package/package.json +2 -2
- package/src/curves/bezier/tangentAt.test.js +1 -1
- package/src/curves/bezier/valueAt.test.js +1 -1
- package/src/geometries/geom2/index.d.ts +1 -0
- package/src/geometries/geom2/index.js +12 -1
- package/src/geometries/geom2/isA.js +2 -2
- package/src/geometries/geom2/toCompactBinary.js +4 -4
- package/src/geometries/geom2/toString.js +1 -1
- package/src/geometries/geom2/transform.test.js +1 -1
- package/src/geometries/geom2/validate.d.ts +3 -0
- package/src/geometries/geom2/validate.js +36 -0
- package/src/geometries/geom3/fromCompactBinary.js +1 -1
- package/src/geometries/geom3/index.d.ts +1 -0
- package/src/geometries/geom3/index.js +19 -1
- package/src/geometries/geom3/isA.js +2 -2
- package/src/geometries/geom3/toCompactBinary.js +4 -4
- package/src/geometries/geom3/toString.js +1 -1
- package/src/geometries/geom3/transform.test.js +1 -1
- package/src/geometries/geom3/validate.d.ts +3 -0
- package/src/geometries/geom3/validate.js +62 -0
- package/src/geometries/index.js +8 -1
- package/src/geometries/path2/eachPoint.js +3 -3
- package/src/geometries/path2/index.d.ts +1 -0
- package/src/geometries/path2/index.js +13 -1
- package/src/geometries/path2/isA.js +2 -2
- package/src/geometries/path2/reverse.js +4 -4
- package/src/geometries/path2/toCompactBinary.js +6 -6
- package/src/geometries/path2/toString.js +1 -1
- package/src/geometries/path2/transform.test.js +1 -1
- package/src/geometries/path2/validate.d.ts +3 -0
- package/src/geometries/path2/validate.js +41 -0
- package/src/geometries/poly2/arePointsInside.js +0 -35
- package/src/geometries/poly2/arePointsInside.test.js +1 -1
- package/src/geometries/poly2/index.js +6 -0
- package/src/geometries/poly3/index.d.ts +1 -0
- package/src/geometries/poly3/index.js +9 -2
- package/src/geometries/poly3/invert.js +7 -1
- package/src/geometries/poly3/isA.js +2 -2
- package/src/geometries/poly3/isConvex.js +2 -2
- package/src/geometries/poly3/measureArea.js +4 -4
- package/src/geometries/poly3/measureArea.test.js +16 -16
- package/src/geometries/poly3/measureBoundingBox.js +2 -2
- package/src/geometries/poly3/measureBoundingSphere.js +2 -2
- package/src/geometries/poly3/measureBoundingSphere.test.js +8 -8
- package/src/geometries/poly3/measureSignedVolume.js +4 -4
- package/src/geometries/poly3/toPoints.js +2 -2
- package/src/geometries/poly3/toString.js +2 -2
- package/src/geometries/poly3/transform.js +2 -2
- package/src/geometries/poly3/validate.d.ts +4 -0
- package/src/geometries/poly3/validate.js +50 -0
- package/src/maths/index.js +1 -1
- package/src/maths/line2/equals.js +2 -2
- package/src/maths/line2/fromValues.js +2 -2
- package/src/maths/line2/intersectPointOfLines.js +1 -1
- package/src/maths/line2/intersectPointOfLines.test.js +1 -1
- package/src/maths/line2/reverse.test.js +1 -1
- package/src/maths/line2/transform.test.js +1 -1
- package/src/maths/line3/equals.js +2 -2
- package/src/maths/line3/reverse.test.js +1 -1
- package/src/maths/line3/transform.test.js +1 -1
- package/src/maths/mat4/fromVectorRotation.js +1 -1
- package/src/maths/mat4/fromVectorRotation.test.js +1 -1
- package/src/maths/mat4/identity.test.js +1 -1
- package/src/maths/mat4/invert.js +18 -18
- package/src/maths/mat4/isIdentity.js +1 -1
- package/src/maths/mat4/isMirroring.js +4 -4
- package/src/maths/mat4/isMirroring.test.js +1 -1
- package/src/maths/mat4/leftMultiplyVec3.js +2 -2
- package/src/maths/mat4/toString.js +2 -2
- package/src/maths/mat4/translate.test.js +1 -1
- package/src/maths/plane/flip.test.js +1 -1
- package/src/maths/plane/fromPoints.d.ts +1 -1
- package/src/maths/plane/fromPoints.js +1 -3
- package/src/maths/plane/signedDistanceToPoint.js +1 -1
- package/src/maths/plane/transform.test.js +1 -1
- package/src/maths/utils/aboutEqualNormals.js +2 -2
- package/src/maths/vec2/abs.d.ts +1 -1
- package/src/maths/vec2/add.test.js +1 -1
- package/src/maths/vec2/angleDegrees.d.ts +1 -1
- package/src/maths/vec2/angleRadians.d.ts +1 -1
- package/src/maths/vec2/create.js +1 -1
- package/src/maths/vec2/cross.test.js +1 -1
- package/src/maths/vec2/divide.test.js +1 -1
- package/src/maths/vec2/fromAngleDegrees.js +1 -1
- package/src/maths/vec2/fromScalar.js +1 -1
- package/src/maths/vec2/length.d.ts +1 -1
- package/src/maths/vec2/length.js +1 -1
- package/src/maths/vec2/lerp.test.js +1 -1
- package/src/maths/vec2/multiply.test.js +1 -1
- package/src/maths/vec2/negate.test.js +1 -1
- package/src/maths/vec2/normal.js +1 -1
- package/src/maths/vec2/normalize.d.ts +1 -1
- package/src/maths/vec2/normalize.test.js +1 -1
- package/src/maths/vec2/rotate.test.js +1 -1
- package/src/maths/vec2/squaredLength.d.ts +1 -1
- package/src/maths/vec2/squaredLength.js +3 -3
- package/src/maths/vec2/subtract.test.js +1 -1
- package/src/maths/vec2/toString.js +1 -1
- package/src/maths/vec2/transform.test.js +1 -1
- package/src/maths/vec3/abs.d.ts +1 -1
- package/src/maths/vec3/add.test.js +1 -1
- package/src/maths/vec3/cross.test.js +1 -1
- package/src/maths/vec3/divide.test.js +1 -1
- package/src/maths/vec3/fromScalar.js +1 -1
- package/src/maths/vec3/fromVec2.d.ts +1 -1
- package/src/maths/vec3/fromVec2.js +3 -3
- package/src/maths/vec3/length.d.ts +1 -1
- package/src/maths/vec3/length.js +4 -4
- package/src/maths/vec3/lerp.test.js +1 -1
- package/src/maths/vec3/multiply.test.js +1 -1
- package/src/maths/vec3/negate.d.ts +1 -1
- package/src/maths/vec3/negate.test.js +1 -1
- package/src/maths/vec3/normalize.d.ts +1 -1
- package/src/maths/vec3/normalize.test.js +1 -1
- package/src/maths/vec3/rotateX.test.js +1 -1
- package/src/maths/vec3/rotateY.test.js +1 -1
- package/src/maths/vec3/rotateZ.test.js +1 -1
- package/src/maths/vec3/scale.test.js +1 -1
- package/src/maths/vec3/squaredLength.d.ts +1 -1
- package/src/maths/vec3/squaredLength.js +4 -4
- package/src/maths/vec3/subtract.test.js +1 -1
- package/src/maths/vec3/toString.js +1 -1
- package/src/maths/vec3/transform.test.js +1 -1
- package/src/maths/vec4/toString.js +1 -1
- package/src/maths/vec4/transform.test.js +1 -1
- package/src/measurements/measureBoundingSphere.js +4 -4
- package/src/measurements/measureCenterOfMass.js +1 -1
- package/src/measurements/measureCenterOfMass.test.js +2 -2
- package/src/operations/booleans/intersect.test.js +8 -0
- package/src/operations/booleans/mayOverlap.js +3 -3
- package/src/operations/booleans/retessellate.js +2 -2
- package/src/operations/booleans/scission.js +1 -1
- package/src/operations/booleans/scission.test.js +4 -4
- package/src/operations/booleans/subtract.js +1 -1
- package/src/operations/booleans/subtract.test.js +8 -0
- package/src/operations/booleans/trees/Node.js +10 -16
- package/src/operations/booleans/trees/PolygonTreeNode.js +13 -14
- package/src/operations/booleans/trees/Tree.js +1 -2
- package/src/operations/booleans/trees/splitPolygonByPlane.js +2 -3
- package/src/operations/booleans/union.test.js +28 -1
- package/src/operations/booleans/unionGeom3Sub.js +1 -1
- package/src/operations/expansions/expand.js +2 -2
- package/src/operations/expansions/expand.test.js +32 -55
- package/src/operations/expansions/expandShell.js +24 -18
- package/src/operations/expansions/offset.js +1 -1
- package/src/operations/expansions/offset.test.js +50 -89
- package/src/operations/expansions/offsetFromPoints.js +11 -6
- package/src/operations/extrusions/earcut/assignHoles.js +91 -0
- package/src/operations/extrusions/earcut/assignHoles.test.js +74 -0
- package/src/operations/extrusions/earcut/eliminateHoles.js +131 -0
- package/src/operations/extrusions/earcut/index.js +252 -0
- package/src/operations/extrusions/earcut/linkedList.js +58 -0
- package/src/operations/extrusions/earcut/linkedListSort.js +54 -0
- package/src/operations/extrusions/earcut/linkedPolygon.js +197 -0
- package/src/operations/extrusions/earcut/polygonHierarchy.js +64 -0
- package/src/operations/extrusions/earcut/triangle.js +16 -0
- package/src/operations/extrusions/extrudeFromSlices.js +10 -3
- package/src/operations/extrusions/extrudeFromSlices.test.js +47 -31
- package/src/operations/extrusions/extrudeLinear.js +10 -5
- package/src/operations/extrusions/extrudeLinear.test.js +91 -35
- package/src/operations/extrusions/extrudeLinearGeom2.js +5 -2
- package/src/operations/extrusions/extrudeLinearPath2.js +24 -0
- package/src/operations/extrusions/extrudeRectangular.js +1 -1
- package/src/operations/extrusions/extrudeRectangular.test.js +22 -15
- package/src/operations/extrusions/extrudeRotate.test.js +31 -27
- package/src/operations/extrusions/project.js +1 -1
- package/src/operations/extrusions/project.test.js +5 -5
- package/src/operations/extrusions/slice/calculatePlane.js +7 -4
- package/src/operations/extrusions/slice/isA.js +2 -2
- package/src/operations/extrusions/slice/repairSlice.js +47 -0
- package/src/operations/extrusions/slice/toPolygons.js +24 -60
- package/src/operations/hulls/hull.test.js +25 -2
- package/src/operations/hulls/hullChain.js +1 -1
- package/src/operations/hulls/hullChain.test.js +6 -4
- package/src/operations/hulls/hullGeom2.js +1 -1
- package/src/operations/hulls/hullPath2.js +6 -4
- package/src/operations/hulls/hullPath2.test.js +16 -0
- package/src/operations/hulls/hullPoints2.test.js +1 -1
- package/src/operations/modifiers/edges.js +1 -1
- package/src/operations/modifiers/generalize.js +1 -1
- package/src/operations/modifiers/generalize.test.js +6 -0
- package/src/operations/modifiers/snap.test.js +3 -3
- package/src/operations/transforms/align.d.ts +1 -1
- package/src/operations/transforms/align.test.js +12 -0
- package/src/operations/transforms/center.js +17 -17
- package/src/operations/transforms/center.test.js +12 -0
- package/src/operations/transforms/mirror.js +12 -12
- package/src/operations/transforms/mirror.test.js +16 -0
- package/src/operations/transforms/rotate.js +12 -12
- package/src/operations/transforms/rotate.test.js +10 -0
- package/src/operations/transforms/scale.js +19 -19
- package/src/operations/transforms/scale.test.js +15 -0
- package/src/operations/transforms/transform.js +3 -3
- package/src/operations/transforms/transform.test.js +5 -0
- package/src/operations/transforms/translate.js +14 -14
- package/src/operations/transforms/translate.test.js +16 -0
- package/src/primitives/arc.js +1 -1
- package/src/primitives/arc.test.js +11 -0
- package/src/primitives/circle.test.js +15 -9
- package/src/primitives/cube.test.js +3 -0
- package/src/primitives/cuboid.test.js +9 -24
- package/src/primitives/cylinder.test.js +7 -4
- package/src/primitives/cylinderElliptic.js +13 -6
- package/src/primitives/cylinderElliptic.test.js +72 -52
- package/src/primitives/ellipse.js +3 -1
- package/src/primitives/ellipse.test.js +14 -8
- package/src/primitives/ellipsoid.js +7 -5
- package/src/primitives/ellipsoid.test.js +84 -82
- package/src/primitives/geodesicSphere.d.ts +0 -1
- package/src/primitives/geodesicSphere.test.js +3 -0
- package/src/primitives/line.test.js +1 -0
- package/src/primitives/polygon.test.js +15 -10
- package/src/primitives/polyhedron.js +1 -1
- package/src/primitives/polyhedron.test.js +14 -42
- package/src/primitives/rectangle.test.js +3 -0
- package/src/primitives/roundedCuboid.test.js +5 -0
- package/src/primitives/roundedCylinder.js +6 -4
- package/src/primitives/roundedCylinder.test.js +40 -36
- package/src/primitives/roundedRectangle.test.js +5 -0
- package/src/primitives/sphere.test.js +52 -73
- package/src/primitives/square.test.js +3 -0
- package/src/primitives/star.test.js +6 -0
- package/src/primitives/torus.d.ts +0 -1
- package/src/primitives/torus.test.js +8 -1
- package/src/primitives/triangle.js +1 -1
- package/src/primitives/triangle.test.js +7 -0
- package/src/text/vectorText.js +2 -2
- package/src/utils/areAllShapesTheSameType.js +2 -2
- package/src/utils/areAllShapesTheSameType.test.js +17 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +3 -1
- package/src/utils/padArrayToLength.js +1 -1
- package/src/utils/trigonometry.d.ts +2 -0
- package/src/utils/trigonometry.js +35 -0
- package/src/utils/trigonometry.test.js +25 -0
- package/test/helpers/nearlyEqual.js +4 -1
|
@@ -24,18 +24,18 @@ const centerGeometry = (options, object) => {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Center the given
|
|
27
|
+
* Center the given objects using the given options.
|
|
28
28
|
* @param {Object} options - options for centering
|
|
29
29
|
* @param {Array} [options.axes=[true,true,true]] - axis of which to center, true or false
|
|
30
|
-
* @param {Array} [options.relativeTo=[0,0,0]] - relative point of which to center the
|
|
31
|
-
* @param {...Object}
|
|
32
|
-
* @return {Object|Array} the centered
|
|
30
|
+
* @param {Array} [options.relativeTo=[0,0,0]] - relative point of which to center the objects
|
|
31
|
+
* @param {...Object} objects - the objects to center
|
|
32
|
+
* @return {Object|Array} the centered object, or a list of centered objects
|
|
33
33
|
* @alias module:modeling/transforms.center
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* let myshape = center({axes: [true,false,false]}, sphere()) // center about the X axis
|
|
37
37
|
*/
|
|
38
|
-
const center = (options, ...
|
|
38
|
+
const center = (options, ...objects) => {
|
|
39
39
|
const defaults = {
|
|
40
40
|
axes: [true, true, true],
|
|
41
41
|
relativeTo: [0, 0, 0]
|
|
@@ -43,13 +43,13 @@ const center = (options, ...geometries) => {
|
|
|
43
43
|
}
|
|
44
44
|
const { axes, relativeTo } = Object.assign({}, defaults, options)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
if (
|
|
46
|
+
objects = flatten(objects)
|
|
47
|
+
if (objects.length === 0) throw new Error('wrong number of arguments')
|
|
48
48
|
if (relativeTo.length !== 3) throw new Error('relativeTo must be an array of length 3')
|
|
49
49
|
|
|
50
50
|
options = { axes, relativeTo }
|
|
51
51
|
|
|
52
|
-
const results =
|
|
52
|
+
const results = objects.map((object) => {
|
|
53
53
|
if (path2.isA(object)) return centerGeometry(options, object)
|
|
54
54
|
if (geom2.isA(object)) return centerGeometry(options, object)
|
|
55
55
|
if (geom3.isA(object)) return centerGeometry(options, object)
|
|
@@ -59,25 +59,25 @@ const center = (options, ...geometries) => {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Center the given
|
|
63
|
-
* @param {...Object}
|
|
64
|
-
* @return {Object|Array} the centered
|
|
62
|
+
* Center the given objects about the X axis.
|
|
63
|
+
* @param {...Object} objects - the objects to center
|
|
64
|
+
* @return {Object|Array} the centered object, or a list of centered objects
|
|
65
65
|
* @alias module:modeling/transforms.centerX
|
|
66
66
|
*/
|
|
67
67
|
const centerX = (...objects) => center({ axes: [true, false, false] }, objects)
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Center the given
|
|
71
|
-
* @param {...Object}
|
|
72
|
-
* @return {Object|Array} the centered
|
|
70
|
+
* Center the given objects about the Y axis.
|
|
71
|
+
* @param {...Object} objects - the objects to center
|
|
72
|
+
* @return {Object|Array} the centered object, or a list of centered objects
|
|
73
73
|
* @alias module:modeling/transforms.centerY
|
|
74
74
|
*/
|
|
75
75
|
const centerY = (...objects) => center({ axes: [false, true, false] }, objects)
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* Center the given
|
|
79
|
-
* @param {...Object}
|
|
80
|
-
* @return {Object|Array} the centered
|
|
78
|
+
* Center the given objects about the Z axis.
|
|
79
|
+
* @param {...Object} objects - the objects to center
|
|
80
|
+
* @return {Object|Array} the centered object, or a list of centered objects
|
|
81
81
|
* @alias module:modeling/transforms.centerZ
|
|
82
82
|
*/
|
|
83
83
|
const centerZ = (...objects) => center({ axes: [false, false, true] }, objects)
|
|
@@ -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
|
})
|
|
@@ -8,12 +8,12 @@ const geom3 = require('../../geometries/geom3')
|
|
|
8
8
|
const path2 = require('../../geometries/path2')
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Mirror the given
|
|
11
|
+
* Mirror the given objects using the given options.
|
|
12
12
|
* @param {Object} options - options for mirror
|
|
13
13
|
* @param {Array} [options.origin=[0,0,0]] - the origin of the plane
|
|
14
14
|
* @param {Array} [options.normal=[0,0,1]] - the normal vector of the plane
|
|
15
|
-
* @param {...Object}
|
|
16
|
-
* @return {Object|Array} the mirrored
|
|
15
|
+
* @param {...Object} objects - the objects to mirror
|
|
16
|
+
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
17
17
|
* @alias module:modeling/transforms.mirror
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
@@ -47,25 +47,25 @@ const mirror = (options, ...objects) => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Mirror the given
|
|
51
|
-
* @param {...Object}
|
|
52
|
-
* @return {Object|Array} the mirrored
|
|
50
|
+
* Mirror the given objects about the X axis.
|
|
51
|
+
* @param {...Object} objects - the objects to mirror
|
|
52
|
+
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
53
53
|
* @alias module:modeling/transforms.mirrorX
|
|
54
54
|
*/
|
|
55
55
|
const mirrorX = (...objects) => mirror({ normal: [1, 0, 0] }, objects)
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Mirror the given
|
|
59
|
-
* @param {...Object}
|
|
60
|
-
* @return {Object|Array} the mirrored
|
|
58
|
+
* Mirror the given objects about the Y axis.
|
|
59
|
+
* @param {...Object} objects - the geometries to mirror
|
|
60
|
+
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
61
61
|
* @alias module:modeling/transforms.mirrorY
|
|
62
62
|
*/
|
|
63
63
|
const mirrorY = (...objects) => mirror({ normal: [0, 1, 0] }, objects)
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* Mirror the given
|
|
67
|
-
* @param {...Object}
|
|
68
|
-
* @return {Object|Array} the mirrored
|
|
66
|
+
* Mirror the given objects about the Z axis.
|
|
67
|
+
* @param {...Object} objects - the geometries to mirror
|
|
68
|
+
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
69
69
|
* @alias module:modeling/transforms.mirrorZ
|
|
70
70
|
*/
|
|
71
71
|
const mirrorZ = (...objects) => mirror({ normal: [0, 0, 1] }, objects)
|
|
@@ -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
|
})
|
|
@@ -7,10 +7,10 @@ const geom3 = require('../../geometries/geom3')
|
|
|
7
7
|
const path2 = require('../../geometries/path2')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Rotate the given
|
|
10
|
+
* Rotate the given objects using the given options.
|
|
11
11
|
* @param {Array} angles - angle (RADIANS) of rotations about X, Y, and Z axis
|
|
12
|
-
* @param {...Object}
|
|
13
|
-
* @return {Object|Array} the rotated
|
|
12
|
+
* @param {...Object} objects - the objects to rotate
|
|
13
|
+
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
14
14
|
* @alias module:modeling/transforms.rotate
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -42,28 +42,28 @@ const rotate = (angles, ...objects) => {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Rotate the given
|
|
45
|
+
* Rotate the given objects about the X axis, using the given options.
|
|
46
46
|
* @param {Number} angle - angle (RADIANS) of rotations about X
|
|
47
|
-
* @param {...Object}
|
|
48
|
-
* @return {Object|Array} the rotated
|
|
47
|
+
* @param {...Object} objects - the objects to rotate
|
|
48
|
+
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
49
49
|
* @alias module:modeling/transforms.rotateX
|
|
50
50
|
*/
|
|
51
51
|
const rotateX = (angle, ...objects) => rotate([angle, 0, 0], objects)
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Rotate the given
|
|
54
|
+
* Rotate the given objects about the Y axis, using the given options.
|
|
55
55
|
* @param {Number} angle - angle (RADIANS) of rotations about Y
|
|
56
|
-
* @param {...Object}
|
|
57
|
-
* @return {Object|Array} the rotated
|
|
56
|
+
* @param {...Object} objects - the objects to rotate
|
|
57
|
+
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
58
58
|
* @alias module:modeling/transforms.rotateY
|
|
59
59
|
*/
|
|
60
60
|
const rotateY = (angle, ...objects) => rotate([0, angle, 0], objects)
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Rotate the given
|
|
63
|
+
* Rotate the given objects about the Z axis, using the given options.
|
|
64
64
|
* @param {Number} angle - angle (RADIANS) of rotations about Z
|
|
65
|
-
* @param {...Object}
|
|
66
|
-
* @return {Object|Array} the rotated
|
|
65
|
+
* @param {...Object} objects - the objects to rotate
|
|
66
|
+
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
67
67
|
* @alias module:modeling/transforms.rotateZ
|
|
68
68
|
*/
|
|
69
69
|
const rotateZ = (angle, ...objects) => rotate([0, 0, angle], objects)
|
|
@@ -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
|
})
|
|
@@ -7,10 +7,10 @@ const geom3 = require('../../geometries/geom3')
|
|
|
7
7
|
const path2 = require('../../geometries/path2')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Scale the given
|
|
11
|
-
* @param {Array} factors - X, Y, Z factors by which to scale the
|
|
12
|
-
* @param {...Object}
|
|
13
|
-
* @return {Object|Array} the scaled
|
|
10
|
+
* Scale the given objects using the given options.
|
|
11
|
+
* @param {Array} factors - X, Y, Z factors by which to scale the objects
|
|
12
|
+
* @param {...Object} objects - the objects to scale
|
|
13
|
+
* @return {Object|Array} the scaled object, or a list of scaled objects
|
|
14
14
|
* @alias module:modeling/transforms.scale
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -40,31 +40,31 @@ const scale = (factors, ...objects) => {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Scale the given
|
|
44
|
-
* @param {Number} factor - X factor by which to scale the
|
|
45
|
-
* @param {...Object}
|
|
46
|
-
* @return {Object|Array} the scaled
|
|
43
|
+
* Scale the given objects about the X axis using the given options.
|
|
44
|
+
* @param {Number} factor - X factor by which to scale the objects
|
|
45
|
+
* @param {...Object} objects - the objects to scale
|
|
46
|
+
* @return {Object|Array} the scaled object, or a list of scaled objects
|
|
47
47
|
* @alias module:modeling/transforms.scaleX
|
|
48
48
|
*/
|
|
49
|
-
const scaleX = (
|
|
49
|
+
const scaleX = (factor, ...objects) => scale([factor, 1, 1], objects)
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Scale the given
|
|
53
|
-
* @param {Number} factor - Y factor by which to scale the
|
|
54
|
-
* @param {...Object}
|
|
55
|
-
* @return {Object|Array} the scaled
|
|
52
|
+
* Scale the given objects about the Y axis using the given options.
|
|
53
|
+
* @param {Number} factor - Y factor by which to scale the objects
|
|
54
|
+
* @param {...Object} objects - the objects to scale
|
|
55
|
+
* @return {Object|Array} the scaled object, or a list of scaled objects
|
|
56
56
|
* @alias module:modeling/transforms.scaleY
|
|
57
57
|
*/
|
|
58
|
-
const scaleY = (
|
|
58
|
+
const scaleY = (factor, ...objects) => scale([1, factor, 1], objects)
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Scale the given
|
|
62
|
-
* @param {Number} factor - Z factor by which to scale the
|
|
63
|
-
* @param {...Object}
|
|
64
|
-
* @return {Object|Array} the scaled
|
|
61
|
+
* Scale the given objects about the Z axis using the given options.
|
|
62
|
+
* @param {Number} factor - Z factor by which to scale the objects
|
|
63
|
+
* @param {...Object} objects - the objects to scale
|
|
64
|
+
* @return {Object|Array} the scaled object, or a list of scaled objects
|
|
65
65
|
* @alias module:modeling/transforms.scaleZ
|
|
66
66
|
*/
|
|
67
|
-
const scaleZ = (
|
|
67
|
+
const scaleZ = (factor, ...objects) => scale([1, 1, factor], objects)
|
|
68
68
|
|
|
69
69
|
module.exports = {
|
|
70
70
|
scale,
|
|
@@ -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
|
})
|
|
@@ -5,10 +5,10 @@ const geom3 = require('../../geometries/geom3')
|
|
|
5
5
|
const path2 = require('../../geometries/path2')
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Transform the given
|
|
8
|
+
* Transform the given objects using the given matrix.
|
|
9
9
|
* @param {mat4} matrix - a transformation matrix
|
|
10
|
-
* @param {...Object}
|
|
11
|
-
* @return {Object|Array} the transformed
|
|
10
|
+
* @param {...Object} objects - the objects to transform
|
|
11
|
+
* @return {Object|Array} the transformed object, or a list of transformed objects
|
|
12
12
|
* @alias module:modeling/transforms.transform
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
@@ -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
|
})
|