@jbroll/jscad-modeling 2.12.7
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/.claude/settings.local.json +30 -0
- package/CHANGELOG.md +888 -0
- package/CLAUDE.md +135 -0
- package/README.md +99 -0
- package/benchmarks/booleans.bench.js +100 -0
- package/benchmarks/extrusions.bench.js +124 -0
- package/benchmarks/measurements.bench.js +123 -0
- package/benchmarks/run.js +145 -0
- package/benchmarks/transforms.bench.js +106 -0
- package/benchmarks/utils.bench.js +89 -0
- package/dist/jscad-modeling.min.js +1214 -0
- package/package.json +66 -0
- package/src/colors/colorNameToRgb.d.ts +5 -0
- package/src/colors/colorNameToRgb.js +14 -0
- package/src/colors/colorNameToRgb.test.js +14 -0
- package/src/colors/colorize.d.ts +14 -0
- package/src/colors/colorize.js +65 -0
- package/src/colors/colorize.test.js +72 -0
- package/src/colors/cssColors.d.ts +149 -0
- package/src/colors/cssColors.js +176 -0
- package/src/colors/hexToRgb.d.ts +5 -0
- package/src/colors/hexToRgb.js +26 -0
- package/src/colors/hexToRgb.test.js +37 -0
- package/src/colors/hslToRgb.d.ts +8 -0
- package/src/colors/hslToRgb.js +44 -0
- package/src/colors/hslToRgb.test.js +37 -0
- package/src/colors/hsvToRgb.d.ts +8 -0
- package/src/colors/hsvToRgb.js +73 -0
- package/src/colors/hsvToRgb.test.js +27 -0
- package/src/colors/hueToColorComponent.d.ts +3 -0
- package/src/colors/hueToColorComponent.js +18 -0
- package/src/colors/index.d.ts +13 -0
- package/src/colors/index.js +19 -0
- package/src/colors/rgbToHex.d.ts +6 -0
- package/src/colors/rgbToHex.js +27 -0
- package/src/colors/rgbToHex.test.js +15 -0
- package/src/colors/rgbToHsl.d.ts +8 -0
- package/src/colors/rgbToHsl.js +53 -0
- package/src/colors/rgbToHsl.test.js +35 -0
- package/src/colors/rgbToHsv.d.ts +8 -0
- package/src/colors/rgbToHsv.js +52 -0
- package/src/colors/rgbToHsv.test.js +40 -0
- package/src/colors/types.d.ts +6 -0
- package/src/connectors/create.js +23 -0
- package/src/connectors/create.test.js +17 -0
- package/src/connectors/extends.js +15 -0
- package/src/connectors/fromPointAxisNormal.js +21 -0
- package/src/connectors/fromPointAxisNormal.test.js +22 -0
- package/src/connectors/index.js +12 -0
- package/src/connectors/normalize.js +20 -0
- package/src/connectors/toString.js +15 -0
- package/src/connectors/transform.js +28 -0
- package/src/connectors/transform.test.js +106 -0
- package/src/connectors/transformationBetween.js +68 -0
- package/src/connectors/transformationBetween.test.js +40 -0
- package/src/curves/bezier/arcLengthToT.d.ts +10 -0
- package/src/curves/bezier/arcLengthToT.js +63 -0
- package/src/curves/bezier/arcLengthToT.test.js +79 -0
- package/src/curves/bezier/create.d.ts +5 -0
- package/src/curves/bezier/create.js +81 -0
- package/src/curves/bezier/create.test.js +60 -0
- package/src/curves/bezier/index.d.ts +9 -0
- package/src/curves/bezier/index.js +13 -0
- package/src/curves/bezier/length.d.ts +5 -0
- package/src/curves/bezier/length.js +18 -0
- package/src/curves/bezier/length.test.js +54 -0
- package/src/curves/bezier/lengths.d.ts +5 -0
- package/src/curves/bezier/lengths.js +56 -0
- package/src/curves/bezier/lengths.test.js +78 -0
- package/src/curves/bezier/tangentAt.d.ts +5 -0
- package/src/curves/bezier/tangentAt.js +45 -0
- package/src/curves/bezier/tangentAt.test.js +63 -0
- package/src/curves/bezier/type.d.ts +9 -0
- package/src/curves/bezier/valueAt.d.ts +5 -0
- package/src/curves/bezier/valueAt.js +44 -0
- package/src/curves/bezier/valueAt.test.js +63 -0
- package/src/curves/index.d.ts +3 -0
- package/src/curves/index.js +9 -0
- package/src/geometries/geom2/applyTransforms.js +26 -0
- package/src/geometries/geom2/applyTransforms.test.js +21 -0
- package/src/geometries/geom2/clone.d.ts +5 -0
- package/src/geometries/geom2/clone.js +9 -0
- package/src/geometries/geom2/clone.test.js +26 -0
- package/src/geometries/geom2/create.d.ts +6 -0
- package/src/geometries/geom2/create.js +26 -0
- package/src/geometries/geom2/create.test.js +20 -0
- package/src/geometries/geom2/fromCompactBinary.d.ts +5 -0
- package/src/geometries/geom2/fromCompactBinary.js +32 -0
- package/src/geometries/geom2/fromPoints.d.ts +6 -0
- package/src/geometries/geom2/fromPoints.js +35 -0
- package/src/geometries/geom2/fromPoints.test.js +22 -0
- package/src/geometries/geom2/fromToCompactBinary.test.js +122 -0
- package/src/geometries/geom2/index.d.ts +16 -0
- package/src/geometries/geom2/index.js +30 -0
- package/src/geometries/geom2/isA.d.ts +5 -0
- package/src/geometries/geom2/isA.js +18 -0
- package/src/geometries/geom2/isA.test.js +19 -0
- package/src/geometries/geom2/reverse.d.ts +5 -0
- package/src/geometries/geom2/reverse.js +22 -0
- package/src/geometries/geom2/reverse.test.js +20 -0
- package/src/geometries/geom2/toCompactBinary.d.ts +5 -0
- package/src/geometries/geom2/toCompactBinary.js +53 -0
- package/src/geometries/geom2/toOutlines.d.ts +6 -0
- package/src/geometries/geom2/toOutlines.js +119 -0
- package/src/geometries/geom2/toOutlines.test.js +122 -0
- package/src/geometries/geom2/toPoints.d.ts +6 -0
- package/src/geometries/geom2/toPoints.js +25 -0
- package/src/geometries/geom2/toPoints.test.js +24 -0
- package/src/geometries/geom2/toSides.d.ts +6 -0
- package/src/geometries/geom2/toSides.js +16 -0
- package/src/geometries/geom2/toString.d.ts +5 -0
- package/src/geometries/geom2/toString.js +24 -0
- package/src/geometries/geom2/transform.d.ts +6 -0
- package/src/geometries/geom2/transform.js +28 -0
- package/src/geometries/geom2/transform.test.js +110 -0
- package/src/geometries/geom2/type.d.ts +11 -0
- package/src/geometries/geom2/validate.d.ts +3 -0
- package/src/geometries/geom2/validate.js +36 -0
- package/src/geometries/geom3/applyTransforms.js +23 -0
- package/src/geometries/geom3/applyTransforms.test.js +28 -0
- package/src/geometries/geom3/clone.d.ts +5 -0
- package/src/geometries/geom3/clone.js +9 -0
- package/src/geometries/geom3/clone.test.js +31 -0
- package/src/geometries/geom3/create.d.ts +6 -0
- package/src/geometries/geom3/create.js +26 -0
- package/src/geometries/geom3/create.test.js +25 -0
- package/src/geometries/geom3/fromCompactBinary.d.ts +5 -0
- package/src/geometries/geom3/fromCompactBinary.js +44 -0
- package/src/geometries/geom3/fromPoints.d.ts +6 -0
- package/src/geometries/geom3/fromPoints.js +28 -0
- package/src/geometries/geom3/fromPoints.test.js +24 -0
- package/src/geometries/geom3/fromPointsConvex.d.ts +6 -0
- package/src/geometries/geom3/fromPointsConvex.js +26 -0
- package/src/geometries/geom3/fromPointsConvex.test.js +31 -0
- package/src/geometries/geom3/fromToCompactBinary.test.js +139 -0
- package/src/geometries/geom3/index.d.ts +16 -0
- package/src/geometries/geom3/index.js +37 -0
- package/src/geometries/geom3/invert.d.ts +5 -0
- package/src/geometries/geom3/invert.js +18 -0
- package/src/geometries/geom3/invert.test.js +31 -0
- package/src/geometries/geom3/isA.d.ts +5 -0
- package/src/geometries/geom3/isA.js +18 -0
- package/src/geometries/geom3/isA.test.js +19 -0
- package/src/geometries/geom3/toCompactBinary.d.ts +5 -0
- package/src/geometries/geom3/toCompactBinary.js +68 -0
- package/src/geometries/geom3/toPoints.d.ts +6 -0
- package/src/geometries/geom3/toPoints.js +18 -0
- package/src/geometries/geom3/toPoints.test.js +19 -0
- package/src/geometries/geom3/toPolygons.d.ts +6 -0
- package/src/geometries/geom3/toPolygons.js +15 -0
- package/src/geometries/geom3/toString.d.ts +5 -0
- package/src/geometries/geom3/toString.js +23 -0
- package/src/geometries/geom3/transform.d.ts +6 -0
- package/src/geometries/geom3/transform.js +20 -0
- package/src/geometries/geom3/transform.test.js +49 -0
- package/src/geometries/geom3/type.d.ts +11 -0
- package/src/geometries/geom3/validate.d.ts +3 -0
- package/src/geometries/geom3/validate.js +62 -0
- package/src/geometries/index.d.ts +7 -0
- package/src/geometries/index.js +21 -0
- package/src/geometries/path2/appendArc.d.ts +15 -0
- package/src/geometries/path2/appendArc.js +142 -0
- package/src/geometries/path2/appendArc.test.js +88 -0
- package/src/geometries/path2/appendBezier.d.ts +11 -0
- package/src/geometries/path2/appendBezier.js +156 -0
- package/src/geometries/path2/appendBezier.test.js +36 -0
- package/src/geometries/path2/appendPoints.d.ts +6 -0
- package/src/geometries/path2/appendPoints.js +15 -0
- package/src/geometries/path2/appendPoints.test.js +35 -0
- package/src/geometries/path2/applyTransforms.js +20 -0
- package/src/geometries/path2/applyTransforms.test.js +28 -0
- package/src/geometries/path2/clone.d.ts +5 -0
- package/src/geometries/path2/clone.js +9 -0
- package/src/geometries/path2/close.d.ts +5 -0
- package/src/geometries/path2/close.js +33 -0
- package/src/geometries/path2/close.test.js +43 -0
- package/src/geometries/path2/concat.d.ts +5 -0
- package/src/geometries/path2/concat.js +36 -0
- package/src/geometries/path2/concat.test.js +35 -0
- package/src/geometries/path2/create.d.ts +6 -0
- package/src/geometries/path2/create.js +30 -0
- package/src/geometries/path2/create.test.js +7 -0
- package/src/geometries/path2/equals.d.ts +5 -0
- package/src/geometries/path2/equals.js +47 -0
- package/src/geometries/path2/equals.test.js +38 -0
- package/src/geometries/path2/fromCompactBinary.d.ts +5 -0
- package/src/geometries/path2/fromCompactBinary.js +33 -0
- package/src/geometries/path2/fromPoints.d.ts +10 -0
- package/src/geometries/path2/fromPoints.js +42 -0
- package/src/geometries/path2/fromPoints.test.js +33 -0
- package/src/geometries/path2/fromToCompactBinary.test.js +114 -0
- package/src/geometries/path2/index.d.ts +20 -0
- package/src/geometries/path2/index.js +35 -0
- package/src/geometries/path2/isA.d.ts +5 -0
- package/src/geometries/path2/isA.js +20 -0
- package/src/geometries/path2/isA.test.js +19 -0
- package/src/geometries/path2/reverse.d.ts +5 -0
- package/src/geometries/path2/reverse.js +20 -0
- package/src/geometries/path2/reverse.test.js +9 -0
- package/src/geometries/path2/toCompactBinary.d.ts +5 -0
- package/src/geometries/path2/toCompactBinary.js +52 -0
- package/src/geometries/path2/toPoints.d.ts +6 -0
- package/src/geometries/path2/toPoints.js +15 -0
- package/src/geometries/path2/toPoints.test.js +13 -0
- package/src/geometries/path2/toString.d.ts +5 -0
- package/src/geometries/path2/toString.js +24 -0
- package/src/geometries/path2/transform.d.ts +6 -0
- package/src/geometries/path2/transform.js +20 -0
- package/src/geometries/path2/transform.test.js +50 -0
- package/src/geometries/path2/type.d.ts +12 -0
- package/src/geometries/path2/validate.d.ts +3 -0
- package/src/geometries/path2/validate.js +41 -0
- package/src/geometries/poly2/arePointsInside.d.ts +6 -0
- package/src/geometries/poly2/arePointsInside.js +83 -0
- package/src/geometries/poly2/arePointsInside.test.js +77 -0
- package/src/geometries/poly2/create.d.ts +6 -0
- package/src/geometries/poly2/create.js +24 -0
- package/src/geometries/poly2/create.test.js +13 -0
- package/src/geometries/poly2/flip.d.ts +5 -0
- package/src/geometries/poly2/flip.js +15 -0
- package/src/geometries/poly2/index.d.ts +7 -0
- package/src/geometries/poly2/index.js +17 -0
- package/src/geometries/poly2/measureArea.d.ts +5 -0
- package/src/geometries/poly2/measureArea.js +12 -0
- package/src/geometries/poly2/measureArea.test.js +44 -0
- package/src/geometries/poly2/type.d.ts +7 -0
- package/src/geometries/poly3/clone.d.ts +6 -0
- package/src/geometries/poly3/clone.js +28 -0
- package/src/geometries/poly3/clone.test.js +35 -0
- package/src/geometries/poly3/create.d.ts +6 -0
- package/src/geometries/poly3/create.js +24 -0
- package/src/geometries/poly3/create.test.js +9 -0
- package/src/geometries/poly3/fromPoints.d.ts +6 -0
- package/src/geometries/poly3/fromPoints.js +25 -0
- package/src/geometries/poly3/fromPoints.test.js +15 -0
- package/src/geometries/poly3/fromPointsAndPlane.d.ts +7 -0
- package/src/geometries/poly3/fromPointsAndPlane.js +17 -0
- package/src/geometries/poly3/index.d.ts +19 -0
- package/src/geometries/poly3/index.js +29 -0
- package/src/geometries/poly3/invert.d.ts +5 -0
- package/src/geometries/poly3/invert.js +21 -0
- package/src/geometries/poly3/invert.test.js +18 -0
- package/src/geometries/poly3/isA.d.ts +5 -0
- package/src/geometries/poly3/isA.js +18 -0
- package/src/geometries/poly3/isA.test.js +19 -0
- package/src/geometries/poly3/isConvex.d.ts +5 -0
- package/src/geometries/poly3/isConvex.js +44 -0
- package/src/geometries/poly3/isConvex.test.js +24 -0
- package/src/geometries/poly3/measureArea.d.ts +5 -0
- package/src/geometries/poly3/measureArea.js +83 -0
- package/src/geometries/poly3/measureArea.test.js +111 -0
- package/src/geometries/poly3/measureBoundingBox.d.ts +6 -0
- package/src/geometries/poly3/measureBoundingBox.js +20 -0
- package/src/geometries/poly3/measureBoundingBox.test.js +70 -0
- package/src/geometries/poly3/measureBoundingSphere.d.ts +6 -0
- package/src/geometries/poly3/measureBoundingSphere.js +56 -0
- package/src/geometries/poly3/measureBoundingSphere.test.js +60 -0
- package/src/geometries/poly3/measureSignedVolume.d.ts +5 -0
- package/src/geometries/poly3/measureSignedVolume.js +25 -0
- package/src/geometries/poly3/measureSignedVolume.test.js +68 -0
- package/src/geometries/poly3/plane.d.ts +6 -0
- package/src/geometries/poly3/plane.js +10 -0
- package/src/geometries/poly3/toPoints.d.ts +6 -0
- package/src/geometries/poly3/toPoints.js +10 -0
- package/src/geometries/poly3/toString.d.ts +5 -0
- package/src/geometries/poly3/toString.js +17 -0
- package/src/geometries/poly3/transform.d.ts +6 -0
- package/src/geometries/poly3/transform.js +22 -0
- package/src/geometries/poly3/transform.test.js +62 -0
- package/src/geometries/poly3/type.d.ts +11 -0
- package/src/geometries/poly3/validate.d.ts +4 -0
- package/src/geometries/poly3/validate.js +64 -0
- package/src/geometries/types.d.ts +21 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +17 -0
- package/src/index.test-d.ts +26 -0
- package/src/maths/OrthoNormalBasis.js +59 -0
- package/src/maths/constants.d.ts +3 -0
- package/src/maths/constants.js +41 -0
- package/src/maths/index.d.ts +11 -0
- package/src/maths/index.js +19 -0
- package/src/maths/line2/clone.d.ts +5 -0
- package/src/maths/line2/clone.js +18 -0
- package/src/maths/line2/clone.test.js +21 -0
- package/src/maths/line2/closestPoint.d.ts +6 -0
- package/src/maths/line2/closestPoint.js +25 -0
- package/src/maths/line2/closestPoint.test.js +48 -0
- package/src/maths/line2/copy.d.ts +5 -0
- package/src/maths/line2/copy.js +16 -0
- package/src/maths/line2/copy.test.js +27 -0
- package/src/maths/line2/create.d.ts +5 -0
- package/src/maths/line2/create.js +20 -0
- package/src/maths/line2/create.test.js +10 -0
- package/src/maths/line2/direction.d.ts +6 -0
- package/src/maths/line2/direction.js +16 -0
- package/src/maths/line2/direction.test.js +31 -0
- package/src/maths/line2/distanceToPoint.d.ts +6 -0
- package/src/maths/line2/distanceToPoint.js +17 -0
- package/src/maths/line2/distanceToPoint.test.js +31 -0
- package/src/maths/line2/equals.d.ts +5 -0
- package/src/maths/line2/equals.js +11 -0
- package/src/maths/line2/equals.test.js +26 -0
- package/src/maths/line2/fromPoints.d.ts +6 -0
- package/src/maths/line2/fromPoints.js +26 -0
- package/src/maths/line2/fromPoints.test.js +24 -0
- package/src/maths/line2/fromValues.d.ts +5 -0
- package/src/maths/line2/fromValues.js +20 -0
- package/src/maths/line2/fromValues.test.js +12 -0
- package/src/maths/line2/index.d.ts +18 -0
- package/src/maths/line2/index.js +22 -0
- package/src/maths/line2/intersectPointOfLines.d.ts +6 -0
- package/src/maths/line2/intersectPointOfLines.js +21 -0
- package/src/maths/line2/intersectPointOfLines.test.js +31 -0
- package/src/maths/line2/origin.d.ts +6 -0
- package/src/maths/line2/origin.js +13 -0
- package/src/maths/line2/origin.test.js +30 -0
- package/src/maths/line2/reverse.d.ts +5 -0
- package/src/maths/line2/reverse.js +20 -0
- package/src/maths/line2/reverse.test.js +36 -0
- package/src/maths/line2/toString.d.ts +5 -0
- package/src/maths/line2/toString.js +10 -0
- package/src/maths/line2/transform.d.ts +6 -0
- package/src/maths/line2/transform.js +26 -0
- package/src/maths/line2/transform.test.js +89 -0
- package/src/maths/line2/type.d.ts +3 -0
- package/src/maths/line2/xAtY.d.ts +5 -0
- package/src/maths/line2/xAtY.js +22 -0
- package/src/maths/line2/xAtY.test.js +39 -0
- package/src/maths/line3/clone.d.ts +5 -0
- package/src/maths/line3/clone.js +19 -0
- package/src/maths/line3/clone.test.js +24 -0
- package/src/maths/line3/closestPoint.d.ts +6 -0
- package/src/maths/line3/closestPoint.js +24 -0
- package/src/maths/line3/closestPoint.test.js +37 -0
- package/src/maths/line3/copy.d.ts +5 -0
- package/src/maths/line3/copy.js +17 -0
- package/src/maths/line3/copy.test.js +33 -0
- package/src/maths/line3/create.d.ts +5 -0
- package/src/maths/line3/create.js +23 -0
- package/src/maths/line3/create.test.js +11 -0
- package/src/maths/line3/direction.d.ts +6 -0
- package/src/maths/line3/direction.js +10 -0
- package/src/maths/line3/direction.test.js +26 -0
- package/src/maths/line3/distanceToPoint.d.ts +6 -0
- package/src/maths/line3/distanceToPoint.js +19 -0
- package/src/maths/line3/distanceToPoint.test.js +31 -0
- package/src/maths/line3/equals.d.ts +5 -0
- package/src/maths/line3/equals.js +25 -0
- package/src/maths/line3/equals.test.js +17 -0
- package/src/maths/line3/fromPlanes.d.ts +6 -0
- package/src/maths/line3/fromPlanes.js +47 -0
- package/src/maths/line3/fromPlanes.test.js +38 -0
- package/src/maths/line3/fromPointAndDirection.d.ts +6 -0
- package/src/maths/line3/fromPointAndDirection.js +25 -0
- package/src/maths/line3/fromPointAndDirection.test.js +37 -0
- package/src/maths/line3/fromPoints.d.ts +6 -0
- package/src/maths/line3/fromPoints.js +19 -0
- package/src/maths/line3/fromPoints.test.js +37 -0
- package/src/maths/line3/index.d.ts +18 -0
- package/src/maths/line3/index.js +22 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +7 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.js +29 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.test.js +29 -0
- package/src/maths/line3/origin.d.ts +6 -0
- package/src/maths/line3/origin.js +10 -0
- package/src/maths/line3/origin.test.js +26 -0
- package/src/maths/line3/reverse.d.ts +5 -0
- package/src/maths/line3/reverse.js +19 -0
- package/src/maths/line3/reverse.test.js +33 -0
- package/src/maths/line3/toString.d.ts +5 -0
- package/src/maths/line3/toString.js +14 -0
- package/src/maths/line3/transform.d.ts +6 -0
- package/src/maths/line3/transform.js +26 -0
- package/src/maths/line3/transform.test.js +66 -0
- package/src/maths/line3/type.d.ts +5 -0
- package/src/maths/mat4/add.d.ts +5 -0
- package/src/maths/mat4/add.js +30 -0
- package/src/maths/mat4/add.test.js +27 -0
- package/src/maths/mat4/clone.d.ts +5 -0
- package/src/maths/mat4/clone.js +31 -0
- package/src/maths/mat4/clone.test.js +21 -0
- package/src/maths/mat4/copy.d.ts +5 -0
- package/src/maths/mat4/copy.js +29 -0
- package/src/maths/mat4/copy.test.js +30 -0
- package/src/maths/mat4/create.d.ts +5 -0
- package/src/maths/mat4/create.js +20 -0
- package/src/maths/mat4/create.test.js +10 -0
- package/src/maths/mat4/equals.d.ts +5 -0
- package/src/maths/mat4/equals.js +16 -0
- package/src/maths/mat4/equals.test.js +56 -0
- package/src/maths/mat4/fromRotation.d.ts +6 -0
- package/src/maths/mat4/fromRotation.js +60 -0
- package/src/maths/mat4/fromRotation.test.js +18 -0
- package/src/maths/mat4/fromScaling.d.ts +6 -0
- package/src/maths/mat4/fromScaling.js +35 -0
- package/src/maths/mat4/fromScaling.test.js +12 -0
- package/src/maths/mat4/fromTaitBryanRotation.d.ts +5 -0
- package/src/maths/mat4/fromTaitBryanRotation.js +55 -0
- package/src/maths/mat4/fromTaitBryanRotation.test.js +24 -0
- package/src/maths/mat4/fromTranslation.d.ts +6 -0
- package/src/maths/mat4/fromTranslation.js +35 -0
- package/src/maths/mat4/fromTranslation.test.js +12 -0
- package/src/maths/mat4/fromValues.d.ts +5 -0
- package/src/maths/mat4/fromValues.js +53 -0
- package/src/maths/mat4/fromValues.test.js +12 -0
- package/src/maths/mat4/fromVectorRotation.d.ts +6 -0
- package/src/maths/mat4/fromVectorRotation.js +49 -0
- package/src/maths/mat4/fromVectorRotation.test.js +127 -0
- package/src/maths/mat4/fromXRotation.d.ts +5 -0
- package/src/maths/mat4/fromXRotation.js +41 -0
- package/src/maths/mat4/fromXRotation.test.js +14 -0
- package/src/maths/mat4/fromYRotation.d.ts +5 -0
- package/src/maths/mat4/fromYRotation.js +41 -0
- package/src/maths/mat4/fromYRotation.test.js +14 -0
- package/src/maths/mat4/fromZRotation.d.ts +5 -0
- package/src/maths/mat4/fromZRotation.js +41 -0
- package/src/maths/mat4/fromZRotation.test.js +14 -0
- package/src/maths/mat4/identity.d.ts +5 -0
- package/src/maths/mat4/identity.js +28 -0
- package/src/maths/mat4/identity.test.js +12 -0
- package/src/maths/mat4/index.d.ts +29 -0
- package/src/maths/mat4/index.js +36 -0
- package/src/maths/mat4/invert.js +71 -0
- package/src/maths/mat4/invert.test.js +32 -0
- package/src/maths/mat4/isIdentity.d.ts +5 -0
- package/src/maths/mat4/isIdentity.js +20 -0
- package/src/maths/mat4/isIdentity.test.js +11 -0
- package/src/maths/mat4/isMirroring.d.ts +5 -0
- package/src/maths/mat4/isMirroring.js +24 -0
- package/src/maths/mat4/isMirroring.test.js +37 -0
- package/src/maths/mat4/isOnlyTransformScale.js +22 -0
- package/src/maths/mat4/isOnlyTransformScale.test.js +29 -0
- package/src/maths/mat4/leftMultiplyVec2.d.ts +6 -0
- package/src/maths/mat4/leftMultiplyVec2.js +28 -0
- package/src/maths/mat4/leftMultiplyVec3.d.ts +6 -0
- package/src/maths/mat4/leftMultiplyVec3.js +29 -0
- package/src/maths/mat4/mirror.d.ts +6 -0
- package/src/maths/mat4/mirror.js +34 -0
- package/src/maths/mat4/mirrorByPlane.d.ts +6 -0
- package/src/maths/mat4/mirrorByPlane.js +32 -0
- package/src/maths/mat4/mirrorByPlane.test.js +28 -0
- package/src/maths/mat4/multiply.d.ts +5 -0
- package/src/maths/mat4/multiply.js +67 -0
- package/src/maths/mat4/multiply.test.js +28 -0
- package/src/maths/mat4/rightMultiplyVec2.d.ts +6 -0
- package/src/maths/mat4/rightMultiplyVec2.js +29 -0
- package/src/maths/mat4/rightMultiplyVec3.d.ts +6 -0
- package/src/maths/mat4/rightMultiplyVec3.js +30 -0
- package/src/maths/mat4/rotate.d.ts +6 -0
- package/src/maths/mat4/rotate.js +82 -0
- package/src/maths/mat4/rotate.test.js +27 -0
- package/src/maths/mat4/rotateX.d.ts +5 -0
- package/src/maths/mat4/rotateX.js +47 -0
- package/src/maths/mat4/rotateX.test.js +21 -0
- package/src/maths/mat4/rotateY.d.ts +5 -0
- package/src/maths/mat4/rotateY.js +47 -0
- package/src/maths/mat4/rotateY.test.js +21 -0
- package/src/maths/mat4/rotateZ.d.ts +5 -0
- package/src/maths/mat4/rotateZ.js +47 -0
- package/src/maths/mat4/rotateZ.test.js +21 -0
- package/src/maths/mat4/scale.d.ts +6 -0
- package/src/maths/mat4/scale.js +34 -0
- package/src/maths/mat4/scale.test.js +21 -0
- package/src/maths/mat4/subtract.d.ts +5 -0
- package/src/maths/mat4/subtract.js +30 -0
- package/src/maths/mat4/subtract.test.js +27 -0
- package/src/maths/mat4/toString.d.ts +5 -0
- package/src/maths/mat4/toString.js +10 -0
- package/src/maths/mat4/translate.d.ts +6 -0
- package/src/maths/mat4/translate.js +51 -0
- package/src/maths/mat4/translate.test.js +72 -0
- package/src/maths/mat4/type.d.ts +8 -0
- package/src/maths/plane/clone.d.ts +5 -0
- package/src/maths/plane/clone.test.js +24 -0
- package/src/maths/plane/copy.d.ts +5 -0
- package/src/maths/plane/copy.test.js +30 -0
- package/src/maths/plane/create.d.ts +5 -0
- package/src/maths/plane/create.test.js +10 -0
- package/src/maths/plane/equals.d.ts +5 -0
- package/src/maths/plane/equals.test.js +17 -0
- package/src/maths/plane/flip.d.ts +5 -0
- package/src/maths/plane/flip.js +17 -0
- package/src/maths/plane/flip.test.js +26 -0
- package/src/maths/plane/fromNoisyPoints.d.ts +6 -0
- package/src/maths/plane/fromNoisyPoints.js +106 -0
- package/src/maths/plane/fromNoisyPoints.test.js +24 -0
- package/src/maths/plane/fromNormalAndPoint.d.ts +6 -0
- package/src/maths/plane/fromNormalAndPoint.js +32 -0
- package/src/maths/plane/fromNormalAndPoint.test.js +12 -0
- package/src/maths/plane/fromPoints.d.ts +6 -0
- package/src/maths/plane/fromPoints.js +47 -0
- package/src/maths/plane/fromPoints.test.js +20 -0
- package/src/maths/plane/fromPointsRandom.d.ts +6 -0
- package/src/maths/plane/fromPointsRandom.js +42 -0
- package/src/maths/plane/fromValues.d.ts +5 -0
- package/src/maths/plane/index.d.ts +17 -0
- package/src/maths/plane/index.js +46 -0
- package/src/maths/plane/projectionOfPoint.d.ts +6 -0
- package/src/maths/plane/projectionOfPoint.js +19 -0
- package/src/maths/plane/projectionOfPoint.test.js +43 -0
- package/src/maths/plane/signedDistanceToPoint.d.ts +6 -0
- package/src/maths/plane/signedDistanceToPoint.js +13 -0
- package/src/maths/plane/signedDistanceToPoint.test.js +20 -0
- package/src/maths/plane/toString.d.ts +5 -0
- package/src/maths/plane/transform.d.ts +6 -0
- package/src/maths/plane/transform.js +40 -0
- package/src/maths/plane/transform.test.js +72 -0
- package/src/maths/plane/type.d.ts +3 -0
- package/src/maths/rotation.test.js +131 -0
- package/src/maths/types.d.ts +8 -0
- package/src/maths/utils/aboutEqualNormals.d.ts +5 -0
- package/src/maths/utils/aboutEqualNormals.js +12 -0
- package/src/maths/utils/area.d.ts +5 -0
- package/src/maths/utils/area.js +17 -0
- package/src/maths/utils/index.d.ts +8 -0
- package/src/maths/utils/index.js +15 -0
- package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +5 -0
- package/src/maths/utils/interpolateBetween2DPointsForY.js +31 -0
- package/src/maths/utils/intersect.d.ts +5 -0
- package/src/maths/utils/intersect.js +40 -0
- package/src/maths/utils/solve2Linear.d.ts +5 -0
- package/src/maths/utils/solve2Linear.js +11 -0
- package/src/maths/utils/trigonometry.d.ts +2 -0
- package/src/maths/utils/trigonometry.js +34 -0
- package/src/maths/utils/trigonometry.test.js +27 -0
- package/src/maths/vec1/type.d.ts +3 -0
- package/src/maths/vec2/abs.d.ts +5 -0
- package/src/maths/vec2/abs.js +15 -0
- package/src/maths/vec2/abs.test.js +24 -0
- package/src/maths/vec2/add.d.ts +5 -0
- package/src/maths/vec2/add.js +16 -0
- package/src/maths/vec2/add.test.js +26 -0
- package/src/maths/vec2/angle.d.ts +3 -0
- package/src/maths/vec2/angle.js +1 -0
- package/src/maths/vec2/angleDegrees.d.ts +5 -0
- package/src/maths/vec2/angleDegrees.js +12 -0
- package/src/maths/vec2/angleDegrees.test.js +24 -0
- package/src/maths/vec2/angleRadians.d.ts +5 -0
- package/src/maths/vec2/angleRadians.js +10 -0
- package/src/maths/vec2/angleRadians.test.js +24 -0
- package/src/maths/vec2/clone.d.ts +5 -0
- package/src/maths/vec2/clone.js +17 -0
- package/src/maths/vec2/clone.test.js +21 -0
- package/src/maths/vec2/copy.d.ts +5 -0
- package/src/maths/vec2/copy.js +15 -0
- package/src/maths/vec2/copy.test.js +30 -0
- package/src/maths/vec2/create.d.ts +5 -0
- package/src/maths/vec2/create.js +15 -0
- package/src/maths/vec2/create.test.js +10 -0
- package/src/maths/vec2/cross.d.ts +6 -0
- package/src/maths/vec2/cross.js +17 -0
- package/src/maths/vec2/cross.test.js +51 -0
- package/src/maths/vec2/distance.d.ts +5 -0
- package/src/maths/vec2/distance.js +15 -0
- package/src/maths/vec2/distance.test.js +30 -0
- package/src/maths/vec2/divide.d.ts +5 -0
- package/src/maths/vec2/divide.js +16 -0
- package/src/maths/vec2/divide.test.js +36 -0
- package/src/maths/vec2/dot.d.ts +5 -0
- package/src/maths/vec2/dot.js +11 -0
- package/src/maths/vec2/dot.test.js +24 -0
- package/src/maths/vec2/equals.d.ts +5 -0
- package/src/maths/vec2/equals.js +11 -0
- package/src/maths/vec2/equals.test.js +17 -0
- package/src/maths/vec2/fromAngleDegrees.d.ts +5 -0
- package/src/maths/vec2/fromAngleDegrees.js +13 -0
- package/src/maths/vec2/fromAngleDegrees.test.js +12 -0
- package/src/maths/vec2/fromAngleRadians.d.ts +5 -0
- package/src/maths/vec2/fromAngleRadians.js +17 -0
- package/src/maths/vec2/fromAngleRadians.test.js +15 -0
- package/src/maths/vec2/fromScalar.d.ts +5 -0
- package/src/maths/vec2/fromScalar.js +15 -0
- package/src/maths/vec2/fromScalar.test.js +12 -0
- package/src/maths/vec2/fromValues.d.ts +5 -0
- package/src/maths/vec2/fromValues.js +18 -0
- package/src/maths/vec2/index.d.ts +36 -0
- package/src/maths/vec2/index.js +39 -0
- package/src/maths/vec2/length.d.ts +5 -0
- package/src/maths/vec2/length.js +10 -0
- package/src/maths/vec2/length.test.js +29 -0
- package/src/maths/vec2/lerp.d.ts +5 -0
- package/src/maths/vec2/lerp.js +19 -0
- package/src/maths/vec2/lerp.test.js +26 -0
- package/src/maths/vec2/max.d.ts +5 -0
- package/src/maths/vec2/max.js +16 -0
- package/src/maths/vec2/max.test.js +31 -0
- package/src/maths/vec2/min.d.ts +5 -0
- package/src/maths/vec2/min.js +16 -0
- package/src/maths/vec2/min.test.js +31 -0
- package/src/maths/vec2/multiply.d.ts +5 -0
- package/src/maths/vec2/multiply.js +16 -0
- package/src/maths/vec2/multiply.test.js +36 -0
- package/src/maths/vec2/negate.d.ts +5 -0
- package/src/maths/vec2/negate.js +15 -0
- package/src/maths/vec2/negate.test.js +26 -0
- package/src/maths/vec2/normal.d.ts +5 -0
- package/src/maths/vec2/normal.js +17 -0
- package/src/maths/vec2/normal.test.js +30 -0
- package/src/maths/vec2/normalize.d.ts +5 -0
- package/src/maths/vec2/normalize.js +23 -0
- package/src/maths/vec2/normalize.test.js +36 -0
- package/src/maths/vec2/rotate.d.ts +5 -0
- package/src/maths/vec2/rotate.js +23 -0
- package/src/maths/vec2/rotate.test.js +31 -0
- package/src/maths/vec2/scale.d.ts +5 -0
- package/src/maths/vec2/scale.js +16 -0
- package/src/maths/vec2/scale.test.js +24 -0
- package/src/maths/vec2/snap.d.ts +5 -0
- package/src/maths/vec2/snap.js +16 -0
- package/src/maths/vec2/snap.test.js +32 -0
- package/src/maths/vec2/squaredDistance.d.ts +5 -0
- package/src/maths/vec2/squaredDistance.js +15 -0
- package/src/maths/vec2/squaredDistance.test.js +30 -0
- package/src/maths/vec2/squaredLength.d.ts +5 -0
- package/src/maths/vec2/squaredLength.js +14 -0
- package/src/maths/vec2/squaredLength.test.js +29 -0
- package/src/maths/vec2/subtract.d.ts +5 -0
- package/src/maths/vec2/subtract.js +16 -0
- package/src/maths/vec2/subtract.test.js +26 -0
- package/src/maths/vec2/toString.d.ts +5 -0
- package/src/maths/vec2/toString.js +10 -0
- package/src/maths/vec2/transform.d.ts +6 -0
- package/src/maths/vec2/transform.js +18 -0
- package/src/maths/vec2/transform.test.js +66 -0
- package/src/maths/vec2/type.d.ts +3 -0
- package/src/maths/vec3/abs.d.ts +5 -0
- package/src/maths/vec3/abs.js +16 -0
- package/src/maths/vec3/abs.test.js +24 -0
- package/src/maths/vec3/add.d.ts +5 -0
- package/src/maths/vec3/add.js +17 -0
- package/src/maths/vec3/add.test.js +26 -0
- package/src/maths/vec3/angle.d.ts +5 -0
- package/src/maths/vec3/angle.js +25 -0
- package/src/maths/vec3/angle.test.js +34 -0
- package/src/maths/vec3/clone.d.ts +5 -0
- package/src/maths/vec3/clone.js +18 -0
- package/src/maths/vec3/clone.test.js +21 -0
- package/src/maths/vec3/copy.d.ts +5 -0
- package/src/maths/vec3/copy.js +16 -0
- package/src/maths/vec3/copy.test.js +27 -0
- package/src/maths/vec3/create.d.ts +5 -0
- package/src/maths/vec3/create.js +15 -0
- package/src/maths/vec3/create.test.js +10 -0
- package/src/maths/vec3/cross.d.ts +5 -0
- package/src/maths/vec3/cross.js +24 -0
- package/src/maths/vec3/cross.test.js +51 -0
- package/src/maths/vec3/distance.d.ts +5 -0
- package/src/maths/vec3/distance.js +16 -0
- package/src/maths/vec3/distance.test.js +46 -0
- package/src/maths/vec3/divide.d.ts +5 -0
- package/src/maths/vec3/divide.js +17 -0
- package/src/maths/vec3/divide.test.js +36 -0
- package/src/maths/vec3/dot.d.ts +5 -0
- package/src/maths/vec3/dot.js +11 -0
- package/src/maths/vec3/dot.test.js +24 -0
- package/src/maths/vec3/equals.d.ts +5 -0
- package/src/maths/vec3/equals.js +11 -0
- package/src/maths/vec3/equals.test.js +17 -0
- package/src/maths/vec3/fromScalar.d.ts +5 -0
- package/src/maths/vec3/fromScalar.js +17 -0
- package/src/maths/vec3/fromScalar.test.js +12 -0
- package/src/maths/vec3/fromValues.d.ts +5 -0
- package/src/maths/vec3/fromValues.js +20 -0
- package/src/maths/vec3/fromValues.test.js +12 -0
- package/src/maths/vec3/fromVec2.d.ts +6 -0
- package/src/maths/vec3/fromVec2.js +17 -0
- package/src/maths/vec3/fromVec2.test.js +13 -0
- package/src/maths/vec3/index.d.ts +35 -0
- package/src/maths/vec3/index.js +39 -0
- package/src/maths/vec3/length.d.ts +5 -0
- package/src/maths/vec3/length.js +15 -0
- package/src/maths/vec3/length.test.js +45 -0
- package/src/maths/vec3/lerp.d.ts +5 -0
- package/src/maths/vec3/lerp.js +18 -0
- package/src/maths/vec3/lerp.test.js +26 -0
- package/src/maths/vec3/max.d.ts +5 -0
- package/src/maths/vec3/max.js +17 -0
- package/src/maths/vec3/max.test.js +31 -0
- package/src/maths/vec3/min.d.ts +5 -0
- package/src/maths/vec3/min.js +17 -0
- package/src/maths/vec3/min.test.js +31 -0
- package/src/maths/vec3/multiply.d.ts +5 -0
- package/src/maths/vec3/multiply.js +17 -0
- package/src/maths/vec3/multiply.test.js +36 -0
- package/src/maths/vec3/negate.d.ts +5 -0
- package/src/maths/vec3/negate.js +16 -0
- package/src/maths/vec3/negate.test.js +26 -0
- package/src/maths/vec3/normalize.d.ts +5 -0
- package/src/maths/vec3/normalize.js +23 -0
- package/src/maths/vec3/normalize.test.js +36 -0
- package/src/maths/vec3/orthogonal.d.ts +5 -0
- package/src/maths/vec3/orthogonal.js +22 -0
- package/src/maths/vec3/orthogonal.test.js +24 -0
- package/src/maths/vec3/rotateX.d.ts +5 -0
- package/src/maths/vec3/rotateX.js +33 -0
- package/src/maths/vec3/rotateX.test.js +31 -0
- package/src/maths/vec3/rotateY.d.ts +5 -0
- package/src/maths/vec3/rotateY.js +33 -0
- package/src/maths/vec3/rotateY.test.js +31 -0
- package/src/maths/vec3/rotateZ.d.ts +5 -0
- package/src/maths/vec3/rotateZ.js +30 -0
- package/src/maths/vec3/rotateZ.test.js +31 -0
- package/src/maths/vec3/scale.d.ts +5 -0
- package/src/maths/vec3/scale.js +17 -0
- package/src/maths/vec3/scale.test.js +36 -0
- package/src/maths/vec3/snap.d.ts +5 -0
- package/src/maths/vec3/snap.js +17 -0
- package/src/maths/vec3/snap.test.js +32 -0
- package/src/maths/vec3/squaredDistance.d.ts +5 -0
- package/src/maths/vec3/squaredDistance.js +16 -0
- package/src/maths/vec3/squaredDistance.test.js +46 -0
- package/src/maths/vec3/squaredLength.d.ts +5 -0
- package/src/maths/vec3/squaredLength.js +15 -0
- package/src/maths/vec3/squaredLength.test.js +45 -0
- package/src/maths/vec3/subtract.d.ts +5 -0
- package/src/maths/vec3/subtract.js +17 -0
- package/src/maths/vec3/subtract.test.js +26 -0
- package/src/maths/vec3/toString.d.ts +5 -0
- package/src/maths/vec3/toString.js +9 -0
- package/src/maths/vec3/transform.d.ts +6 -0
- package/src/maths/vec3/transform.js +22 -0
- package/src/maths/vec3/transform.test.js +66 -0
- package/src/maths/vec3/type.d.ts +3 -0
- package/src/maths/vec4/clone.d.ts +5 -0
- package/src/maths/vec4/clone.js +19 -0
- package/src/maths/vec4/clone.test.js +24 -0
- package/src/maths/vec4/copy.d.ts +5 -0
- package/src/maths/vec4/copy.js +17 -0
- package/src/maths/vec4/copy.test.js +30 -0
- package/src/maths/vec4/create.d.ts +5 -0
- package/src/maths/vec4/create.js +15 -0
- package/src/maths/vec4/create.test.js +10 -0
- package/src/maths/vec4/dot.d.ts +5 -0
- package/src/maths/vec4/dot.js +11 -0
- package/src/maths/vec4/dot.test.js +11 -0
- package/src/maths/vec4/equals.d.ts +5 -0
- package/src/maths/vec4/equals.js +11 -0
- package/src/maths/vec4/equals.test.js +17 -0
- package/src/maths/vec4/fromScalar.d.ts +5 -0
- package/src/maths/vec4/fromScalar.js +17 -0
- package/src/maths/vec4/fromScalar.test.js +12 -0
- package/src/maths/vec4/fromValues.d.ts +5 -0
- package/src/maths/vec4/fromValues.js +22 -0
- package/src/maths/vec4/fromValues.test.js +15 -0
- package/src/maths/vec4/index.d.ts +12 -0
- package/src/maths/vec4/index.js +16 -0
- package/src/maths/vec4/toString.d.ts +5 -0
- package/src/maths/vec4/toString.js +10 -0
- package/src/maths/vec4/transform.d.ts +6 -0
- package/src/maths/vec4/transform.js +20 -0
- package/src/maths/vec4/transform.test.js +66 -0
- package/src/maths/vec4/type.d.ts +3 -0
- package/src/measurements/calculateEpsilonFromBounds.js +11 -0
- package/src/measurements/calculateEpsilonFromBounds.test.js +18 -0
- package/src/measurements/index.d.ts +15 -0
- package/src/measurements/index.js +20 -0
- package/src/measurements/measureAggregateArea.d.ts +6 -0
- package/src/measurements/measureAggregateArea.js +26 -0
- package/src/measurements/measureAggregateArea.test.js +22 -0
- package/src/measurements/measureAggregateBoundingBox.d.ts +8 -0
- package/src/measurements/measureAggregateBoundingBox.js +30 -0
- package/src/measurements/measureAggregateBoundingBox.test.js +35 -0
- package/src/measurements/measureAggregateEpsilon.d.ts +6 -0
- package/src/measurements/measureAggregateEpsilon.js +29 -0
- package/src/measurements/measureAggregateEpsilon.test.js +28 -0
- package/src/measurements/measureAggregateVolume.d.ts +6 -0
- package/src/measurements/measureAggregateVolume.js +26 -0
- package/src/measurements/measureAggregateVolume.test.js +21 -0
- package/src/measurements/measureArea.d.ts +8 -0
- package/src/measurements/measureArea.js +80 -0
- package/src/measurements/measureArea.test.js +58 -0
- package/src/measurements/measureBoundingBox.d.ts +10 -0
- package/src/measurements/measureBoundingBox.js +134 -0
- package/src/measurements/measureBoundingBox.test.js +66 -0
- package/src/measurements/measureBoundingSphere.d.ts +9 -0
- package/src/measurements/measureBoundingSphere.js +146 -0
- package/src/measurements/measureBoundingSphere.test.js +59 -0
- package/src/measurements/measureCenter.d.ts +7 -0
- package/src/measurements/measureCenter.js +28 -0
- package/src/measurements/measureCenter.test.js +58 -0
- package/src/measurements/measureCenterOfMass.d.ts +7 -0
- package/src/measurements/measureCenterOfMass.js +106 -0
- package/src/measurements/measureCenterOfMass.test.js +58 -0
- package/src/measurements/measureDimensions.d.ts +7 -0
- package/src/measurements/measureDimensions.js +28 -0
- package/src/measurements/measureDimensions.test.js +58 -0
- package/src/measurements/measureEpsilon.d.ts +8 -0
- package/src/measurements/measureEpsilon.js +48 -0
- package/src/measurements/measureEpsilon.test.js +58 -0
- package/src/measurements/measureVolume.d.ts +8 -0
- package/src/measurements/measureVolume.js +68 -0
- package/src/measurements/measureVolume.test.js +58 -0
- package/src/measurements/types.d.ts +3 -0
- package/src/operations/booleans/fromFakePolygons.js +52 -0
- package/src/operations/booleans/index.d.ts +6 -0
- package/src/operations/booleans/index.js +14 -0
- package/src/operations/booleans/intersect.d.ts +7 -0
- package/src/operations/booleans/intersect.js +47 -0
- package/src/operations/booleans/intersectGeom2.js +27 -0
- package/src/operations/booleans/intersectGeom2.test.js +69 -0
- package/src/operations/booleans/intersectGeom3.js +25 -0
- package/src/operations/booleans/intersectGeom3.test.js +116 -0
- package/src/operations/booleans/intersectGeom3Sub.js +33 -0
- package/src/operations/booleans/mayOverlap.js +35 -0
- package/src/operations/booleans/mayOverlap.test.js +73 -0
- package/src/operations/booleans/scission.d.ts +6 -0
- package/src/operations/booleans/scission.js +45 -0
- package/src/operations/booleans/scission.test.js +51 -0
- package/src/operations/booleans/scissionGeom3.js +93 -0
- package/src/operations/booleans/subtract.d.ts +7 -0
- package/src/operations/booleans/subtract.js +47 -0
- package/src/operations/booleans/subtractGeom2.js +27 -0
- package/src/operations/booleans/subtractGeom2.test.js +72 -0
- package/src/operations/booleans/subtractGeom3.js +25 -0
- package/src/operations/booleans/subtractGeom3.test.js +109 -0
- package/src/operations/booleans/subtractGeom3Sub.js +31 -0
- package/src/operations/booleans/to3DWalls.js +36 -0
- package/src/operations/booleans/trees/Node.js +144 -0
- package/src/operations/booleans/trees/PolygonTreeNode.js +261 -0
- package/src/operations/booleans/trees/Tree.js +50 -0
- package/src/operations/booleans/trees/index.js +3 -0
- package/src/operations/booleans/trees/splitLineSegmentByPlane.js +15 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.d.ts +33 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.js +119 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.test.js +132 -0
- package/src/operations/booleans/union.d.ts +7 -0
- package/src/operations/booleans/union.js +46 -0
- package/src/operations/booleans/unionGeom2.js +26 -0
- package/src/operations/booleans/unionGeom2.test.js +166 -0
- package/src/operations/booleans/unionGeom3.js +25 -0
- package/src/operations/booleans/unionGeom3.test.js +133 -0
- package/src/operations/booleans/unionGeom3Sub.js +40 -0
- package/src/operations/expansions/expand.d.ts +18 -0
- package/src/operations/expansions/expand.js +42 -0
- package/src/operations/expansions/expand.test.js +188 -0
- package/src/operations/expansions/expandGeom2.js +43 -0
- package/src/operations/expansions/expandGeom3.js +36 -0
- package/src/operations/expansions/expandGeom3.test.js +32 -0
- package/src/operations/expansions/expandPath2.js +99 -0
- package/src/operations/expansions/expandShell.js +224 -0
- package/src/operations/expansions/extrudePolygon.js +34 -0
- package/src/operations/expansions/index.d.ts +4 -0
- package/src/operations/expansions/index.js +11 -0
- package/src/operations/expansions/offset.d.ts +15 -0
- package/src/operations/expansions/offset.js +36 -0
- package/src/operations/expansions/offset.test.js +503 -0
- package/src/operations/expansions/offsetFromPoints.js +170 -0
- package/src/operations/expansions/offsetGeom2.js +47 -0
- package/src/operations/expansions/offsetPath2.js +32 -0
- 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.d.ts +15 -0
- package/src/operations/extrusions/extrudeFromSlices.js +124 -0
- package/src/operations/extrusions/extrudeFromSlices.test.js +167 -0
- package/src/operations/extrusions/extrudeHelical.d.ts +14 -0
- package/src/operations/extrusions/extrudeHelical.js +109 -0
- package/src/operations/extrusions/extrudeHelical.test.js +70 -0
- package/src/operations/extrusions/extrudeLinear.d.ts +15 -0
- package/src/operations/extrusions/extrudeLinear.js +47 -0
- package/src/operations/extrusions/extrudeLinear.test.js +226 -0
- package/src/operations/extrusions/extrudeLinearGeom2.js +64 -0
- package/src/operations/extrusions/extrudeLinearPath2.js +24 -0
- package/src/operations/extrusions/extrudeRectangular.d.ts +17 -0
- package/src/operations/extrusions/extrudeRectangular.js +45 -0
- package/src/operations/extrusions/extrudeRectangular.test.js +72 -0
- package/src/operations/extrusions/extrudeRectangularGeom2.js +46 -0
- package/src/operations/extrusions/extrudeRectangularPath2.js +33 -0
- package/src/operations/extrusions/extrudeRotate.d.ts +12 -0
- package/src/operations/extrusions/extrudeRotate.js +138 -0
- package/src/operations/extrusions/extrudeRotate.test.js +161 -0
- package/src/operations/extrusions/extrudeWalls.js +78 -0
- package/src/operations/extrusions/extrudeWalls.test.js +82 -0
- package/src/operations/extrusions/index.d.ts +9 -0
- package/src/operations/extrusions/index.js +16 -0
- package/src/operations/extrusions/project.d.ts +14 -0
- package/src/operations/extrusions/project.js +88 -0
- package/src/operations/extrusions/project.test.js +123 -0
- package/src/operations/extrusions/slice/calculatePlane.d.ts +7 -0
- package/src/operations/extrusions/slice/calculatePlane.js +41 -0
- package/src/operations/extrusions/slice/calculatePlane.test.js +35 -0
- package/src/operations/extrusions/slice/clone.d.ts +6 -0
- package/src/operations/extrusions/slice/clone.js +28 -0
- package/src/operations/extrusions/slice/clone.test.js +34 -0
- package/src/operations/extrusions/slice/create.d.ts +5 -0
- package/src/operations/extrusions/slice/create.js +20 -0
- package/src/operations/extrusions/slice/create.test.js +9 -0
- package/src/operations/extrusions/slice/equals.d.ts +5 -0
- package/src/operations/extrusions/slice/equals.js +27 -0
- package/src/operations/extrusions/slice/equals.test.js +17 -0
- package/src/operations/extrusions/slice/fromPoints.d.ts +9 -0
- package/src/operations/extrusions/slice/fromPoints.js +35 -0
- package/src/operations/extrusions/slice/fromPoints.test.js +15 -0
- package/src/operations/extrusions/slice/fromSides.d.ts +7 -0
- package/src/operations/extrusions/slice/fromSides.js +27 -0
- package/src/operations/extrusions/slice/fromSides.test.js +15 -0
- package/src/operations/extrusions/slice/index.d.ts +16 -0
- package/src/operations/extrusions/slice/index.js +19 -0
- package/src/operations/extrusions/slice/isA.d.ts +5 -0
- package/src/operations/extrusions/slice/isA.js +18 -0
- package/src/operations/extrusions/slice/isA.test.js +19 -0
- package/src/operations/extrusions/slice/repair.js +62 -0
- package/src/operations/extrusions/slice/reverse.d.ts +6 -0
- package/src/operations/extrusions/slice/reverse.js +26 -0
- package/src/operations/extrusions/slice/toEdges.d.ts +5 -0
- package/src/operations/extrusions/slice/toEdges.js +13 -0
- package/src/operations/extrusions/slice/toPolygons.d.ts +7 -0
- package/src/operations/extrusions/slice/toPolygons.js +40 -0
- package/src/operations/extrusions/slice/toString.d.ts +5 -0
- package/src/operations/extrusions/slice/toString.js +15 -0
- package/src/operations/extrusions/slice/transform.d.ts +7 -0
- package/src/operations/extrusions/slice/transform.js +21 -0
- package/src/operations/extrusions/slice/transform.test.js +66 -0
- package/src/operations/extrusions/slice/type.d.ts +7 -0
- package/src/operations/hulls/hull.d.ts +8 -0
- package/src/operations/hulls/hull.js +52 -0
- package/src/operations/hulls/hull.test.js +284 -0
- package/src/operations/hulls/hullChain.d.ts +8 -0
- package/src/operations/hulls/hullChain.js +43 -0
- package/src/operations/hulls/hullChain.test.js +87 -0
- package/src/operations/hulls/hullGeom2.js +31 -0
- package/src/operations/hulls/hullGeom3.js +27 -0
- package/src/operations/hulls/hullPath2.js +28 -0
- package/src/operations/hulls/hullPath2.test.js +16 -0
- package/src/operations/hulls/hullPoints2.d.ts +5 -0
- package/src/operations/hulls/hullPoints2.js +62 -0
- package/src/operations/hulls/hullPoints2.test.js +48 -0
- package/src/operations/hulls/hullPoints3.d.ts +6 -0
- package/src/operations/hulls/hullPoints3.js +23 -0
- package/src/operations/hulls/index.d.ts +6 -0
- package/src/operations/hulls/index.js +14 -0
- package/src/operations/hulls/quickhull/Face.js +334 -0
- package/src/operations/hulls/quickhull/HalfEdge.js +56 -0
- package/src/operations/hulls/quickhull/QuickHull.js +754 -0
- package/src/operations/hulls/quickhull/Vertex.js +21 -0
- package/src/operations/hulls/quickhull/VertexList.js +146 -0
- package/src/operations/hulls/quickhull/get-plane-normal.js +20 -0
- package/src/operations/hulls/quickhull/index.js +16 -0
- package/src/operations/hulls/quickhull/point-line-distance.js +42 -0
- package/src/operations/hulls/toUniquePoints.js +34 -0
- package/src/operations/modifiers/generalize.d.ts +12 -0
- package/src/operations/modifiers/generalize.js +82 -0
- package/src/operations/modifiers/generalize.test.js +170 -0
- package/src/operations/modifiers/index.d.ts +3 -0
- package/src/operations/modifiers/index.js +12 -0
- package/src/operations/modifiers/insertTjunctions.js +294 -0
- package/src/operations/modifiers/insertTjunctions.test.js +89 -0
- package/src/operations/modifiers/mergePolygons.js +208 -0
- package/src/operations/modifiers/reTesselateCoplanarPolygons.js +345 -0
- package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +70 -0
- package/src/operations/modifiers/retessellate.d.ts +3 -0
- package/src/operations/modifiers/retessellate.js +93 -0
- package/src/operations/modifiers/retessellate.test.js +173 -0
- package/src/operations/modifiers/snap.d.ts +6 -0
- package/src/operations/modifiers/snap.js +57 -0
- package/src/operations/modifiers/snap.test.js +146 -0
- package/src/operations/modifiers/snapPolygons.js +32 -0
- package/src/operations/modifiers/snapPolygons.test.js +70 -0
- package/src/operations/modifiers/triangulatePolygons.js +45 -0
- package/src/operations/transforms/align.d.ts +16 -0
- package/src/operations/transforms/align.js +89 -0
- package/src/operations/transforms/align.test.js +96 -0
- package/src/operations/transforms/center.d.ts +24 -0
- package/src/operations/transforms/center.js +90 -0
- package/src/operations/transforms/center.test.js +128 -0
- package/src/operations/transforms/index.d.ts +9 -0
- package/src/operations/transforms/index.js +37 -0
- package/src/operations/transforms/mirror.d.ts +24 -0
- package/src/operations/transforms/mirror.js +78 -0
- package/src/operations/transforms/mirror.test.js +158 -0
- package/src/operations/transforms/rotate.d.ts +19 -0
- package/src/operations/transforms/rotate.js +76 -0
- package/src/operations/transforms/rotate.test.js +154 -0
- package/src/operations/transforms/scale.d.ts +19 -0
- package/src/operations/transforms/scale.js +74 -0
- package/src/operations/transforms/scale.test.js +151 -0
- package/src/operations/transforms/transform.d.ts +7 -0
- package/src/operations/transforms/transform.js +32 -0
- package/src/operations/transforms/transform.test.js +76 -0
- package/src/operations/transforms/translate.d.ts +21 -0
- package/src/operations/transforms/translate.js +72 -0
- package/src/operations/transforms/translate.test.js +151 -0
- package/src/primitives/arc.d.ts +15 -0
- package/src/primitives/arc.js +86 -0
- package/src/primitives/arc.test.js +223 -0
- package/src/primitives/circle.d.ts +14 -0
- package/src/primitives/circle.js +38 -0
- package/src/primitives/circle.test.js +155 -0
- package/src/primitives/commonChecks.js +19 -0
- package/src/primitives/cube.d.ts +11 -0
- package/src/primitives/cube.js +30 -0
- package/src/primitives/cube.test.js +55 -0
- package/src/primitives/cuboid.d.ts +11 -0
- package/src/primitives/cuboid.js +55 -0
- package/src/primitives/cuboid.test.js +64 -0
- package/src/primitives/cylinder.d.ts +13 -0
- package/src/primitives/cylinder.js +46 -0
- package/src/primitives/cylinder.test.js +90 -0
- package/src/primitives/cylinderElliptic.d.ts +16 -0
- package/src/primitives/cylinderElliptic.js +132 -0
- package/src/primitives/cylinderElliptic.test.js +213 -0
- package/src/primitives/ellipse.d.ts +14 -0
- package/src/primitives/ellipse.js +78 -0
- package/src/primitives/ellipse.test.js +146 -0
- package/src/primitives/ellipsoid.d.ts +13 -0
- package/src/primitives/ellipsoid.js +99 -0
- package/src/primitives/ellipsoid.test.js +216 -0
- package/src/primitives/geodesicSphere.d.ts +10 -0
- package/src/primitives/geodesicSphere.js +140 -0
- package/src/primitives/geodesicSphere.test.js +60 -0
- package/src/primitives/index.d.ts +23 -0
- package/src/primitives/index.js +31 -0
- package/src/primitives/line.d.ts +6 -0
- package/src/primitives/line.js +19 -0
- package/src/primitives/line.test.js +17 -0
- package/src/primitives/polygon.d.ts +12 -0
- package/src/primitives/polygon.js +81 -0
- package/src/primitives/polygon.test.js +63 -0
- package/src/primitives/polyhedron.d.ts +14 -0
- package/src/primitives/polyhedron.js +72 -0
- package/src/primitives/polyhedron.test.js +44 -0
- package/src/primitives/rectangle.d.ts +11 -0
- package/src/primitives/rectangle.js +44 -0
- package/src/primitives/rectangle.test.js +59 -0
- package/src/primitives/roundedCuboid.d.ts +13 -0
- package/src/primitives/roundedCuboid.js +193 -0
- package/src/primitives/roundedCuboid.test.js +248 -0
- package/src/primitives/roundedCylinder.d.ts +14 -0
- package/src/primitives/roundedCylinder.js +147 -0
- package/src/primitives/roundedCylinder.test.js +165 -0
- package/src/primitives/roundedRectangle.d.ts +13 -0
- package/src/primitives/roundedRectangle.js +76 -0
- package/src/primitives/roundedRectangle.test.js +124 -0
- package/src/primitives/sphere.d.ts +13 -0
- package/src/primitives/sphere.js +35 -0
- package/src/primitives/sphere.test.js +172 -0
- package/src/primitives/square.d.ts +11 -0
- package/src/primitives/square.js +31 -0
- package/src/primitives/square.test.js +51 -0
- package/src/primitives/star.d.ts +15 -0
- package/src/primitives/star.js +88 -0
- package/src/primitives/star.test.js +148 -0
- package/src/primitives/torus.d.ts +15 -0
- package/src/primitives/torus.js +64 -0
- package/src/primitives/torus.test.js +59 -0
- package/src/primitives/triangle.d.ts +10 -0
- package/src/primitives/triangle.js +163 -0
- package/src/primitives/triangle.test.js +103 -0
- package/src/text/fonts/single-line/hershey/simplex.js +101 -0
- package/src/text/index.d.ts +4 -0
- package/src/text/index.js +12 -0
- package/src/text/text.test.js +187 -0
- package/src/text/vectorChar.d.ts +22 -0
- package/src/text/vectorChar.js +60 -0
- package/src/text/vectorParams.js +26 -0
- package/src/text/vectorText.d.ts +21 -0
- package/src/text/vectorText.js +92 -0
- package/src/utils/areAllShapesTheSameType.d.ts +5 -0
- package/src/utils/areAllShapesTheSameType.js +25 -0
- package/src/utils/areAllShapesTheSameType.test.js +17 -0
- package/src/utils/corners.d.ts +1 -0
- package/src/utils/degToRad.d.ts +3 -0
- package/src/utils/degToRad.js +9 -0
- package/src/utils/degToRad.test.js +19 -0
- package/src/utils/flatten.d.ts +5 -0
- package/src/utils/flatten.js +25 -0
- package/src/utils/flatten.test.js +94 -0
- package/src/utils/fnNumberSort.d.ts +3 -0
- package/src/utils/fnNumberSort.js +6 -0
- package/src/utils/index.d.ts +9 -0
- package/src/utils/index.js +15 -0
- package/src/utils/insertSorted.d.ts +3 -0
- package/src/utils/insertSorted.js +21 -0
- package/src/utils/padArrayToLength.d.ts +3 -0
- package/src/utils/padArrayToLength.js +17 -0
- package/src/utils/padArrayToLength.test.js +27 -0
- package/src/utils/radToDeg.d.ts +3 -0
- package/src/utils/radToDeg.js +9 -0
- package/src/utils/radToDeg.test.js +19 -0
- package/src/utils/radiusToSegments.d.ts +3 -0
- package/src/utils/radiusToSegments.js +18 -0
- package/src/utils/radiusToSegments.test.js +28 -0
- package/src/utils/recursiveArray.d.ts +3 -0
- package/test/helpers/asserts.js +126 -0
- package/test/helpers/comparePoints.js +16 -0
- package/test/helpers/comparePolygonLists.js +10 -0
- package/test/helpers/comparePolygons.js +16 -0
- package/test/helpers/comparePolygonsAsPoints.js +23 -0
- package/test/helpers/compareVectors.js +36 -0
- package/test/helpers/index.js +8 -0
- package/test/helpers/nearlyEqual.js +34 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const vec3 = require('../vec3')
|
|
4
|
+
|
|
5
|
+
const create = require('./create')
|
|
6
|
+
const fromVectorRotation = require('./fromVectorRotation')
|
|
7
|
+
|
|
8
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
9
|
+
|
|
10
|
+
test('mat4: fromVectorRotation() called with out parameter should return a mat4 with correct values', (t) => {
|
|
11
|
+
// unit vectors, same directions
|
|
12
|
+
const out = create()
|
|
13
|
+
let ret = fromVectorRotation(out, [1, 0, 0], [1, 0, 0])
|
|
14
|
+
t.is(ret, out)
|
|
15
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
16
|
+
|
|
17
|
+
ret = fromVectorRotation(out, [0, 1, 0], [0, 1, 0])
|
|
18
|
+
t.is(ret, out)
|
|
19
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
20
|
+
|
|
21
|
+
ret = fromVectorRotation(out, [0, 0, 1], [0, 0, 1])
|
|
22
|
+
t.is(ret, out)
|
|
23
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
24
|
+
|
|
25
|
+
// unit vectors, axis rotations
|
|
26
|
+
ret = fromVectorRotation(out, [1, 0, 0], [0, 1, 0])
|
|
27
|
+
t.is(ret, out)
|
|
28
|
+
t.true(compareVectors(out, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
29
|
+
|
|
30
|
+
ret = fromVectorRotation(out, [1, 0, 0], [0, 0, 1])
|
|
31
|
+
t.is(ret, out)
|
|
32
|
+
t.true(compareVectors(out, [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]))
|
|
33
|
+
|
|
34
|
+
ret = fromVectorRotation(out, [0, 1, 0], [1, 0, 0])
|
|
35
|
+
t.is(ret, out)
|
|
36
|
+
t.true(compareVectors(out, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
37
|
+
|
|
38
|
+
ret = fromVectorRotation(out, [0, 1, 0], [0, 0, 1])
|
|
39
|
+
t.is(ret, out)
|
|
40
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
|
|
41
|
+
|
|
42
|
+
ret = fromVectorRotation(out, [0, 0, 1], [1, 0, 0])
|
|
43
|
+
t.is(ret, out)
|
|
44
|
+
t.true(compareVectors(out, [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]))
|
|
45
|
+
|
|
46
|
+
ret = fromVectorRotation(out, [0, 0, 1], [0, 1, 0])
|
|
47
|
+
t.is(ret, out)
|
|
48
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
|
|
49
|
+
|
|
50
|
+
ret = fromVectorRotation(out, [-1, 0, 0], [0, -1, 0])
|
|
51
|
+
t.is(ret, out)
|
|
52
|
+
t.true(compareVectors(out, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
53
|
+
|
|
54
|
+
ret = fromVectorRotation(out, [-1, 0, 0], [0, 0, -1])
|
|
55
|
+
t.is(ret, out)
|
|
56
|
+
t.true(compareVectors(out, [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]))
|
|
57
|
+
|
|
58
|
+
ret = fromVectorRotation(out, [0, -1, 0], [-1, 0, 0])
|
|
59
|
+
t.is(ret, out)
|
|
60
|
+
t.true(compareVectors(out, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
61
|
+
|
|
62
|
+
ret = fromVectorRotation(out, [0, -1, 0], [0, 0, -1])
|
|
63
|
+
t.is(ret, out)
|
|
64
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
|
|
65
|
+
|
|
66
|
+
ret = fromVectorRotation(out, [0, 0, -1], [-1, 0, 0])
|
|
67
|
+
t.is(ret, out)
|
|
68
|
+
t.true(compareVectors(out, [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]))
|
|
69
|
+
|
|
70
|
+
ret = fromVectorRotation(out, [0, 0, -1], [0, -1, 0])
|
|
71
|
+
t.is(ret, out)
|
|
72
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
|
|
73
|
+
|
|
74
|
+
// unit vector, opposite directions
|
|
75
|
+
ret = fromVectorRotation(out, [1, 0, 0], [-1, 0, 0])
|
|
76
|
+
t.is(ret, out)
|
|
77
|
+
t.true(compareVectors(out, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
78
|
+
|
|
79
|
+
ret = fromVectorRotation(out, [-1, 0, 0], [1, 0, 0])
|
|
80
|
+
t.is(ret, out)
|
|
81
|
+
t.true(compareVectors(out, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
82
|
+
|
|
83
|
+
ret = fromVectorRotation(out, [0, 1, 0], [0, -1, 0])
|
|
84
|
+
t.is(ret, out)
|
|
85
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
86
|
+
|
|
87
|
+
ret = fromVectorRotation(out, [0, -1, 0], [0, 1, 0])
|
|
88
|
+
t.is(ret, out)
|
|
89
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
90
|
+
|
|
91
|
+
ret = fromVectorRotation(out, [0, 0, 1], [0, 0, -1])
|
|
92
|
+
t.is(ret, out)
|
|
93
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
94
|
+
|
|
95
|
+
ret = fromVectorRotation(out, [0, 0, -1], [0, 0, 1])
|
|
96
|
+
t.is(ret, out)
|
|
97
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
98
|
+
|
|
99
|
+
// different units
|
|
100
|
+
ret = fromVectorRotation(out, [11, 0, 0], [0, 33, 0])
|
|
101
|
+
t.is(ret, out)
|
|
102
|
+
t.true(compareVectors(out, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
103
|
+
|
|
104
|
+
ret = fromVectorRotation(out, [0, 0.11, 0], [0, 0, 0.33])
|
|
105
|
+
t.is(ret, out)
|
|
106
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
|
|
107
|
+
|
|
108
|
+
ret = fromVectorRotation(out, [0, 0, 111111.0], [0, 0.33, 0])
|
|
109
|
+
t.is(ret, out)
|
|
110
|
+
t.true(compareVectors(out, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
|
|
111
|
+
|
|
112
|
+
// different quadrants
|
|
113
|
+
ret = fromVectorRotation(out, [0.5, 0.5, 0.5], [-0.5, 0.5, 0.5])
|
|
114
|
+
t.is(ret, out)
|
|
115
|
+
t.true(compareVectors(out, [0.3333333333333334, 0.6666666666666669, 0.6666666666666669, 0, -0.6666666666666669, 0.666666666666667, -0.3333333333333335, 0, -0.6666666666666669, -0.3333333333333335, 0.666666666666667, 0, 0, 0, 0, 1]))
|
|
116
|
+
t.true(compareVectors([-0.5, 0.5, 0.5], vec3.transform(vec3.create(), [0.5, 0.5, 0.5], ret)))
|
|
117
|
+
|
|
118
|
+
ret = fromVectorRotation(out, [5, 5, 5], [5, 5, -5])
|
|
119
|
+
t.is(ret, out)
|
|
120
|
+
t.true(compareVectors(out, [0.6666666666666666, -0.3333333333333333, -0.6666666666666666, 0, -0.3333333333333333, 0.6666666666666666, -0.6666666666666666, 0, 0.6666666666666666, 0.6666666666666666, 0.3333333333333333, 0, 0, 0, 0, 1]))
|
|
121
|
+
t.true(compareVectors([5, 5, -5], vec3.transform(vec3.create(), [5, 5, 5], ret)))
|
|
122
|
+
|
|
123
|
+
ret = fromVectorRotation(out, [5, 5, 5], [-5, -5, -5])
|
|
124
|
+
t.is(ret, out)
|
|
125
|
+
t.true(compareVectors(out, [0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1]))
|
|
126
|
+
t.true(compareVectors([-5, -5, -5], vec3.transform(vec3.create(), [5, 5, 5], ret)))
|
|
127
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { sin, cos } = require('../utils/trigonometry')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a matrix from the given angle around the X axis.
|
|
5
|
+
* This is equivalent to (but much faster than):
|
|
6
|
+
*
|
|
7
|
+
* mat4.identity(dest)
|
|
8
|
+
* mat4.rotateX(dest, dest, radians)
|
|
9
|
+
*
|
|
10
|
+
* @param {mat4} out - receiving matrix
|
|
11
|
+
* @param {Number} radians - angle to rotate the matrix by
|
|
12
|
+
* @returns {mat4} out
|
|
13
|
+
* @alias module:modeling/maths/mat4.fromXRotation
|
|
14
|
+
* @example
|
|
15
|
+
* let matrix = fromXRotation(create(), TAU / 4)
|
|
16
|
+
*/
|
|
17
|
+
const fromXRotation = (out, radians) => {
|
|
18
|
+
const s = sin(radians)
|
|
19
|
+
const c = cos(radians)
|
|
20
|
+
|
|
21
|
+
// Perform axis-specific matrix multiplication
|
|
22
|
+
out[0] = 1
|
|
23
|
+
out[1] = 0
|
|
24
|
+
out[2] = 0
|
|
25
|
+
out[3] = 0
|
|
26
|
+
out[4] = 0
|
|
27
|
+
out[5] = c
|
|
28
|
+
out[6] = s
|
|
29
|
+
out[7] = 0
|
|
30
|
+
out[8] = 0
|
|
31
|
+
out[9] = -s
|
|
32
|
+
out[10] = c
|
|
33
|
+
out[11] = 0
|
|
34
|
+
out[12] = 0
|
|
35
|
+
out[13] = 0
|
|
36
|
+
out[14] = 0
|
|
37
|
+
out[15] = 1
|
|
38
|
+
return out
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = fromXRotation
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const { fromXRotation, create } = require('./index')
|
|
3
|
+
|
|
4
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
5
|
+
|
|
6
|
+
test('mat4: fromXRotation() should return a new mat4 with correct values', (t) => {
|
|
7
|
+
const rotation = 90 * 0.017453292519943295
|
|
8
|
+
|
|
9
|
+
const obs2 = fromXRotation(create(), rotation)
|
|
10
|
+
t.true(compareVectors(obs2, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]))
|
|
11
|
+
|
|
12
|
+
const obs3 = fromXRotation(obs2, -rotation)
|
|
13
|
+
t.true(compareVectors(obs3, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]))
|
|
14
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { sin, cos } = require('../utils/trigonometry')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a matrix from the given angle around the Y axis.
|
|
5
|
+
* This is equivalent to (but much faster than):
|
|
6
|
+
*
|
|
7
|
+
* mat4.identity(dest)
|
|
8
|
+
* mat4.rotateY(dest, dest, radians)
|
|
9
|
+
*
|
|
10
|
+
* @param {mat4} out - receiving matrix
|
|
11
|
+
* @param {Number} radians - angle to rotate the matrix by
|
|
12
|
+
* @returns {mat4} out
|
|
13
|
+
* @alias module:modeling/maths/mat4.fromYRotation
|
|
14
|
+
* @example
|
|
15
|
+
* let matrix = fromYRotation(create(), TAU / 4)
|
|
16
|
+
*/
|
|
17
|
+
const fromYRotation = (out, radians) => {
|
|
18
|
+
const s = sin(radians)
|
|
19
|
+
const c = cos(radians)
|
|
20
|
+
|
|
21
|
+
// Perform axis-specific matrix multiplication
|
|
22
|
+
out[0] = c
|
|
23
|
+
out[1] = 0
|
|
24
|
+
out[2] = -s
|
|
25
|
+
out[3] = 0
|
|
26
|
+
out[4] = 0
|
|
27
|
+
out[5] = 1
|
|
28
|
+
out[6] = 0
|
|
29
|
+
out[7] = 0
|
|
30
|
+
out[8] = s
|
|
31
|
+
out[9] = 0
|
|
32
|
+
out[10] = c
|
|
33
|
+
out[11] = 0
|
|
34
|
+
out[12] = 0
|
|
35
|
+
out[13] = 0
|
|
36
|
+
out[14] = 0
|
|
37
|
+
out[15] = 1
|
|
38
|
+
return out
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = fromYRotation
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const { fromYRotation, create } = require('./index')
|
|
3
|
+
|
|
4
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
5
|
+
|
|
6
|
+
test('mat4: fromYRotation() should return a new mat4 with correct values', (t) => {
|
|
7
|
+
const rotation = 90 * 0.017453292519943295
|
|
8
|
+
|
|
9
|
+
const obs2 = fromYRotation(create(), rotation)
|
|
10
|
+
t.true(compareVectors(obs2, [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]))
|
|
11
|
+
|
|
12
|
+
const obs3 = fromYRotation(obs2, -rotation)
|
|
13
|
+
t.true(compareVectors(obs3, [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]))
|
|
14
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { sin, cos } = require('../utils/trigonometry')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a matrix from the given angle around the Z axis.
|
|
5
|
+
* This is equivalent to (but much faster than):
|
|
6
|
+
*
|
|
7
|
+
* mat4.identity(dest)
|
|
8
|
+
* mat4.rotateZ(dest, dest, radians)
|
|
9
|
+
*
|
|
10
|
+
* @param {mat4} out - receiving matrix
|
|
11
|
+
* @param {Number} radians - angle to rotate the matrix by
|
|
12
|
+
* @returns {mat4} out
|
|
13
|
+
* @alias module:modeling/maths/mat4.fromZRotation
|
|
14
|
+
* @example
|
|
15
|
+
* let matrix = fromZRotation(create(), TAU / 4)
|
|
16
|
+
*/
|
|
17
|
+
const fromZRotation = (out, radians) => {
|
|
18
|
+
const s = sin(radians)
|
|
19
|
+
const c = cos(radians)
|
|
20
|
+
|
|
21
|
+
// Perform axis-specific matrix multiplication
|
|
22
|
+
out[0] = c
|
|
23
|
+
out[1] = s
|
|
24
|
+
out[2] = 0
|
|
25
|
+
out[3] = 0
|
|
26
|
+
out[4] = -s
|
|
27
|
+
out[5] = c
|
|
28
|
+
out[6] = 0
|
|
29
|
+
out[7] = 0
|
|
30
|
+
out[8] = 0
|
|
31
|
+
out[9] = 0
|
|
32
|
+
out[10] = 1
|
|
33
|
+
out[11] = 0
|
|
34
|
+
out[12] = 0
|
|
35
|
+
out[13] = 0
|
|
36
|
+
out[14] = 0
|
|
37
|
+
out[15] = 1
|
|
38
|
+
return out
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = fromZRotation
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const { fromZRotation, create } = require('./index')
|
|
3
|
+
|
|
4
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
5
|
+
|
|
6
|
+
test('mat4: fromZRotation() should return a new mat4 with correct values', (t) => {
|
|
7
|
+
const rotation = 90 * 0.017453292519943295
|
|
8
|
+
|
|
9
|
+
const obs2 = fromZRotation(create(), rotation)
|
|
10
|
+
t.true(compareVectors(obs2, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
11
|
+
|
|
12
|
+
const obs3 = fromZRotation(obs2, -rotation)
|
|
13
|
+
t.true(compareVectors(obs3, [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
14
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set a matrix to the identity transform.
|
|
3
|
+
*
|
|
4
|
+
* @param {mat4} out - receiving matrix
|
|
5
|
+
* @returns {mat4} out
|
|
6
|
+
* @alias module:modeling/maths/mat4.identity
|
|
7
|
+
*/
|
|
8
|
+
const identity = (out) => {
|
|
9
|
+
out[0] = 1
|
|
10
|
+
out[1] = 0
|
|
11
|
+
out[2] = 0
|
|
12
|
+
out[3] = 0
|
|
13
|
+
out[4] = 0
|
|
14
|
+
out[5] = 1
|
|
15
|
+
out[6] = 0
|
|
16
|
+
out[7] = 0
|
|
17
|
+
out[8] = 0
|
|
18
|
+
out[9] = 0
|
|
19
|
+
out[10] = 1
|
|
20
|
+
out[11] = 0
|
|
21
|
+
out[12] = 0
|
|
22
|
+
out[13] = 0
|
|
23
|
+
out[14] = 0
|
|
24
|
+
out[15] = 1
|
|
25
|
+
return out
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = identity
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const { identity } = require('./index')
|
|
3
|
+
|
|
4
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
5
|
+
|
|
6
|
+
test('mat4: identity() called with one parameters should update a mat4 with correct values', (t) => {
|
|
7
|
+
const obs1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
8
|
+
const ret1 = identity(obs1)
|
|
9
|
+
t.true(compareVectors(obs1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
10
|
+
t.true(compareVectors(ret1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))
|
|
11
|
+
t.is(obs1, ret1)
|
|
12
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { default as add } from './add'
|
|
2
|
+
export { default as clone } from './clone'
|
|
3
|
+
export { default as copy } from './copy'
|
|
4
|
+
export { default as create } from './create'
|
|
5
|
+
export { default as equals } from './equals'
|
|
6
|
+
export { default as fromRotation } from './fromRotation'
|
|
7
|
+
export { default as fromScaling } from './fromScaling'
|
|
8
|
+
export { default as fromTaitBryanRotation } from './fromTaitBryanRotation'
|
|
9
|
+
export { default as fromTranslation } from './fromTranslation'
|
|
10
|
+
export { default as fromValues } from './fromValues'
|
|
11
|
+
export { default as fromXRotation } from './fromXRotation'
|
|
12
|
+
export { default as fromYRotation } from './fromYRotation'
|
|
13
|
+
export { default as fromZRotation } from './fromZRotation'
|
|
14
|
+
export { default as identity } from './identity'
|
|
15
|
+
export { default as isIdentity } from './isIdentity'
|
|
16
|
+
export { default as isMirroring } from './isMirroring'
|
|
17
|
+
export { default as mirrorByPlane } from './mirrorByPlane'
|
|
18
|
+
export { default as multiply } from './multiply'
|
|
19
|
+
export { default as rotate } from './rotate'
|
|
20
|
+
export { default as rotateX } from './rotateX'
|
|
21
|
+
export { default as rotateY } from './rotateY'
|
|
22
|
+
export { default as rotateZ } from './rotateZ'
|
|
23
|
+
export { default as scale } from './scale'
|
|
24
|
+
export { default as subtract } from './subtract'
|
|
25
|
+
export { default as toString } from './toString'
|
|
26
|
+
export { default as translate } from './translate'
|
|
27
|
+
|
|
28
|
+
export { default as Mat4 } from './type'
|
|
29
|
+
export as namespace mat4
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a 4x4 matrix which is column-major (when typed out it looks row-major).
|
|
3
|
+
* @see {@link mat4} for data structure information.
|
|
4
|
+
* @module modeling/maths/mat4
|
|
5
|
+
*/
|
|
6
|
+
module.exports = {
|
|
7
|
+
add: require('./add'),
|
|
8
|
+
clone: require('./clone'),
|
|
9
|
+
copy: require('./copy'),
|
|
10
|
+
create: require('./create'),
|
|
11
|
+
invert: require('./invert'),
|
|
12
|
+
equals: require('./equals'),
|
|
13
|
+
fromRotation: require('./fromRotation'),
|
|
14
|
+
fromScaling: require('./fromScaling'),
|
|
15
|
+
fromTaitBryanRotation: require('./fromTaitBryanRotation'),
|
|
16
|
+
fromTranslation: require('./fromTranslation'),
|
|
17
|
+
fromValues: require('./fromValues'),
|
|
18
|
+
fromVectorRotation: require('./fromVectorRotation'),
|
|
19
|
+
fromXRotation: require('./fromXRotation'),
|
|
20
|
+
fromYRotation: require('./fromYRotation'),
|
|
21
|
+
fromZRotation: require('./fromZRotation'),
|
|
22
|
+
identity: require('./identity'),
|
|
23
|
+
isIdentity: require('./isIdentity'),
|
|
24
|
+
isOnlyTransformScale: require('./isOnlyTransformScale'),
|
|
25
|
+
isMirroring: require('./isMirroring'),
|
|
26
|
+
mirrorByPlane: require('./mirrorByPlane'),
|
|
27
|
+
multiply: require('./multiply'),
|
|
28
|
+
rotate: require('./rotate'),
|
|
29
|
+
rotateX: require('./rotateX'),
|
|
30
|
+
rotateY: require('./rotateY'),
|
|
31
|
+
rotateZ: require('./rotateZ'),
|
|
32
|
+
scale: require('./scale'),
|
|
33
|
+
subtract: require('./subtract'),
|
|
34
|
+
toString: require('./toString'),
|
|
35
|
+
translate: require('./translate')
|
|
36
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a invert copy of the given matrix.
|
|
3
|
+
* @author Julian Lloyd
|
|
4
|
+
* code from https://github.com/jlmakes/rematrix/blob/master/src/index.js
|
|
5
|
+
*
|
|
6
|
+
* @param {mat4} out - receiving matrix
|
|
7
|
+
* @param {mat4} matrix - matrix to invert
|
|
8
|
+
* @returns {mat4} out
|
|
9
|
+
* @alias module:modeling/maths/mat4.invert
|
|
10
|
+
*/
|
|
11
|
+
const invert = (out, matrix) => {
|
|
12
|
+
const a00 = matrix[0]
|
|
13
|
+
const a01 = matrix[1]
|
|
14
|
+
const a02 = matrix[2]
|
|
15
|
+
const a03 = matrix[3]
|
|
16
|
+
const a10 = matrix[4]
|
|
17
|
+
const a11 = matrix[5]
|
|
18
|
+
const a12 = matrix[6]
|
|
19
|
+
const a13 = matrix[7]
|
|
20
|
+
const a20 = matrix[8]
|
|
21
|
+
const a21 = matrix[9]
|
|
22
|
+
const a22 = matrix[10]
|
|
23
|
+
const a23 = matrix[11]
|
|
24
|
+
const a30 = matrix[12]
|
|
25
|
+
const a31 = matrix[13]
|
|
26
|
+
const a32 = matrix[14]
|
|
27
|
+
const a33 = matrix[15]
|
|
28
|
+
|
|
29
|
+
const b00 = a00 * a11 - a01 * a10
|
|
30
|
+
const b01 = a00 * a12 - a02 * a10
|
|
31
|
+
const b02 = a00 * a13 - a03 * a10
|
|
32
|
+
const b03 = a01 * a12 - a02 * a11
|
|
33
|
+
const b04 = a01 * a13 - a03 * a11
|
|
34
|
+
const b05 = a02 * a13 - a03 * a12
|
|
35
|
+
const b06 = a20 * a31 - a21 * a30
|
|
36
|
+
const b07 = a20 * a32 - a22 * a30
|
|
37
|
+
const b08 = a20 * a33 - a23 * a30
|
|
38
|
+
const b09 = a21 * a32 - a22 * a31
|
|
39
|
+
const b10 = a21 * a33 - a23 * a31
|
|
40
|
+
const b11 = a22 * a33 - a23 * a32
|
|
41
|
+
|
|
42
|
+
// Calculate the determinant
|
|
43
|
+
let det =
|
|
44
|
+
b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06
|
|
45
|
+
|
|
46
|
+
if (!det) {
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
det = 1.0 / det
|
|
50
|
+
|
|
51
|
+
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det
|
|
52
|
+
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det
|
|
53
|
+
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det
|
|
54
|
+
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det
|
|
55
|
+
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det
|
|
56
|
+
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det
|
|
57
|
+
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det
|
|
58
|
+
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det
|
|
59
|
+
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det
|
|
60
|
+
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det
|
|
61
|
+
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det
|
|
62
|
+
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det
|
|
63
|
+
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det
|
|
64
|
+
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det
|
|
65
|
+
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det
|
|
66
|
+
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det
|
|
67
|
+
|
|
68
|
+
return out
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = invert
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const { TAU } = require('../constants')
|
|
4
|
+
const vec3 = require('../vec3/index')
|
|
5
|
+
|
|
6
|
+
const { create, invert, fromTranslation, fromXRotation } = require('./index')
|
|
7
|
+
|
|
8
|
+
const { compareVectors } = require('../../../test/helpers/index')
|
|
9
|
+
|
|
10
|
+
test('mat4: invert() translate ', (t) => {
|
|
11
|
+
const matrix = fromTranslation(create(), [10, 10, 0])
|
|
12
|
+
const matrixInv = invert(create(), matrix)
|
|
13
|
+
|
|
14
|
+
const vec1 = [0, 0, 0]
|
|
15
|
+
const vec2 = vec3.transform([0, 0, 0], vec1, matrix)
|
|
16
|
+
t.true(compareVectors(vec2, [10, 10, 0]))
|
|
17
|
+
|
|
18
|
+
const vec2back = vec3.transform([0, 0, 0], vec2, matrixInv)
|
|
19
|
+
t.true(compareVectors(vec2back, vec1))
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('mat4: invert() rotate ', (t) => {
|
|
23
|
+
const matrix = fromXRotation(create(), TAU / 4)
|
|
24
|
+
const matrixInv = invert(create(), matrix)
|
|
25
|
+
|
|
26
|
+
const vec1 = [10, 10, 10]
|
|
27
|
+
const vec2 = vec3.transform([0, 0, 0], vec1, matrix)
|
|
28
|
+
t.true(compareVectors(vec2, [10, -10, 10]))
|
|
29
|
+
|
|
30
|
+
const vec2back = vec3.transform([0, 0, 0], vec2, matrixInv)
|
|
31
|
+
t.true(compareVectors(vec2back, vec1))
|
|
32
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine whether the given matrix is the identity transform.
|
|
3
|
+
* This is equivalent to (but much faster than):
|
|
4
|
+
*
|
|
5
|
+
* mat4.equals(mat4.create(), matrix)
|
|
6
|
+
*
|
|
7
|
+
* @param {mat4} matrix - the matrix
|
|
8
|
+
* @returns {Boolean} true if matrix is the identity transform
|
|
9
|
+
* @alias module:modeling/maths/mat4.isIdentity
|
|
10
|
+
* @example
|
|
11
|
+
* if (mat4.isIdentity(mymatrix)) ...
|
|
12
|
+
*/
|
|
13
|
+
const isIdentity = (matrix) => (
|
|
14
|
+
matrix[0] === 1 && matrix[1] === 0 && matrix[2] === 0 && matrix[3] === 0 &&
|
|
15
|
+
matrix[4] === 0 && matrix[5] === 1 && matrix[6] === 0 && matrix[7] === 0 &&
|
|
16
|
+
matrix[8] === 0 && matrix[9] === 0 && matrix[10] === 1 && matrix[11] === 0 &&
|
|
17
|
+
matrix[12] === 0 && matrix[13] === 0 && matrix[14] === 0 && matrix[15] === 1
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
module.exports = isIdentity
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const { isIdentity, create, fromTranslation } = require('./index')
|
|
4
|
+
|
|
5
|
+
test('mat4: isIdentity() should return correct values', (t) => {
|
|
6
|
+
const identity = create() // identity matrix
|
|
7
|
+
t.true(isIdentity(identity))
|
|
8
|
+
|
|
9
|
+
const notidentity = fromTranslation(create(), [5, 5, 5])
|
|
10
|
+
t.false(isIdentity(notidentity))
|
|
11
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine whether the given matrix is a mirroring transformation.
|
|
3
|
+
*
|
|
4
|
+
* @param {mat4} matrix - matrix of reference
|
|
5
|
+
* @returns {Boolean} true if matrix is a mirroring transformation
|
|
6
|
+
* @alias module:modeling/maths/mat4.isMirroring
|
|
7
|
+
*/
|
|
8
|
+
const isMirroring = (matrix) => {
|
|
9
|
+
// const xVector = [matrix[0], matrix[4], matrix[8]]
|
|
10
|
+
// const yVector = [matrix[1], matrix[5], matrix[9]]
|
|
11
|
+
// const zVector = [matrix[2], matrix[6], matrix[10]]
|
|
12
|
+
|
|
13
|
+
// for a true orthogonal, non-mirrored base, xVector.cross(yVector) == zVector
|
|
14
|
+
// If they have an opposite direction then we are mirroring
|
|
15
|
+
// calcuate xVector.cross(yVector)
|
|
16
|
+
const x = matrix[4] * matrix[9] - matrix[8] * matrix[5]
|
|
17
|
+
const y = matrix[8] * matrix[1] - matrix[0] * matrix[9]
|
|
18
|
+
const z = matrix[0] * matrix[5] - matrix[4] * matrix[1]
|
|
19
|
+
// calcualte dot(cross, zVector)
|
|
20
|
+
const d = x * matrix[2] + y * matrix[6] + z * matrix[10]
|
|
21
|
+
return (d < 0)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = isMirroring
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const plane = require('../plane')
|
|
4
|
+
|
|
5
|
+
const { isMirroring, fromScaling, create, mirrorByPlane, rotate, scale, translate } = require('./index')
|
|
6
|
+
|
|
7
|
+
test('mat4: isMirroring() should determine correctly', (t) => {
|
|
8
|
+
let matrix = create()
|
|
9
|
+
t.false(isMirroring(matrix))
|
|
10
|
+
|
|
11
|
+
matrix = fromScaling(create(), [2, 4, 6])
|
|
12
|
+
t.false(isMirroring(matrix))
|
|
13
|
+
|
|
14
|
+
const planeX = plane.fromPoints(plane.create(), [0, 0, 0], [0, 1, 1], [0, 1, 0])
|
|
15
|
+
const planeY = plane.fromPoints(plane.create(), [0, 0, 0], [1, 0, 0], [1, 0, 1])
|
|
16
|
+
const planeZ = plane.fromPoints(plane.create(), [0, 0, 0], [1, 0, 0], [1, 1, 0])
|
|
17
|
+
|
|
18
|
+
matrix = mirrorByPlane(create(), planeX)
|
|
19
|
+
t.true(isMirroring(matrix))
|
|
20
|
+
|
|
21
|
+
matrix = mirrorByPlane(create(), planeY)
|
|
22
|
+
t.true(isMirroring(matrix))
|
|
23
|
+
|
|
24
|
+
matrix = mirrorByPlane(create(), planeZ)
|
|
25
|
+
t.true(isMirroring(matrix))
|
|
26
|
+
|
|
27
|
+
// additional transforms
|
|
28
|
+
const rotation = 90 * 0.017453292519943295
|
|
29
|
+
matrix = rotate(matrix, matrix, rotation, [0, 0, 1])
|
|
30
|
+
t.true(isMirroring(matrix))
|
|
31
|
+
|
|
32
|
+
matrix = scale(matrix, matrix, [0.5, 2, 5])
|
|
33
|
+
t.true(isMirroring(matrix))
|
|
34
|
+
|
|
35
|
+
matrix = translate(matrix, matrix, [2, -3, 600])
|
|
36
|
+
t.true(isMirroring(matrix))
|
|
37
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Determine whether the given matrix is only translate and/or scale.
|
|
4
|
+
* This code returns true for TAU / 2 rotation as it can be interpreted as scale.
|
|
5
|
+
*
|
|
6
|
+
* @param {mat4} matrix - the matrix
|
|
7
|
+
* @returns {Boolean} true if matrix is for translate and/or scale
|
|
8
|
+
* @alias module:modeling/maths/mat4.isOnlyTransformScale
|
|
9
|
+
*/
|
|
10
|
+
const isOnlyTransformScale = (matrix) => (
|
|
11
|
+
|
|
12
|
+
// TODO check if it is worth the effort to add recognition of 90 deg rotations
|
|
13
|
+
|
|
14
|
+
isZero(matrix[1]) && isZero(matrix[2]) && isZero(matrix[3]) &&
|
|
15
|
+
isZero(matrix[4]) && isZero(matrix[6]) && isZero(matrix[7]) &&
|
|
16
|
+
isZero(matrix[8]) && isZero(matrix[9]) && isZero(matrix[11]) &&
|
|
17
|
+
matrix[15] === 1
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const isZero = (num) => Math.abs(num) < Number.EPSILON
|
|
21
|
+
|
|
22
|
+
module.exports = isOnlyTransformScale
|