@cesium/engine 24.0.0 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/Workers/{chunk-NKT5K3K3.js → chunk-35H3UBIO.js} +13 -12
- package/Build/Workers/{chunk-5A2SW66E.js → chunk-3LSD7OOA.js} +16 -16
- package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-3RFFPH4M.js} +1 -1
- package/Build/Workers/{chunk-EDXL4W76.js → chunk-3TKLDHV3.js} +2 -2
- package/Build/Workers/{chunk-GQUNK2XC.js → chunk-3VDDRF2E.js} +14 -14
- package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-3XY3MVPG.js} +4 -4
- package/Build/Workers/{chunk-A47HVBC5.js → chunk-4GF4MVPY.js} +7 -7
- package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-4MTRQFJP.js} +3 -2
- package/Build/Workers/{chunk-N65BAKSH.js → chunk-4QQXGTCE.js} +8 -8
- package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-4XXHJI6Y.js} +17 -17
- package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-5T6QQAJW.js} +3 -2
- package/Build/Workers/{chunk-UIGVOKKI.js → chunk-6SDGQI27.js} +3 -2
- package/Build/Workers/{chunk-ILMFADZA.js → chunk-77RL3MBD.js} +6 -5
- package/Build/Workers/{chunk-2N4KDHS3.js → chunk-7LSFAEWF.js} +12 -11
- package/Build/Workers/{chunk-44EMEGKW.js → chunk-A7A433MD.js} +5 -5
- package/Build/Workers/{chunk-J6AW5YHS.js → chunk-A7ZBMVFS.js} +14 -14
- package/Build/Workers/{chunk-XJRBB253.js → chunk-ACFFCHHZ.js} +11 -11
- package/Build/Workers/{chunk-MKM27KGV.js → chunk-AEAVLYPS.js} +2 -2
- package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-AWFZHD2B.js} +4 -4
- package/Build/Workers/{chunk-UQU4RXLT.js → chunk-BTX2NL3P.js} +50 -45
- package/Build/Workers/{chunk-4TIG36AW.js → chunk-BVAIWR7O.js} +12 -12
- package/Build/Workers/chunk-CKQP3DSS.js +973 -0
- package/Build/Workers/{chunk-VLDEUTOP.js → chunk-CZ23Y3RM.js} +2 -2
- package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DFEI5MAV.js} +7 -7
- package/Build/Workers/{chunk-AJLTU6PF.js → chunk-DH26SNAB.js} +4 -1
- package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-DYT5NR6P.js} +3 -3
- package/Build/Workers/{chunk-63SIWPLS.js → chunk-EZARA5FJ.js} +13 -13
- package/Build/Workers/{chunk-AMIHNSST.js → chunk-FIBS5S7R.js} +2 -2
- package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-FVLVVOBQ.js} +10 -10
- package/Build/Workers/{chunk-XY6HMDGI.js → chunk-GL7DNVUS.js} +5 -5
- package/Build/Workers/{chunk-6WLHJFD3.js → chunk-GPIGURCG.js} +59 -32
- package/Build/Workers/{chunk-B6SCUUFP.js → chunk-H2A4USJR.js} +10 -10
- package/Build/Workers/chunk-HSVQATK2.js +147 -0
- package/Build/Workers/{chunk-72VYSVEW.js → chunk-HVMG6AG4.js} +11 -10
- package/Build/Workers/{chunk-LXMCPFFS.js → chunk-I3A6DXYZ.js} +4 -4
- package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-ITD2IN7N.js} +2 -2
- package/Build/Workers/{chunk-RQNJD3O4.js → chunk-J3OFS2RD.js} +12 -12
- package/Build/Workers/{chunk-C6P4IG5P.js → chunk-J647NNZW.js} +6 -6
- package/Build/Workers/{chunk-7X322WP2.js → chunk-J7KQEKPK.js} +13 -13
- package/Build/Workers/{chunk-7O5XJTVE.js → chunk-K6NFIRFB.js} +5 -5
- package/Build/Workers/{chunk-AF3MU2RL.js → chunk-LH5SF3XV.js} +7 -6
- package/Build/Workers/{chunk-GOQBUCXH.js → chunk-ND3NTTOF.js} +708 -430
- package/Build/Workers/chunk-QO2CGXMP.js +2342 -0
- package/Build/Workers/chunk-QSDY4NS7.js +1287 -0
- package/Build/Workers/chunk-QXNQQYPV.js +3201 -0
- package/Build/Workers/{chunk-YAOZMOFL.js → chunk-ST2UWDUU.js} +5 -5
- package/Build/Workers/{chunk-PVV64VFW.js → chunk-TA777BGS.js} +3 -2
- package/Build/Workers/{chunk-ISY4EZCA.js → chunk-TAI4HLII.js} +4 -4
- package/Build/Workers/{chunk-JCI63T3K.js → chunk-URUCCIPS.js} +6 -6
- package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-VQKLRBIK.js} +7 -7
- package/Build/Workers/{chunk-6MPGQEHA.js → chunk-WC57YYBN.js} +2 -2
- package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-WN6P5UDH.js} +12 -12
- package/Build/Workers/{chunk-LIB2H534.js → chunk-WNN5D4W3.js} +12 -11
- package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-WTQGE7Q6.js} +17 -17
- package/Build/Workers/{chunk-YJZGW74L.js → chunk-WUBKZFF6.js} +2213 -1349
- package/Build/Workers/{chunk-7TYLCBGK.js → chunk-ZAPOS52G.js} +12 -10
- package/Build/Workers/{chunk-6RMS4S72.js → chunk-ZCCIIBZT.js} +6 -6
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +175 -118
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +24 -23
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +12 -9
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/ArcType.js +6 -1
- package/Source/Core/ArticulationStageType.js +5 -1
- package/Source/Core/AssociativeArray.js +100 -94
- package/Source/Core/BoundingSphere.js +1296 -1300
- package/Source/Core/Cartesian3.js +1 -2
- package/Source/Core/Cartographic.js +257 -249
- package/Source/Core/ClockRange.js +6 -1
- package/Source/Core/ClockStep.js +6 -1
- package/Source/Core/Color.js +844 -835
- package/Source/Core/ComponentDatatype.js +4 -1
- package/Source/Core/CornerType.js +6 -1
- package/Source/Core/Credit.js +121 -124
- package/Source/Core/Ellipsoid.js +637 -660
- package/Source/Core/ExtrapolationType.js +6 -1
- package/Source/Core/GeocodeType.js +6 -1
- package/Source/Core/GeographicProjection.js +74 -74
- package/Source/Core/GeographicTilingScheme.js +179 -198
- package/Source/Core/GeometryOffsetAttribute.js +7 -1
- package/Source/Core/GeometryType.js +7 -1
- package/Source/Core/HeightmapEncoding.js +6 -1
- package/Source/Core/Iau2006XysData.js +24 -13
- package/Source/Core/IndexDatatype.js +3 -1
- package/Source/Core/InterpolationType.js +5 -1
- package/Source/Core/Intersect.js +6 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +5 -1
- package/Source/Core/JulianDate.js +850 -848
- package/Source/Core/KeyboardEventModifier.js +6 -1
- package/Source/Core/MapProjection.js +39 -44
- package/Source/Core/Matrix2.js +906 -893
- package/Source/Core/Matrix3.js +1643 -1575
- package/Source/Core/Matrix4.js +2903 -2872
- package/Source/Core/PixelFormat.js +3 -1
- package/Source/Core/PrimitiveType.js +11 -1
- package/Source/Core/Ray.js +62 -60
- package/Source/Core/Rectangle.js +913 -904
- package/Source/Core/ReferenceFrame.js +6 -1
- package/Source/Core/RequestScheduler.js +8 -3
- package/Source/Core/RequestState.js +6 -1
- package/Source/Core/RequestType.js +6 -1
- package/Source/Core/ScreenSpaceEventType.js +6 -1
- package/Source/Core/TerrainQuantization.js +6 -1
- package/Source/Core/TilingScheme.js +100 -98
- package/Source/Core/TimeConstants.js +6 -1
- package/Source/Core/TimeStandard.js +6 -1
- package/Source/Core/TrackingReferenceFrame.js +6 -1
- package/Source/Core/Visibility.js +6 -1
- package/Source/Core/VulkanConstants.js +6 -1
- package/Source/Core/WebGLConstants.js +6 -1
- package/Source/Core/WebMercatorProjection.js +108 -109
- package/Source/Core/WebMercatorTilingScheme.js +246 -242
- package/Source/Core/WindingOrder.js +3 -1
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
- package/Source/DataSources/StripeOrientation.js +6 -1
- package/Source/Renderer/BufferUsage.js +20 -9
- package/Source/Renderer/Context.js +2 -29
- package/Source/Renderer/DrawCommand.js +435 -403
- package/Source/Renderer/MipmapHint.js +5 -1
- package/Source/Renderer/Pass.js +7 -1
- package/Source/Renderer/PickId.js +44 -0
- package/Source/Renderer/PixelDatatype.js +3 -1
- package/Source/Renderer/RenderbufferFormat.js +5 -1
- package/Source/Renderer/ShaderDestination.js +4 -1
- package/Source/Renderer/TextureMagnificationFilter.js +3 -1
- package/Source/Renderer/TextureMinificationFilter.js +3 -1
- package/Source/Renderer/TextureWrap.js +5 -1
- package/Source/Scene/AlphaMode.js +5 -1
- package/Source/Scene/ArcGisBaseMapType.js +6 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/AttributeType.js +3 -1
- package/Source/Scene/Axis.js +3 -1
- package/Source/Scene/BingMapsStyle.js +6 -1
- package/Source/Scene/BlendEquation.js +6 -1
- package/Source/Scene/BlendFunction.js +6 -1
- package/Source/Scene/BlendOption.js +6 -1
- package/Source/Scene/BlendingState.js +6 -1
- package/Source/Scene/BufferLoader.js +0 -2
- package/Source/Scene/BufferPointCollection.js +4 -1
- package/Source/Scene/BufferPolygonCollection.js +3 -1
- package/Source/Scene/BufferPolylineCollection.js +3 -1
- package/Source/Scene/BufferPrimitiveCollection.js +140 -24
- package/Source/Scene/CameraEventType.js +6 -1
- package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
- package/Source/Scene/Cesium3DTileContentState.js +6 -1
- package/Source/Scene/Cesium3DTileContentType.js +3 -1
- package/Source/Scene/Cesium3DTileFeature.js +289 -306
- package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
- package/Source/Scene/Cesium3DTilePass.js +5 -1
- package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
- package/Source/Scene/Cesium3DTileRefine.js +6 -1
- package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/ClassificationType.js +3 -1
- package/Source/Scene/CloudType.js +3 -1
- package/Source/Scene/ColorBlendMode.js +4 -1
- package/Source/Scene/CullFace.js +6 -1
- package/Source/Scene/DepthFunction.js +6 -1
- package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
- package/Source/Scene/EquirectangularPanorama.js +1 -0
- package/Source/Scene/ExpressionNodeType.js +6 -1
- package/Source/Scene/GltfBufferViewLoader.js +0 -2
- package/Source/Scene/GltfDracoLoader.js +0 -2
- package/Source/Scene/GltfImageLoader.js +0 -3
- package/Source/Scene/GltfIndexBufferLoader.js +0 -4
- package/Source/Scene/GltfJsonLoader.js +0 -2
- package/Source/Scene/GltfLoader.js +0 -5
- package/Source/Scene/GltfLoaderUtil.js +14 -0
- package/Source/Scene/GltfSpzLoader.js +0 -2
- package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
- package/Source/Scene/GltfTextureLoader.js +0 -2
- package/Source/Scene/GltfVertexBufferLoader.js +0 -4
- package/Source/Scene/HeightReference.js +5 -1
- package/Source/Scene/HorizontalOrigin.js +6 -1
- package/Source/Scene/ImageryProvider.js +1 -1
- package/Source/Scene/ImageryState.js +6 -1
- package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
- package/Source/Scene/InstanceAttributeSemantic.js +3 -1
- package/Source/Scene/IonWorldImageryStyle.js +6 -1
- package/Source/Scene/JobType.js +6 -1
- package/Source/Scene/LabelStyle.js +6 -1
- package/Source/Scene/MapMode2D.js +6 -1
- package/Source/Scene/MetadataComponentType.js +3 -1
- package/Source/Scene/MetadataSchemaLoader.js +0 -2
- package/Source/Scene/MetadataSemantic.js +6 -2
- package/Source/Scene/MetadataType.js +3 -1
- package/Source/Scene/Model/B3dmLoader.js +0 -3
- package/Source/Scene/Model/CustomShaderMode.js +3 -1
- package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +44 -71
- package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
- package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
- package/Source/Scene/Model/GeoJsonLoader.js +0 -2
- package/Source/Scene/Model/I3dmLoader.js +0 -3
- package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
- package/Source/Scene/Model/LightingModel.js +5 -1
- package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
- package/Source/Scene/Model/ModelReader.js +474 -3
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
- package/Source/Scene/Model/ModelType.js +3 -1
- package/Source/Scene/Model/PntsLoader.js +4 -3
- package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
- package/Source/Scene/Model/UniformType.js +5 -1
- package/Source/Scene/Model/VaryingType.js +5 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +73 -28
- package/Source/Scene/Model/pickModel.js +94 -299
- package/Source/Scene/ModelAnimationLoop.js +6 -1
- package/Source/Scene/ModelAnimationState.js +6 -1
- package/Source/Scene/ModelComponents.js +8 -1
- package/Source/Scene/PrimitiveState.js +7 -1
- package/Source/Scene/QuadtreeOccluders.js +20 -15
- package/Source/Scene/QuadtreeTile.js +547 -541
- package/Source/Scene/QuadtreeTileLoadState.js +6 -1
- package/Source/Scene/QuadtreeTileProvider.js +159 -175
- package/Source/Scene/ResourceLoader.js +0 -1
- package/Source/Scene/ResourceLoaderState.js +7 -1
- package/Source/Scene/SceneMode.js +4 -1
- package/Source/Scene/ShadowMode.js +3 -1
- package/Source/Scene/SkyBox.js +1 -1
- package/Source/Scene/SplitDirection.js +6 -1
- package/Source/Scene/StencilFunction.js +6 -1
- package/Source/Scene/StencilOperation.js +6 -1
- package/Source/Scene/TerrainState.js +7 -1
- package/Source/Scene/TileState.js +7 -1
- package/Source/Scene/Tonemapper.js +5 -1
- package/Source/Scene/VectorGltf3DTileContent.js +72 -51
- package/Source/Scene/VertexAttributeSemantic.js +3 -1
- package/Source/Scene/VerticalOrigin.js +6 -1
- package/Source/Scene/VoxelBoxShape.js +12 -6
- package/Source/Scene/VoxelContent.js +2 -0
- package/Source/Scene/VoxelCylinderShape.js +39 -38
- package/Source/Scene/VoxelEllipsoidShape.js +46 -96
- package/Source/Scene/VoxelMetadataOrder.js +6 -1
- package/Source/Scene/VoxelProvider.js +1 -0
- package/Source/Scene/VoxelShapeType.js +3 -1
- package/Source/Scene/renderBufferPointCollection.js +17 -66
- package/Source/Scene/renderBufferPolygonCollection.js +21 -68
- package/Source/Scene/renderBufferPolylineCollection.js +22 -73
- package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
- package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
- package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
- package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
- package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
- package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
- package/Source/Shaders/Model/MaterialStageFS.js +46 -20
- package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
- package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
- package/Source/Widget/CesiumWidget.js +11 -4
- package/index.d.ts +343 -309
- package/index.js +443 -438
- package/package.json +2 -2
- package/Build/Workers/chunk-DVB56LG7.js +0 -114
- package/Build/Workers/chunk-HKUES6UG.js +0 -2357
- package/Build/Workers/chunk-HRHRYFHS.js +0 -940
- package/Build/Workers/chunk-KLPGTXS3.js +0 -642
- package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
package/Source/Core/Matrix3.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import Cartesian3 from "./Cartesian3.js";
|
|
2
4
|
import Check from "./Check.js";
|
|
3
5
|
import defined from "./defined.js";
|
|
4
6
|
import DeveloperError from "./DeveloperError.js";
|
|
5
7
|
import CesiumMath from "./Math.js";
|
|
6
8
|
|
|
9
|
+
/** @import Quaternion from "./Quaternion.js"; */
|
|
10
|
+
/** @import HeadingPitchRoll from "./HeadingPitchRoll.js"; */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} EigenDecompositionResult
|
|
14
|
+
* @property {Matrix3} [unitary]
|
|
15
|
+
* @property {Matrix3} [diagonal]
|
|
16
|
+
*/
|
|
17
|
+
|
|
7
18
|
/**
|
|
8
19
|
* A 3x3 matrix, indexable as a column-major order array.
|
|
9
20
|
* Constructor parameters are in row-major order for code readability.
|
|
10
|
-
* @alias Matrix3
|
|
11
|
-
* @constructor
|
|
12
|
-
* @implements {ArrayLike<number>}
|
|
13
21
|
*
|
|
14
|
-
* @
|
|
15
|
-
* @param {number} [column1Row0=0.0] The value for column 1, row 0.
|
|
16
|
-
* @param {number} [column2Row0=0.0] The value for column 2, row 0.
|
|
17
|
-
* @param {number} [column0Row1=0.0] The value for column 0, row 1.
|
|
18
|
-
* @param {number} [column1Row1=0.0] The value for column 1, row 1.
|
|
19
|
-
* @param {number} [column2Row1=0.0] The value for column 2, row 1.
|
|
20
|
-
* @param {number} [column0Row2=0.0] The value for column 0, row 2.
|
|
21
|
-
* @param {number} [column1Row2=0.0] The value for column 1, row 2.
|
|
22
|
-
* @param {number} [column2Row2=0.0] The value for column 2, row 2.
|
|
22
|
+
* @implements {ArrayLike<number>}
|
|
23
23
|
*
|
|
24
24
|
* @see Matrix3.fromArray
|
|
25
25
|
* @see Matrix3.fromColumnMajorArray
|
|
@@ -35,1635 +35,1662 @@ import CesiumMath from "./Math.js";
|
|
|
35
35
|
* @see Matrix2
|
|
36
36
|
* @see Matrix4
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
39
|
+
class Matrix3 {
|
|
40
|
+
/**
|
|
41
|
+
* @param {number} [column0Row0=0.0] The value for column 0, row 0.
|
|
42
|
+
* @param {number} [column1Row0=0.0] The value for column 1, row 0.
|
|
43
|
+
* @param {number} [column2Row0=0.0] The value for column 2, row 0.
|
|
44
|
+
* @param {number} [column0Row1=0.0] The value for column 0, row 1.
|
|
45
|
+
* @param {number} [column1Row1=0.0] The value for column 1, row 1.
|
|
46
|
+
* @param {number} [column2Row1=0.0] The value for column 2, row 1.
|
|
47
|
+
* @param {number} [column0Row2=0.0] The value for column 0, row 2.
|
|
48
|
+
* @param {number} [column1Row2=0.0] The value for column 1, row 2.
|
|
49
|
+
* @param {number} [column2Row2=0.0] The value for column 2, row 2.
|
|
50
|
+
*/
|
|
51
|
+
constructor(
|
|
52
|
+
column0Row0,
|
|
53
|
+
column1Row0,
|
|
54
|
+
column2Row0,
|
|
55
|
+
column0Row1,
|
|
56
|
+
column1Row1,
|
|
57
|
+
column2Row1,
|
|
58
|
+
column0Row2,
|
|
59
|
+
column1Row2,
|
|
60
|
+
column2Row2,
|
|
61
|
+
) {
|
|
62
|
+
this[0] = column0Row0 ?? 0.0;
|
|
63
|
+
this[1] = column0Row1 ?? 0.0;
|
|
64
|
+
this[2] = column0Row2 ?? 0.0;
|
|
65
|
+
this[3] = column1Row0 ?? 0.0;
|
|
66
|
+
this[4] = column1Row1 ?? 0.0;
|
|
67
|
+
this[5] = column1Row2 ?? 0.0;
|
|
68
|
+
this[6] = column2Row0 ?? 0.0;
|
|
69
|
+
this[7] = column2Row1 ?? 0.0;
|
|
70
|
+
this[8] = column2Row2 ?? 0.0;
|
|
71
|
+
}
|
|
65
72
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
startingIndex = startingIndex ?? 0;
|
|
82
|
-
|
|
83
|
-
array[startingIndex++] = value[0];
|
|
84
|
-
array[startingIndex++] = value[1];
|
|
85
|
-
array[startingIndex++] = value[2];
|
|
86
|
-
array[startingIndex++] = value[3];
|
|
87
|
-
array[startingIndex++] = value[4];
|
|
88
|
-
array[startingIndex++] = value[5];
|
|
89
|
-
array[startingIndex++] = value[6];
|
|
90
|
-
array[startingIndex++] = value[7];
|
|
91
|
-
array[startingIndex++] = value[8];
|
|
92
|
-
|
|
93
|
-
return array;
|
|
94
|
-
};
|
|
73
|
+
/**
|
|
74
|
+
* Stores the provided instance into the provided array.
|
|
75
|
+
*
|
|
76
|
+
* @param {Matrix3} value The value to pack.
|
|
77
|
+
* @param {number[]} array The array to pack into.
|
|
78
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
79
|
+
*
|
|
80
|
+
* @returns {number[]} The array that was packed into
|
|
81
|
+
*/
|
|
82
|
+
static pack(value, array, startingIndex) {
|
|
83
|
+
//>>includeStart('debug', pragmas.debug);
|
|
84
|
+
Check.typeOf.object("value", value);
|
|
85
|
+
Check.defined("array", array);
|
|
86
|
+
//>>includeEnd('debug');
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
* Retrieves an instance from a packed array.
|
|
98
|
-
*
|
|
99
|
-
* @param {number[]} array The packed array.
|
|
100
|
-
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
101
|
-
* @param {Matrix3} [result] The object into which to store the result.
|
|
102
|
-
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
|
|
103
|
-
*/
|
|
104
|
-
Matrix3.unpack = function (array, startingIndex, result) {
|
|
105
|
-
//>>includeStart('debug', pragmas.debug);
|
|
106
|
-
Check.defined("array", array);
|
|
107
|
-
//>>includeEnd('debug');
|
|
88
|
+
startingIndex = startingIndex ?? 0;
|
|
108
89
|
|
|
109
|
-
|
|
90
|
+
array[startingIndex++] = value[0];
|
|
91
|
+
array[startingIndex++] = value[1];
|
|
92
|
+
array[startingIndex++] = value[2];
|
|
93
|
+
array[startingIndex++] = value[3];
|
|
94
|
+
array[startingIndex++] = value[4];
|
|
95
|
+
array[startingIndex++] = value[5];
|
|
96
|
+
array[startingIndex++] = value[6];
|
|
97
|
+
array[startingIndex++] = value[7];
|
|
98
|
+
array[startingIndex++] = value[8];
|
|
110
99
|
|
|
111
|
-
|
|
112
|
-
result = new Matrix3();
|
|
100
|
+
return array;
|
|
113
101
|
}
|
|
114
102
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return result;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Flattens an array of Matrix3s into an array of components. The components
|
|
129
|
-
* are stored in column-major order.
|
|
130
|
-
*
|
|
131
|
-
* @param {Matrix3[]} array The array of matrices to pack.
|
|
132
|
-
* @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 9 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 9) elements.
|
|
133
|
-
* @returns {number[]} The packed array.
|
|
134
|
-
*/
|
|
135
|
-
Matrix3.packArray = function (array, result) {
|
|
136
|
-
//>>includeStart('debug', pragmas.debug);
|
|
137
|
-
Check.defined("array", array);
|
|
138
|
-
//>>includeEnd('debug');
|
|
139
|
-
|
|
140
|
-
const length = array.length;
|
|
141
|
-
const resultLength = length * 9;
|
|
142
|
-
if (!defined(result)) {
|
|
143
|
-
result = new Array(resultLength);
|
|
144
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves an instance from a packed array.
|
|
105
|
+
*
|
|
106
|
+
* @param {number[]} array The packed array.
|
|
107
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
108
|
+
* @param {Matrix3} [result] The object into which to store the result.
|
|
109
|
+
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
|
|
110
|
+
*/
|
|
111
|
+
static unpack(array, startingIndex, result) {
|
|
145
112
|
//>>includeStart('debug', pragmas.debug);
|
|
146
|
-
|
|
147
|
-
"If result is a typed array, it must have exactly array.length * 9 elements",
|
|
148
|
-
);
|
|
113
|
+
Check.defined("array", array);
|
|
149
114
|
//>>includeEnd('debug');
|
|
150
|
-
} else if (result.length !== resultLength) {
|
|
151
|
-
result.length = resultLength;
|
|
152
|
-
}
|
|
153
115
|
|
|
154
|
-
|
|
155
|
-
Matrix3.pack(array[i], result, i * 9);
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
};
|
|
116
|
+
startingIndex = startingIndex ?? 0;
|
|
159
117
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* @param {number[]} array The array of components to unpack.
|
|
164
|
-
* @param {Matrix3[]} [result] The array onto which to store the result.
|
|
165
|
-
* @returns {Matrix3[]} The unpacked array.
|
|
166
|
-
*/
|
|
167
|
-
Matrix3.unpackArray = function (array, result) {
|
|
168
|
-
//>>includeStart('debug', pragmas.debug);
|
|
169
|
-
Check.defined("array", array);
|
|
170
|
-
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
|
|
171
|
-
if (array.length % 9 !== 0) {
|
|
172
|
-
throw new DeveloperError("array length must be a multiple of 9.");
|
|
173
|
-
}
|
|
174
|
-
//>>includeEnd('debug');
|
|
118
|
+
if (!defined(result)) {
|
|
119
|
+
result = new Matrix3();
|
|
120
|
+
}
|
|
175
121
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
result =
|
|
179
|
-
|
|
180
|
-
result
|
|
122
|
+
result[0] = array[startingIndex++];
|
|
123
|
+
result[1] = array[startingIndex++];
|
|
124
|
+
result[2] = array[startingIndex++];
|
|
125
|
+
result[3] = array[startingIndex++];
|
|
126
|
+
result[4] = array[startingIndex++];
|
|
127
|
+
result[5] = array[startingIndex++];
|
|
128
|
+
result[6] = array[startingIndex++];
|
|
129
|
+
result[7] = array[startingIndex++];
|
|
130
|
+
result[8] = array[startingIndex++];
|
|
131
|
+
return result;
|
|
181
132
|
}
|
|
182
133
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
134
|
+
/**
|
|
135
|
+
* Flattens an array of Matrix3s into an array of components. The components
|
|
136
|
+
* are stored in column-major order.
|
|
137
|
+
*
|
|
138
|
+
* @param {Matrix3[]} array The array of matrices to pack.
|
|
139
|
+
* @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 9 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 9) elements.
|
|
140
|
+
* @returns {number[]} The packed array.
|
|
141
|
+
*/
|
|
142
|
+
static packArray(array, result) {
|
|
143
|
+
//>>includeStart('debug', pragmas.debug);
|
|
144
|
+
Check.defined("array", array);
|
|
145
|
+
//>>includeEnd('debug');
|
|
189
146
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
matrix[5],
|
|
211
|
-
matrix[8],
|
|
212
|
-
);
|
|
147
|
+
const length = array.length;
|
|
148
|
+
const resultLength = length * 9;
|
|
149
|
+
if (!defined(result)) {
|
|
150
|
+
result = new Array(resultLength);
|
|
151
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires conditional TypedArray types.
|
|
152
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
153
|
+
//>>includeStart('debug', pragmas.debug);
|
|
154
|
+
throw new DeveloperError(
|
|
155
|
+
"If result is a typed array, it must have exactly array.length * 9 elements",
|
|
156
|
+
);
|
|
157
|
+
//>>includeEnd('debug');
|
|
158
|
+
} else if (result.length !== resultLength) {
|
|
159
|
+
/** @type {number[]} */ (result).length = resultLength;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
for (let i = 0; i < length; ++i) {
|
|
163
|
+
Matrix3.pack(array[i], result, i * 9);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return result;
|
|
213
167
|
}
|
|
214
|
-
result[0] = matrix[0];
|
|
215
|
-
result[1] = matrix[1];
|
|
216
|
-
result[2] = matrix[2];
|
|
217
|
-
result[3] = matrix[3];
|
|
218
|
-
result[4] = matrix[4];
|
|
219
|
-
result[5] = matrix[5];
|
|
220
|
-
result[6] = matrix[6];
|
|
221
|
-
result[7] = matrix[7];
|
|
222
|
-
result[8] = matrix[8];
|
|
223
|
-
return result;
|
|
224
|
-
};
|
|
225
168
|
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
* const v = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
|
|
242
|
-
* const m = Cesium.Matrix3.fromArray(v);
|
|
243
|
-
*
|
|
244
|
-
* // Create same Matrix3 with using an offset into an array
|
|
245
|
-
* const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
|
|
246
|
-
* const m2 = Cesium.Matrix3.fromArray(v2, 2);
|
|
247
|
-
*/
|
|
248
|
-
Matrix3.fromArray = Matrix3.unpack;
|
|
169
|
+
/**
|
|
170
|
+
* Unpacks an array of column-major matrix components into an array of Matrix3s.
|
|
171
|
+
*
|
|
172
|
+
* @param {number[]} array The array of components to unpack.
|
|
173
|
+
* @param {Matrix3[]} [result] The array onto which to store the result.
|
|
174
|
+
* @returns {Matrix3[]} The unpacked array.
|
|
175
|
+
*/
|
|
176
|
+
static unpackArray(array, result) {
|
|
177
|
+
//>>includeStart('debug', pragmas.debug);
|
|
178
|
+
Check.defined("array", array);
|
|
179
|
+
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
|
|
180
|
+
if (array.length % 9 !== 0) {
|
|
181
|
+
throw new DeveloperError("array length must be a multiple of 9.");
|
|
182
|
+
}
|
|
183
|
+
//>>includeEnd('debug');
|
|
249
184
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
*/
|
|
257
|
-
Matrix3.fromColumnMajorArray = function (values, result) {
|
|
258
|
-
//>>includeStart('debug', pragmas.debug);
|
|
259
|
-
Check.defined("values", values);
|
|
260
|
-
//>>includeEnd('debug');
|
|
185
|
+
const length = array.length;
|
|
186
|
+
if (!defined(result)) {
|
|
187
|
+
result = new Array(length / 9);
|
|
188
|
+
} else {
|
|
189
|
+
result.length = length / 9;
|
|
190
|
+
}
|
|
261
191
|
|
|
262
|
-
|
|
263
|
-
|
|
192
|
+
for (let i = 0; i < length; i += 9) {
|
|
193
|
+
const index = i / 9;
|
|
194
|
+
result[index] = Matrix3.unpack(array, i, result[index]);
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
264
198
|
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Duplicates a Matrix3 instance.
|
|
201
|
+
*
|
|
202
|
+
* @param {Matrix3} matrix The matrix to duplicate.
|
|
203
|
+
* @param {Matrix3} [result] The object onto which to store the result.
|
|
204
|
+
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)
|
|
205
|
+
*/
|
|
206
|
+
static clone(matrix, result) {
|
|
207
|
+
if (!defined(matrix)) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
if (!defined(result)) {
|
|
211
|
+
return new Matrix3(
|
|
212
|
+
matrix[0],
|
|
213
|
+
matrix[3],
|
|
214
|
+
matrix[6],
|
|
215
|
+
matrix[1],
|
|
216
|
+
matrix[4],
|
|
217
|
+
matrix[7],
|
|
218
|
+
matrix[2],
|
|
219
|
+
matrix[5],
|
|
220
|
+
matrix[8],
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
result[0] = matrix[0];
|
|
224
|
+
result[1] = matrix[1];
|
|
225
|
+
result[2] = matrix[2];
|
|
226
|
+
result[3] = matrix[3];
|
|
227
|
+
result[4] = matrix[4];
|
|
228
|
+
result[5] = matrix[5];
|
|
229
|
+
result[6] = matrix[6];
|
|
230
|
+
result[7] = matrix[7];
|
|
231
|
+
result[8] = matrix[8];
|
|
232
|
+
return result;
|
|
290
233
|
}
|
|
291
|
-
result[0] = values[0];
|
|
292
|
-
result[1] = values[3];
|
|
293
|
-
result[2] = values[6];
|
|
294
|
-
result[3] = values[1];
|
|
295
|
-
result[4] = values[4];
|
|
296
|
-
result[5] = values[7];
|
|
297
|
-
result[6] = values[2];
|
|
298
|
-
result[7] = values[5];
|
|
299
|
-
result[8] = values[8];
|
|
300
|
-
return result;
|
|
301
|
-
};
|
|
302
234
|
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const xz = quaternion.x * quaternion.z;
|
|
318
|
-
const xw = quaternion.x * quaternion.w;
|
|
319
|
-
const y2 = quaternion.y * quaternion.y;
|
|
320
|
-
const yz = quaternion.y * quaternion.z;
|
|
321
|
-
const yw = quaternion.y * quaternion.w;
|
|
322
|
-
const z2 = quaternion.z * quaternion.z;
|
|
323
|
-
const zw = quaternion.z * quaternion.w;
|
|
324
|
-
const w2 = quaternion.w * quaternion.w;
|
|
325
|
-
|
|
326
|
-
const m00 = x2 - y2 - z2 + w2;
|
|
327
|
-
const m01 = 2.0 * (xy - zw);
|
|
328
|
-
const m02 = 2.0 * (xz + yw);
|
|
329
|
-
|
|
330
|
-
const m10 = 2.0 * (xy + zw);
|
|
331
|
-
const m11 = -x2 + y2 - z2 + w2;
|
|
332
|
-
const m12 = 2.0 * (yz - xw);
|
|
333
|
-
|
|
334
|
-
const m20 = 2.0 * (xz - yw);
|
|
335
|
-
const m21 = 2.0 * (yz + xw);
|
|
336
|
-
const m22 = -x2 - y2 + z2 + w2;
|
|
337
|
-
|
|
338
|
-
if (!defined(result)) {
|
|
339
|
-
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
235
|
+
/**
|
|
236
|
+
* Creates a Matrix3 instance from a column-major order array.
|
|
237
|
+
*
|
|
238
|
+
* @param {number[]} values The column-major order array.
|
|
239
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
240
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
241
|
+
*/
|
|
242
|
+
static fromColumnMajorArray(values, result) {
|
|
243
|
+
//>>includeStart('debug', pragmas.debug);
|
|
244
|
+
Check.defined("values", values);
|
|
245
|
+
//>>includeEnd('debug');
|
|
246
|
+
|
|
247
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
248
|
+
return Matrix3.clone(values, result);
|
|
340
249
|
}
|
|
341
|
-
result[0] = m00;
|
|
342
|
-
result[1] = m10;
|
|
343
|
-
result[2] = m20;
|
|
344
|
-
result[3] = m01;
|
|
345
|
-
result[4] = m11;
|
|
346
|
-
result[5] = m21;
|
|
347
|
-
result[6] = m02;
|
|
348
|
-
result[7] = m12;
|
|
349
|
-
result[8] = m22;
|
|
350
|
-
return result;
|
|
351
|
-
};
|
|
352
250
|
|
|
353
|
-
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Creates a Matrix3 instance from a row-major order array.
|
|
253
|
+
* The resulting matrix will be in column-major order.
|
|
254
|
+
*
|
|
255
|
+
* @param {number[]} values The row-major order array.
|
|
256
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
257
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
258
|
+
*/
|
|
259
|
+
static fromRowMajorArray(values, result) {
|
|
260
|
+
//>>includeStart('debug', pragmas.debug);
|
|
261
|
+
Check.defined("values", values);
|
|
262
|
+
//>>includeEnd('debug');
|
|
263
|
+
|
|
264
|
+
if (!defined(result)) {
|
|
265
|
+
return new Matrix3(
|
|
266
|
+
values[0],
|
|
267
|
+
values[1],
|
|
268
|
+
values[2],
|
|
269
|
+
values[3],
|
|
270
|
+
values[4],
|
|
271
|
+
values[5],
|
|
272
|
+
values[6],
|
|
273
|
+
values[7],
|
|
274
|
+
values[8],
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
result[0] = values[0];
|
|
278
|
+
result[1] = values[3];
|
|
279
|
+
result[2] = values[6];
|
|
280
|
+
result[3] = values[1];
|
|
281
|
+
result[4] = values[4];
|
|
282
|
+
result[5] = values[7];
|
|
283
|
+
result[6] = values[2];
|
|
284
|
+
result[7] = values[5];
|
|
285
|
+
result[8] = values[8];
|
|
286
|
+
return result;
|
|
386
287
|
}
|
|
387
|
-
result[0] = m00;
|
|
388
|
-
result[1] = m10;
|
|
389
|
-
result[2] = m20;
|
|
390
|
-
result[3] = m01;
|
|
391
|
-
result[4] = m11;
|
|
392
|
-
result[5] = m21;
|
|
393
|
-
result[6] = m02;
|
|
394
|
-
result[7] = m12;
|
|
395
|
-
result[8] = m22;
|
|
396
|
-
return result;
|
|
397
|
-
};
|
|
398
288
|
|
|
399
|
-
/**
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
* // [0.0, 0.0, 9.0]
|
|
411
|
-
* const m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));
|
|
412
|
-
*/
|
|
413
|
-
Matrix3.fromScale = function (scale, result) {
|
|
414
|
-
//>>includeStart('debug', pragmas.debug);
|
|
415
|
-
Check.typeOf.object("scale", scale);
|
|
416
|
-
//>>includeEnd('debug');
|
|
289
|
+
/**
|
|
290
|
+
* Computes a 3x3 rotation matrix from the provided quaternion.
|
|
291
|
+
*
|
|
292
|
+
* @param {Quaternion} quaternion the quaternion to use.
|
|
293
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
294
|
+
* @returns {Matrix3} The 3x3 rotation matrix from this quaternion.
|
|
295
|
+
*/
|
|
296
|
+
static fromQuaternion(quaternion, result) {
|
|
297
|
+
//>>includeStart('debug', pragmas.debug);
|
|
298
|
+
Check.typeOf.object("quaternion", quaternion);
|
|
299
|
+
//>>includeEnd('debug');
|
|
417
300
|
|
|
418
|
-
|
|
419
|
-
|
|
301
|
+
const x2 = quaternion.x * quaternion.x;
|
|
302
|
+
const xy = quaternion.x * quaternion.y;
|
|
303
|
+
const xz = quaternion.x * quaternion.z;
|
|
304
|
+
const xw = quaternion.x * quaternion.w;
|
|
305
|
+
const y2 = quaternion.y * quaternion.y;
|
|
306
|
+
const yz = quaternion.y * quaternion.z;
|
|
307
|
+
const yw = quaternion.y * quaternion.w;
|
|
308
|
+
const z2 = quaternion.z * quaternion.z;
|
|
309
|
+
const zw = quaternion.z * quaternion.w;
|
|
310
|
+
const w2 = quaternion.w * quaternion.w;
|
|
311
|
+
|
|
312
|
+
const m00 = x2 - y2 - z2 + w2;
|
|
313
|
+
const m01 = 2.0 * (xy - zw);
|
|
314
|
+
const m02 = 2.0 * (xz + yw);
|
|
315
|
+
|
|
316
|
+
const m10 = 2.0 * (xy + zw);
|
|
317
|
+
const m11 = -x2 + y2 - z2 + w2;
|
|
318
|
+
const m12 = 2.0 * (yz - xw);
|
|
319
|
+
|
|
320
|
+
const m20 = 2.0 * (xz - yw);
|
|
321
|
+
const m21 = 2.0 * (yz + xw);
|
|
322
|
+
const m22 = -x2 - y2 + z2 + w2;
|
|
323
|
+
|
|
324
|
+
if (!defined(result)) {
|
|
325
|
+
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
326
|
+
}
|
|
327
|
+
result[0] = m00;
|
|
328
|
+
result[1] = m10;
|
|
329
|
+
result[2] = m20;
|
|
330
|
+
result[3] = m01;
|
|
331
|
+
result[4] = m11;
|
|
332
|
+
result[5] = m21;
|
|
333
|
+
result[6] = m02;
|
|
334
|
+
result[7] = m12;
|
|
335
|
+
result[8] = m22;
|
|
336
|
+
return result;
|
|
420
337
|
}
|
|
421
338
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
result
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )
|
|
341
|
+
*
|
|
342
|
+
* @param {HeadingPitchRoll} headingPitchRoll the headingPitchRoll to use.
|
|
343
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
344
|
+
* @returns {Matrix3} The 3x3 rotation matrix from this headingPitchRoll.
|
|
345
|
+
*/
|
|
346
|
+
static fromHeadingPitchRoll(headingPitchRoll, result) {
|
|
347
|
+
//>>includeStart('debug', pragmas.debug);
|
|
348
|
+
Check.typeOf.object("headingPitchRoll", headingPitchRoll);
|
|
349
|
+
//>>includeEnd('debug');
|
|
433
350
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
*
|
|
441
|
-
* @example
|
|
442
|
-
* // Creates
|
|
443
|
-
* // [2.0, 0.0, 0.0]
|
|
444
|
-
* // [0.0, 2.0, 0.0]
|
|
445
|
-
* // [0.0, 0.0, 2.0]
|
|
446
|
-
* const m = Cesium.Matrix3.fromUniformScale(2.0);
|
|
447
|
-
*/
|
|
448
|
-
Matrix3.fromUniformScale = function (scale, result) {
|
|
449
|
-
//>>includeStart('debug', pragmas.debug);
|
|
450
|
-
Check.typeOf.number("scale", scale);
|
|
451
|
-
//>>includeEnd('debug');
|
|
351
|
+
const cosTheta = Math.cos(-headingPitchRoll.pitch);
|
|
352
|
+
const cosPsi = Math.cos(-headingPitchRoll.heading);
|
|
353
|
+
const cosPhi = Math.cos(headingPitchRoll.roll);
|
|
354
|
+
const sinTheta = Math.sin(-headingPitchRoll.pitch);
|
|
355
|
+
const sinPsi = Math.sin(-headingPitchRoll.heading);
|
|
356
|
+
const sinPhi = Math.sin(headingPitchRoll.roll);
|
|
452
357
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
358
|
+
const m00 = cosTheta * cosPsi;
|
|
359
|
+
const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
|
|
360
|
+
const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
|
|
456
361
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
result[3] = 0.0;
|
|
461
|
-
result[4] = scale;
|
|
462
|
-
result[5] = 0.0;
|
|
463
|
-
result[6] = 0.0;
|
|
464
|
-
result[7] = 0.0;
|
|
465
|
-
result[8] = scale;
|
|
466
|
-
return result;
|
|
467
|
-
};
|
|
362
|
+
const m10 = cosTheta * sinPsi;
|
|
363
|
+
const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
|
|
364
|
+
const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
|
|
468
365
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
*
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
//>>includeEnd('debug');
|
|
487
|
-
|
|
488
|
-
if (!defined(result)) {
|
|
489
|
-
return new Matrix3(
|
|
490
|
-
0.0,
|
|
491
|
-
-vector.z,
|
|
492
|
-
vector.y,
|
|
493
|
-
vector.z,
|
|
494
|
-
0.0,
|
|
495
|
-
-vector.x,
|
|
496
|
-
-vector.y,
|
|
497
|
-
vector.x,
|
|
498
|
-
0.0,
|
|
499
|
-
);
|
|
366
|
+
const m20 = -sinTheta;
|
|
367
|
+
const m21 = sinPhi * cosTheta;
|
|
368
|
+
const m22 = cosPhi * cosTheta;
|
|
369
|
+
|
|
370
|
+
if (!defined(result)) {
|
|
371
|
+
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
372
|
+
}
|
|
373
|
+
result[0] = m00;
|
|
374
|
+
result[1] = m10;
|
|
375
|
+
result[2] = m20;
|
|
376
|
+
result[3] = m01;
|
|
377
|
+
result[4] = m11;
|
|
378
|
+
result[5] = m21;
|
|
379
|
+
result[6] = m02;
|
|
380
|
+
result[7] = m12;
|
|
381
|
+
result[8] = m22;
|
|
382
|
+
return result;
|
|
500
383
|
}
|
|
501
384
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
385
|
+
/**
|
|
386
|
+
* Computes a Matrix3 instance representing a non-uniform scale.
|
|
387
|
+
*
|
|
388
|
+
* @param {Cartesian3} scale The x, y, and z scale factors.
|
|
389
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
390
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Creates
|
|
394
|
+
* // [7.0, 0.0, 0.0]
|
|
395
|
+
* // [0.0, 8.0, 0.0]
|
|
396
|
+
* // [0.0, 0.0, 9.0]
|
|
397
|
+
* const m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));
|
|
398
|
+
*/
|
|
399
|
+
static fromScale(scale, result) {
|
|
400
|
+
//>>includeStart('debug', pragmas.debug);
|
|
401
|
+
Check.typeOf.object("scale", scale);
|
|
402
|
+
//>>includeEnd('debug');
|
|
513
403
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
0.0,
|
|
539
|
-
0.0,
|
|
540
|
-
0.0,
|
|
541
|
-
cosAngle,
|
|
542
|
-
-sinAngle,
|
|
543
|
-
0.0,
|
|
544
|
-
sinAngle,
|
|
545
|
-
cosAngle,
|
|
546
|
-
);
|
|
404
|
+
if (!defined(result)) {
|
|
405
|
+
return new Matrix3(
|
|
406
|
+
scale.x,
|
|
407
|
+
0.0,
|
|
408
|
+
0.0,
|
|
409
|
+
0.0,
|
|
410
|
+
scale.y,
|
|
411
|
+
0.0,
|
|
412
|
+
0.0,
|
|
413
|
+
0.0,
|
|
414
|
+
scale.z,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
result[0] = scale.x;
|
|
419
|
+
result[1] = 0.0;
|
|
420
|
+
result[2] = 0.0;
|
|
421
|
+
result[3] = 0.0;
|
|
422
|
+
result[4] = scale.y;
|
|
423
|
+
result[5] = 0.0;
|
|
424
|
+
result[6] = 0.0;
|
|
425
|
+
result[7] = 0.0;
|
|
426
|
+
result[8] = scale.z;
|
|
427
|
+
return result;
|
|
547
428
|
}
|
|
548
429
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Computes a Matrix3 instance representing a uniform scale.
|
|
432
|
+
*
|
|
433
|
+
* @param {number} scale The uniform scale factor.
|
|
434
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
435
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* // Creates
|
|
439
|
+
* // [2.0, 0.0, 0.0]
|
|
440
|
+
* // [0.0, 2.0, 0.0]
|
|
441
|
+
* // [0.0, 0.0, 2.0]
|
|
442
|
+
* const m = Cesium.Matrix3.fromUniformScale(2.0);
|
|
443
|
+
*/
|
|
444
|
+
static fromUniformScale(scale, result) {
|
|
445
|
+
//>>includeStart('debug', pragmas.debug);
|
|
446
|
+
Check.typeOf.number("scale", scale);
|
|
447
|
+
//>>includeEnd('debug');
|
|
558
448
|
|
|
559
|
-
|
|
560
|
-
|
|
449
|
+
if (!defined(result)) {
|
|
450
|
+
return new Matrix3(scale, 0.0, 0.0, 0.0, scale, 0.0, 0.0, 0.0, scale);
|
|
451
|
+
}
|
|
561
452
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
* const m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));
|
|
573
|
-
* const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
|
|
574
|
-
*/
|
|
575
|
-
Matrix3.fromRotationY = function (angle, result) {
|
|
576
|
-
//>>includeStart('debug', pragmas.debug);
|
|
577
|
-
Check.typeOf.number("angle", angle);
|
|
578
|
-
//>>includeEnd('debug');
|
|
579
|
-
|
|
580
|
-
const cosAngle = Math.cos(angle);
|
|
581
|
-
const sinAngle = Math.sin(angle);
|
|
582
|
-
|
|
583
|
-
if (!defined(result)) {
|
|
584
|
-
return new Matrix3(
|
|
585
|
-
cosAngle,
|
|
586
|
-
0.0,
|
|
587
|
-
sinAngle,
|
|
588
|
-
0.0,
|
|
589
|
-
1.0,
|
|
590
|
-
0.0,
|
|
591
|
-
-sinAngle,
|
|
592
|
-
0.0,
|
|
593
|
-
cosAngle,
|
|
594
|
-
);
|
|
453
|
+
result[0] = scale;
|
|
454
|
+
result[1] = 0.0;
|
|
455
|
+
result[2] = 0.0;
|
|
456
|
+
result[3] = 0.0;
|
|
457
|
+
result[4] = scale;
|
|
458
|
+
result[5] = 0.0;
|
|
459
|
+
result[6] = 0.0;
|
|
460
|
+
result[7] = 0.0;
|
|
461
|
+
result[8] = scale;
|
|
462
|
+
return result;
|
|
595
463
|
}
|
|
596
464
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
465
|
+
/**
|
|
466
|
+
* Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.
|
|
467
|
+
*
|
|
468
|
+
* @param {Cartesian3} vector the vector on the left hand side of the cross product operation.
|
|
469
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
470
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* // Creates
|
|
474
|
+
* // [0.0, -9.0, 8.0]
|
|
475
|
+
* // [9.0, 0.0, -7.0]
|
|
476
|
+
* // [-8.0, 7.0, 0.0]
|
|
477
|
+
* const m = Cesium.Matrix3.fromCrossProduct(new Cesium.Cartesian3(7.0, 8.0, 9.0));
|
|
478
|
+
*/
|
|
479
|
+
static fromCrossProduct(vector, result) {
|
|
480
|
+
//>>includeStart('debug', pragmas.debug);
|
|
481
|
+
Check.typeOf.object("vector", vector);
|
|
482
|
+
//>>includeEnd('debug');
|
|
606
483
|
|
|
607
|
-
|
|
608
|
-
|
|
484
|
+
if (!defined(result)) {
|
|
485
|
+
return new Matrix3(
|
|
486
|
+
0.0,
|
|
487
|
+
-vector.z,
|
|
488
|
+
vector.y,
|
|
489
|
+
vector.z,
|
|
490
|
+
0.0,
|
|
491
|
+
-vector.x,
|
|
492
|
+
-vector.y,
|
|
493
|
+
vector.x,
|
|
494
|
+
0.0,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
609
497
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
* const m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));
|
|
621
|
-
* const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
|
|
622
|
-
*/
|
|
623
|
-
Matrix3.fromRotationZ = function (angle, result) {
|
|
624
|
-
//>>includeStart('debug', pragmas.debug);
|
|
625
|
-
Check.typeOf.number("angle", angle);
|
|
626
|
-
//>>includeEnd('debug');
|
|
627
|
-
|
|
628
|
-
const cosAngle = Math.cos(angle);
|
|
629
|
-
const sinAngle = Math.sin(angle);
|
|
630
|
-
|
|
631
|
-
if (!defined(result)) {
|
|
632
|
-
return new Matrix3(
|
|
633
|
-
cosAngle,
|
|
634
|
-
-sinAngle,
|
|
635
|
-
0.0,
|
|
636
|
-
sinAngle,
|
|
637
|
-
cosAngle,
|
|
638
|
-
0.0,
|
|
639
|
-
0.0,
|
|
640
|
-
0.0,
|
|
641
|
-
1.0,
|
|
642
|
-
);
|
|
498
|
+
result[0] = 0.0;
|
|
499
|
+
result[1] = vector.z;
|
|
500
|
+
result[2] = -vector.y;
|
|
501
|
+
result[3] = -vector.z;
|
|
502
|
+
result[4] = 0.0;
|
|
503
|
+
result[5] = vector.x;
|
|
504
|
+
result[6] = vector.y;
|
|
505
|
+
result[7] = -vector.x;
|
|
506
|
+
result[8] = 0.0;
|
|
507
|
+
return result;
|
|
643
508
|
}
|
|
644
509
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Creates a rotation matrix around the x-axis.
|
|
512
|
+
*
|
|
513
|
+
* @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
|
|
514
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
515
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* // Rotate a point 45 degrees counterclockwise around the x-axis.
|
|
519
|
+
* const p = new Cesium.Cartesian3(5, 6, 7);
|
|
520
|
+
* const m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));
|
|
521
|
+
* const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
|
|
522
|
+
*/
|
|
523
|
+
static fromRotationX(angle, result) {
|
|
524
|
+
//>>includeStart('debug', pragmas.debug);
|
|
525
|
+
Check.typeOf.number("angle", angle);
|
|
526
|
+
//>>includeEnd('debug');
|
|
654
527
|
|
|
655
|
-
|
|
656
|
-
|
|
528
|
+
const cosAngle = Math.cos(angle);
|
|
529
|
+
const sinAngle = Math.sin(angle);
|
|
530
|
+
|
|
531
|
+
if (!defined(result)) {
|
|
532
|
+
return new Matrix3(
|
|
533
|
+
1.0,
|
|
534
|
+
0.0,
|
|
535
|
+
0.0,
|
|
536
|
+
0.0,
|
|
537
|
+
cosAngle,
|
|
538
|
+
-sinAngle,
|
|
539
|
+
0.0,
|
|
540
|
+
sinAngle,
|
|
541
|
+
cosAngle,
|
|
542
|
+
);
|
|
543
|
+
}
|
|
657
544
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
//>>includeEnd('debug');
|
|
670
|
-
|
|
671
|
-
if (!defined(result)) {
|
|
672
|
-
return [
|
|
673
|
-
matrix[0],
|
|
674
|
-
matrix[1],
|
|
675
|
-
matrix[2],
|
|
676
|
-
matrix[3],
|
|
677
|
-
matrix[4],
|
|
678
|
-
matrix[5],
|
|
679
|
-
matrix[6],
|
|
680
|
-
matrix[7],
|
|
681
|
-
matrix[8],
|
|
682
|
-
];
|
|
545
|
+
result[0] = 1.0;
|
|
546
|
+
result[1] = 0.0;
|
|
547
|
+
result[2] = 0.0;
|
|
548
|
+
result[3] = 0.0;
|
|
549
|
+
result[4] = cosAngle;
|
|
550
|
+
result[5] = sinAngle;
|
|
551
|
+
result[6] = 0.0;
|
|
552
|
+
result[7] = -sinAngle;
|
|
553
|
+
result[8] = cosAngle;
|
|
554
|
+
|
|
555
|
+
return result;
|
|
683
556
|
}
|
|
684
|
-
result[0] = matrix[0];
|
|
685
|
-
result[1] = matrix[1];
|
|
686
|
-
result[2] = matrix[2];
|
|
687
|
-
result[3] = matrix[3];
|
|
688
|
-
result[4] = matrix[4];
|
|
689
|
-
result[5] = matrix[5];
|
|
690
|
-
result[6] = matrix[6];
|
|
691
|
-
result[7] = matrix[7];
|
|
692
|
-
result[8] = matrix[8];
|
|
693
|
-
return result;
|
|
694
|
-
};
|
|
695
557
|
|
|
696
|
-
/**
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
//>>includeStart('debug', pragmas.debug);
|
|
714
|
-
Check.typeOf.number.greaterThanOrEquals("row", row, 0);
|
|
715
|
-
Check.typeOf.number.lessThanOrEquals("row", row, 2);
|
|
716
|
-
Check.typeOf.number.greaterThanOrEquals("column", column, 0);
|
|
717
|
-
Check.typeOf.number.lessThanOrEquals("column", column, 2);
|
|
718
|
-
//>>includeEnd('debug');
|
|
558
|
+
/**
|
|
559
|
+
* Creates a rotation matrix around the y-axis.
|
|
560
|
+
*
|
|
561
|
+
* @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
|
|
562
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
563
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* // Rotate a point 45 degrees counterclockwise around the y-axis.
|
|
567
|
+
* const p = new Cesium.Cartesian3(5, 6, 7);
|
|
568
|
+
* const m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));
|
|
569
|
+
* const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
|
|
570
|
+
*/
|
|
571
|
+
static fromRotationY(angle, result) {
|
|
572
|
+
//>>includeStart('debug', pragmas.debug);
|
|
573
|
+
Check.typeOf.number("angle", angle);
|
|
574
|
+
//>>includeEnd('debug');
|
|
719
575
|
|
|
720
|
-
|
|
721
|
-
|
|
576
|
+
const cosAngle = Math.cos(angle);
|
|
577
|
+
const sinAngle = Math.sin(angle);
|
|
578
|
+
|
|
579
|
+
if (!defined(result)) {
|
|
580
|
+
return new Matrix3(
|
|
581
|
+
cosAngle,
|
|
582
|
+
0.0,
|
|
583
|
+
sinAngle,
|
|
584
|
+
0.0,
|
|
585
|
+
1.0,
|
|
586
|
+
0.0,
|
|
587
|
+
-sinAngle,
|
|
588
|
+
0.0,
|
|
589
|
+
cosAngle,
|
|
590
|
+
);
|
|
591
|
+
}
|
|
722
592
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
Check.typeOf.object("matrix", matrix);
|
|
736
|
-
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
737
|
-
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
738
|
-
Check.typeOf.object("result", result);
|
|
739
|
-
//>>includeEnd('debug');
|
|
740
|
-
|
|
741
|
-
const startIndex = index * 3;
|
|
742
|
-
const x = matrix[startIndex];
|
|
743
|
-
const y = matrix[startIndex + 1];
|
|
744
|
-
const z = matrix[startIndex + 2];
|
|
745
|
-
|
|
746
|
-
result.x = x;
|
|
747
|
-
result.y = y;
|
|
748
|
-
result.z = z;
|
|
749
|
-
return result;
|
|
750
|
-
};
|
|
593
|
+
result[0] = cosAngle;
|
|
594
|
+
result[1] = 0.0;
|
|
595
|
+
result[2] = -sinAngle;
|
|
596
|
+
result[3] = 0.0;
|
|
597
|
+
result[4] = 1.0;
|
|
598
|
+
result[5] = 0.0;
|
|
599
|
+
result[6] = sinAngle;
|
|
600
|
+
result[7] = 0.0;
|
|
601
|
+
result[8] = cosAngle;
|
|
602
|
+
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
751
605
|
|
|
752
|
-
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
Check.typeOf.object("result", result);
|
|
770
|
-
//>>includeEnd('debug');
|
|
771
|
-
|
|
772
|
-
result = Matrix3.clone(matrix, result);
|
|
773
|
-
const startIndex = index * 3;
|
|
774
|
-
result[startIndex] = cartesian.x;
|
|
775
|
-
result[startIndex + 1] = cartesian.y;
|
|
776
|
-
result[startIndex + 2] = cartesian.z;
|
|
777
|
-
return result;
|
|
778
|
-
};
|
|
606
|
+
/**
|
|
607
|
+
* Creates a rotation matrix around the z-axis.
|
|
608
|
+
*
|
|
609
|
+
* @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
|
|
610
|
+
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
611
|
+
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* // Rotate a point 45 degrees counterclockwise around the z-axis.
|
|
615
|
+
* const p = new Cesium.Cartesian3(5, 6, 7);
|
|
616
|
+
* const m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));
|
|
617
|
+
* const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
|
|
618
|
+
*/
|
|
619
|
+
static fromRotationZ(angle, result) {
|
|
620
|
+
//>>includeStart('debug', pragmas.debug);
|
|
621
|
+
Check.typeOf.number("angle", angle);
|
|
622
|
+
//>>includeEnd('debug');
|
|
779
623
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
//>>includeEnd('debug');
|
|
797
|
-
|
|
798
|
-
const x = matrix[index];
|
|
799
|
-
const y = matrix[index + 3];
|
|
800
|
-
const z = matrix[index + 6];
|
|
801
|
-
|
|
802
|
-
result.x = x;
|
|
803
|
-
result.y = y;
|
|
804
|
-
result.z = z;
|
|
805
|
-
return result;
|
|
806
|
-
};
|
|
624
|
+
const cosAngle = Math.cos(angle);
|
|
625
|
+
const sinAngle = Math.sin(angle);
|
|
626
|
+
|
|
627
|
+
if (!defined(result)) {
|
|
628
|
+
return new Matrix3(
|
|
629
|
+
cosAngle,
|
|
630
|
+
-sinAngle,
|
|
631
|
+
0.0,
|
|
632
|
+
sinAngle,
|
|
633
|
+
cosAngle,
|
|
634
|
+
0.0,
|
|
635
|
+
0.0,
|
|
636
|
+
0.0,
|
|
637
|
+
1.0,
|
|
638
|
+
);
|
|
639
|
+
}
|
|
807
640
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
//>>includeStart('debug', pragmas.debug);
|
|
821
|
-
Check.typeOf.object("matrix", matrix);
|
|
822
|
-
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
823
|
-
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
824
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
825
|
-
Check.typeOf.object("result", result);
|
|
826
|
-
//>>includeEnd('debug');
|
|
827
|
-
|
|
828
|
-
result = Matrix3.clone(matrix, result);
|
|
829
|
-
result[index] = cartesian.x;
|
|
830
|
-
result[index + 3] = cartesian.y;
|
|
831
|
-
result[index + 6] = cartesian.z;
|
|
832
|
-
return result;
|
|
833
|
-
};
|
|
641
|
+
result[0] = cosAngle;
|
|
642
|
+
result[1] = sinAngle;
|
|
643
|
+
result[2] = 0.0;
|
|
644
|
+
result[3] = -sinAngle;
|
|
645
|
+
result[4] = cosAngle;
|
|
646
|
+
result[5] = 0.0;
|
|
647
|
+
result[6] = 0.0;
|
|
648
|
+
result[7] = 0.0;
|
|
649
|
+
result[8] = 1.0;
|
|
650
|
+
|
|
651
|
+
return result;
|
|
652
|
+
}
|
|
834
653
|
|
|
835
|
-
|
|
654
|
+
/**
|
|
655
|
+
* Creates an Array from the provided Matrix3 instance.
|
|
656
|
+
* The array will be in column-major order.
|
|
657
|
+
*
|
|
658
|
+
* @param {Matrix3} matrix The matrix to use..
|
|
659
|
+
* @param {number[]} [result] The Array onto which to store the result.
|
|
660
|
+
* @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.
|
|
661
|
+
*/
|
|
662
|
+
static toArray(matrix, result) {
|
|
663
|
+
//>>includeStart('debug', pragmas.debug);
|
|
664
|
+
Check.typeOf.object("matrix", matrix);
|
|
665
|
+
//>>includeEnd('debug');
|
|
836
666
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
const scaleRatioX = scale.x / existingScale.x;
|
|
862
|
-
const scaleRatioY = scale.y / existingScale.y;
|
|
863
|
-
const scaleRatioZ = scale.z / existingScale.z;
|
|
864
|
-
|
|
865
|
-
result[0] = matrix[0] * scaleRatioX;
|
|
866
|
-
result[1] = matrix[1] * scaleRatioX;
|
|
867
|
-
result[2] = matrix[2] * scaleRatioX;
|
|
868
|
-
result[3] = matrix[3] * scaleRatioY;
|
|
869
|
-
result[4] = matrix[4] * scaleRatioY;
|
|
870
|
-
result[5] = matrix[5] * scaleRatioY;
|
|
871
|
-
result[6] = matrix[6] * scaleRatioZ;
|
|
872
|
-
result[7] = matrix[7] * scaleRatioZ;
|
|
873
|
-
result[8] = matrix[8] * scaleRatioZ;
|
|
667
|
+
if (!defined(result)) {
|
|
668
|
+
return [
|
|
669
|
+
matrix[0],
|
|
670
|
+
matrix[1],
|
|
671
|
+
matrix[2],
|
|
672
|
+
matrix[3],
|
|
673
|
+
matrix[4],
|
|
674
|
+
matrix[5],
|
|
675
|
+
matrix[6],
|
|
676
|
+
matrix[7],
|
|
677
|
+
matrix[8],
|
|
678
|
+
];
|
|
679
|
+
}
|
|
680
|
+
result[0] = matrix[0];
|
|
681
|
+
result[1] = matrix[1];
|
|
682
|
+
result[2] = matrix[2];
|
|
683
|
+
result[3] = matrix[3];
|
|
684
|
+
result[4] = matrix[4];
|
|
685
|
+
result[5] = matrix[5];
|
|
686
|
+
result[6] = matrix[6];
|
|
687
|
+
result[7] = matrix[7];
|
|
688
|
+
result[8] = matrix[8];
|
|
689
|
+
return result;
|
|
690
|
+
}
|
|
874
691
|
|
|
875
|
-
|
|
876
|
-
|
|
692
|
+
/**
|
|
693
|
+
* Computes the array index of the element at the provided row and column.
|
|
694
|
+
*
|
|
695
|
+
* @param {number} column The zero-based index of the column.
|
|
696
|
+
* @param {number} row The zero-based index of the row.
|
|
697
|
+
* @returns {number} The index of the element at the provided row and column.
|
|
698
|
+
*
|
|
699
|
+
* @exception {DeveloperError} row must be 0, 1, or 2.
|
|
700
|
+
* @exception {DeveloperError} column must be 0, 1, or 2.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* const myMatrix = new Cesium.Matrix3();
|
|
704
|
+
* const column1Row0Index = Cesium.Matrix3.getElementIndex(1, 0);
|
|
705
|
+
* const column1Row0 = myMatrix[column1Row0Index]
|
|
706
|
+
* myMatrix[column1Row0Index] = 10.0;
|
|
707
|
+
*/
|
|
708
|
+
static getElementIndex(column, row) {
|
|
709
|
+
//>>includeStart('debug', pragmas.debug);
|
|
710
|
+
Check.typeOf.number.greaterThanOrEquals("row", row, 0);
|
|
711
|
+
Check.typeOf.number.lessThanOrEquals("row", row, 2);
|
|
712
|
+
Check.typeOf.number.greaterThanOrEquals("column", column, 0);
|
|
713
|
+
Check.typeOf.number.lessThanOrEquals("column", column, 2);
|
|
714
|
+
//>>includeEnd('debug');
|
|
877
715
|
|
|
878
|
-
|
|
716
|
+
return column * 3 + row;
|
|
717
|
+
}
|
|
879
718
|
|
|
880
|
-
/**
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
//>>includeStart('debug', pragmas.debug);
|
|
898
|
-
Check.typeOf.object("matrix", matrix);
|
|
899
|
-
Check.typeOf.number("scale", scale);
|
|
900
|
-
Check.typeOf.object("result", result);
|
|
901
|
-
//>>includeEnd('debug');
|
|
902
|
-
|
|
903
|
-
const existingScale = Matrix3.getScale(matrix, scaleScratch2);
|
|
904
|
-
const scaleRatioX = scale / existingScale.x;
|
|
905
|
-
const scaleRatioY = scale / existingScale.y;
|
|
906
|
-
const scaleRatioZ = scale / existingScale.z;
|
|
907
|
-
|
|
908
|
-
result[0] = matrix[0] * scaleRatioX;
|
|
909
|
-
result[1] = matrix[1] * scaleRatioX;
|
|
910
|
-
result[2] = matrix[2] * scaleRatioX;
|
|
911
|
-
result[3] = matrix[3] * scaleRatioY;
|
|
912
|
-
result[4] = matrix[4] * scaleRatioY;
|
|
913
|
-
result[5] = matrix[5] * scaleRatioY;
|
|
914
|
-
result[6] = matrix[6] * scaleRatioZ;
|
|
915
|
-
result[7] = matrix[7] * scaleRatioZ;
|
|
916
|
-
result[8] = matrix[8] * scaleRatioZ;
|
|
719
|
+
/**
|
|
720
|
+
* Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
|
|
721
|
+
*
|
|
722
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
723
|
+
* @param {number} index The zero-based index of the column to retrieve.
|
|
724
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
725
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
726
|
+
*
|
|
727
|
+
* @exception {DeveloperError} index must be 0, 1, or 2.
|
|
728
|
+
*/
|
|
729
|
+
static getColumn(matrix, index, result) {
|
|
730
|
+
//>>includeStart('debug', pragmas.debug);
|
|
731
|
+
Check.typeOf.object("matrix", matrix);
|
|
732
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
733
|
+
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
734
|
+
Check.typeOf.object("result", result);
|
|
735
|
+
//>>includeEnd('debug');
|
|
917
736
|
|
|
918
|
-
|
|
919
|
-
};
|
|
737
|
+
const startIndex = index * 3;
|
|
920
738
|
|
|
921
|
-
|
|
739
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
740
|
+
const x = matrix[startIndex];
|
|
741
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
742
|
+
const y = matrix[startIndex + 1];
|
|
743
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
744
|
+
const z = matrix[startIndex + 2];
|
|
922
745
|
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
929
|
-
*
|
|
930
|
-
* @see Matrix3.multiplyByScale
|
|
931
|
-
* @see Matrix3.multiplyByUniformScale
|
|
932
|
-
* @see Matrix3.fromScale
|
|
933
|
-
* @see Matrix3.fromUniformScale
|
|
934
|
-
* @see Matrix3.setScale
|
|
935
|
-
* @see Matrix3.setUniformScale
|
|
936
|
-
*/
|
|
937
|
-
Matrix3.getScale = function (matrix, result) {
|
|
938
|
-
//>>includeStart('debug', pragmas.debug);
|
|
939
|
-
Check.typeOf.object("matrix", matrix);
|
|
940
|
-
Check.typeOf.object("result", result);
|
|
941
|
-
//>>includeEnd('debug');
|
|
942
|
-
|
|
943
|
-
result.x = Cartesian3.magnitude(
|
|
944
|
-
Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn),
|
|
945
|
-
);
|
|
946
|
-
result.y = Cartesian3.magnitude(
|
|
947
|
-
Cartesian3.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn),
|
|
948
|
-
);
|
|
949
|
-
result.z = Cartesian3.magnitude(
|
|
950
|
-
Cartesian3.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn),
|
|
951
|
-
);
|
|
952
|
-
return result;
|
|
953
|
-
};
|
|
746
|
+
result.x = x;
|
|
747
|
+
result.y = y;
|
|
748
|
+
result.z = z;
|
|
749
|
+
return result;
|
|
750
|
+
}
|
|
954
751
|
|
|
955
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.
|
|
754
|
+
*
|
|
755
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
756
|
+
* @param {number} index The zero-based index of the column to set.
|
|
757
|
+
* @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified column.
|
|
758
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
759
|
+
* @returns {Matrix3} The modified result parameter.
|
|
760
|
+
*
|
|
761
|
+
* @exception {DeveloperError} index must be 0, 1, or 2.
|
|
762
|
+
*/
|
|
763
|
+
static setColumn(matrix, index, cartesian, result) {
|
|
764
|
+
//>>includeStart('debug', pragmas.debug);
|
|
765
|
+
Check.typeOf.object("matrix", matrix);
|
|
766
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
767
|
+
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
768
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
769
|
+
Check.typeOf.object("result", result);
|
|
770
|
+
//>>includeEnd('debug');
|
|
956
771
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
* The maximum scale is the maximum length of the column vectors.
|
|
960
|
-
*
|
|
961
|
-
* @param {Matrix3} matrix The matrix.
|
|
962
|
-
* @returns {number} The maximum scale.
|
|
963
|
-
*/
|
|
964
|
-
Matrix3.getMaximumScale = function (matrix) {
|
|
965
|
-
Matrix3.getScale(matrix, scaleScratch3);
|
|
966
|
-
return Cartesian3.maximumComponent(scaleScratch3);
|
|
967
|
-
};
|
|
772
|
+
result = Matrix3.clone(matrix, result);
|
|
773
|
+
const startIndex = index * 3;
|
|
968
774
|
|
|
969
|
-
|
|
775
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
776
|
+
result[startIndex] = cartesian.x;
|
|
777
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
778
|
+
result[startIndex + 1] = cartesian.y;
|
|
779
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
780
|
+
result[startIndex + 2] = cartesian.z;
|
|
970
781
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
*
|
|
974
|
-
* @param {Matrix3} matrix The matrix.
|
|
975
|
-
* @param {Matrix3} rotation The rotation matrix.
|
|
976
|
-
* @param {Matrix3} result The object onto which to store the result.
|
|
977
|
-
* @returns {Matrix3} The modified result parameter.
|
|
978
|
-
*
|
|
979
|
-
* @see Matrix3.getRotation
|
|
980
|
-
*/
|
|
981
|
-
Matrix3.setRotation = function (matrix, rotation, result) {
|
|
982
|
-
//>>includeStart('debug', pragmas.debug);
|
|
983
|
-
Check.typeOf.object("matrix", matrix);
|
|
984
|
-
Check.typeOf.object("result", result);
|
|
985
|
-
//>>includeEnd('debug');
|
|
986
|
-
|
|
987
|
-
const scale = Matrix3.getScale(matrix, scaleScratch4);
|
|
988
|
-
|
|
989
|
-
result[0] = rotation[0] * scale.x;
|
|
990
|
-
result[1] = rotation[1] * scale.x;
|
|
991
|
-
result[2] = rotation[2] * scale.x;
|
|
992
|
-
result[3] = rotation[3] * scale.y;
|
|
993
|
-
result[4] = rotation[4] * scale.y;
|
|
994
|
-
result[5] = rotation[5] * scale.y;
|
|
995
|
-
result[6] = rotation[6] * scale.z;
|
|
996
|
-
result[7] = rotation[7] * scale.z;
|
|
997
|
-
result[8] = rotation[8] * scale.z;
|
|
782
|
+
return result;
|
|
783
|
+
}
|
|
998
784
|
|
|
999
|
-
|
|
1000
|
-
|
|
785
|
+
/**
|
|
786
|
+
* Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
|
|
787
|
+
*
|
|
788
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
789
|
+
* @param {number} index The zero-based index of the row to retrieve.
|
|
790
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
791
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
792
|
+
*
|
|
793
|
+
* @exception {DeveloperError} index must be 0, 1, or 2.
|
|
794
|
+
*/
|
|
795
|
+
static getRow(matrix, index, result) {
|
|
796
|
+
//>>includeStart('debug', pragmas.debug);
|
|
797
|
+
Check.typeOf.object("matrix", matrix);
|
|
798
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
799
|
+
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
800
|
+
Check.typeOf.object("result", result);
|
|
801
|
+
//>>includeEnd('debug');
|
|
1001
802
|
|
|
1002
|
-
|
|
803
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
804
|
+
const x = matrix[index];
|
|
805
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
806
|
+
const y = matrix[index + 3];
|
|
807
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
808
|
+
const z = matrix[index + 6];
|
|
809
|
+
|
|
810
|
+
result.x = x;
|
|
811
|
+
result.y = y;
|
|
812
|
+
result.z = z;
|
|
813
|
+
return result;
|
|
814
|
+
}
|
|
1003
815
|
|
|
1004
|
-
/**
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
result[2] = matrix[2] / scale.x;
|
|
1024
|
-
result[3] = matrix[3] / scale.y;
|
|
1025
|
-
result[4] = matrix[4] / scale.y;
|
|
1026
|
-
result[5] = matrix[5] / scale.y;
|
|
1027
|
-
result[6] = matrix[6] / scale.z;
|
|
1028
|
-
result[7] = matrix[7] / scale.z;
|
|
1029
|
-
result[8] = matrix[8] / scale.z;
|
|
816
|
+
/**
|
|
817
|
+
* Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.
|
|
818
|
+
*
|
|
819
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
820
|
+
* @param {number} index The zero-based index of the row to set.
|
|
821
|
+
* @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified row.
|
|
822
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
823
|
+
* @returns {Matrix3} The modified result parameter.
|
|
824
|
+
*
|
|
825
|
+
* @exception {DeveloperError} index must be 0, 1, or 2.
|
|
826
|
+
*/
|
|
827
|
+
static setRow(matrix, index, cartesian, result) {
|
|
828
|
+
//>>includeStart('debug', pragmas.debug);
|
|
829
|
+
Check.typeOf.object("matrix", matrix);
|
|
830
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
831
|
+
Check.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
832
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
833
|
+
Check.typeOf.object("result", result);
|
|
834
|
+
//>>includeEnd('debug');
|
|
1030
835
|
|
|
1031
|
-
|
|
1032
|
-
};
|
|
836
|
+
result = Matrix3.clone(matrix, result);
|
|
1033
837
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
* @returns {Matrix3} The modified result parameter.
|
|
1041
|
-
*/
|
|
1042
|
-
Matrix3.multiply = function (left, right, result) {
|
|
1043
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1044
|
-
Check.typeOf.object("left", left);
|
|
1045
|
-
Check.typeOf.object("right", right);
|
|
1046
|
-
Check.typeOf.object("result", result);
|
|
1047
|
-
//>>includeEnd('debug');
|
|
1048
|
-
|
|
1049
|
-
const column0Row0 =
|
|
1050
|
-
left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
|
|
1051
|
-
const column0Row1 =
|
|
1052
|
-
left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
|
|
1053
|
-
const column0Row2 =
|
|
1054
|
-
left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
|
|
1055
|
-
|
|
1056
|
-
const column1Row0 =
|
|
1057
|
-
left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
|
|
1058
|
-
const column1Row1 =
|
|
1059
|
-
left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
|
|
1060
|
-
const column1Row2 =
|
|
1061
|
-
left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
|
|
1062
|
-
|
|
1063
|
-
const column2Row0 =
|
|
1064
|
-
left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
|
|
1065
|
-
const column2Row1 =
|
|
1066
|
-
left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
|
|
1067
|
-
const column2Row2 =
|
|
1068
|
-
left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
|
|
1069
|
-
|
|
1070
|
-
result[0] = column0Row0;
|
|
1071
|
-
result[1] = column0Row1;
|
|
1072
|
-
result[2] = column0Row2;
|
|
1073
|
-
result[3] = column1Row0;
|
|
1074
|
-
result[4] = column1Row1;
|
|
1075
|
-
result[5] = column1Row2;
|
|
1076
|
-
result[6] = column2Row0;
|
|
1077
|
-
result[7] = column2Row1;
|
|
1078
|
-
result[8] = column2Row2;
|
|
1079
|
-
return result;
|
|
1080
|
-
};
|
|
838
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
839
|
+
result[index] = cartesian.x;
|
|
840
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
841
|
+
result[index + 3] = cartesian.y;
|
|
842
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
843
|
+
result[index + 6] = cartesian.z;
|
|
1081
844
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
*
|
|
1085
|
-
* @param {Matrix3} left The first matrix.
|
|
1086
|
-
* @param {Matrix3} right The second matrix.
|
|
1087
|
-
* @param {Matrix3} result The object onto which to store the result.
|
|
1088
|
-
* @returns {Matrix3} The modified result parameter.
|
|
1089
|
-
*/
|
|
1090
|
-
Matrix3.add = function (left, right, result) {
|
|
1091
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1092
|
-
Check.typeOf.object("left", left);
|
|
1093
|
-
Check.typeOf.object("right", right);
|
|
1094
|
-
Check.typeOf.object("result", result);
|
|
1095
|
-
//>>includeEnd('debug');
|
|
1096
|
-
|
|
1097
|
-
result[0] = left[0] + right[0];
|
|
1098
|
-
result[1] = left[1] + right[1];
|
|
1099
|
-
result[2] = left[2] + right[2];
|
|
1100
|
-
result[3] = left[3] + right[3];
|
|
1101
|
-
result[4] = left[4] + right[4];
|
|
1102
|
-
result[5] = left[5] + right[5];
|
|
1103
|
-
result[6] = left[6] + right[6];
|
|
1104
|
-
result[7] = left[7] + right[7];
|
|
1105
|
-
result[8] = left[8] + right[8];
|
|
1106
|
-
return result;
|
|
1107
|
-
};
|
|
845
|
+
return result;
|
|
846
|
+
}
|
|
1108
847
|
|
|
1109
|
-
/**
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
result[7] = left[7] - right[7];
|
|
1132
|
-
result[8] = left[8] - right[8];
|
|
1133
|
-
return result;
|
|
1134
|
-
};
|
|
848
|
+
/**
|
|
849
|
+
* Computes a new matrix that replaces the scale with the provided scale.
|
|
850
|
+
* This assumes the matrix is an affine transformation.
|
|
851
|
+
*
|
|
852
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
853
|
+
* @param {Cartesian3} scale The scale that replaces the scale of the provided matrix.
|
|
854
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
855
|
+
* @returns {Matrix3} The modified result parameter.
|
|
856
|
+
*
|
|
857
|
+
* @see Matrix3.setUniformScale
|
|
858
|
+
* @see Matrix3.fromScale
|
|
859
|
+
* @see Matrix3.fromUniformScale
|
|
860
|
+
* @see Matrix3.multiplyByScale
|
|
861
|
+
* @see Matrix3.multiplyByUniformScale
|
|
862
|
+
* @see Matrix3.getScale
|
|
863
|
+
*/
|
|
864
|
+
static setScale(matrix, scale, result) {
|
|
865
|
+
//>>includeStart('debug', pragmas.debug);
|
|
866
|
+
Check.typeOf.object("matrix", matrix);
|
|
867
|
+
Check.typeOf.object("scale", scale);
|
|
868
|
+
Check.typeOf.object("result", result);
|
|
869
|
+
//>>includeEnd('debug');
|
|
1135
870
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
const vZ = cartesian.z;
|
|
1154
|
-
|
|
1155
|
-
const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
|
|
1156
|
-
const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
|
|
1157
|
-
const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
|
|
1158
|
-
|
|
1159
|
-
result.x = x;
|
|
1160
|
-
result.y = y;
|
|
1161
|
-
result.z = z;
|
|
1162
|
-
return result;
|
|
1163
|
-
};
|
|
871
|
+
const existingScale = Matrix3.getScale(matrix, scaleScratch1);
|
|
872
|
+
const scaleRatioX = scale.x / existingScale.x;
|
|
873
|
+
const scaleRatioY = scale.y / existingScale.y;
|
|
874
|
+
const scaleRatioZ = scale.z / existingScale.z;
|
|
875
|
+
|
|
876
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
877
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
878
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
879
|
+
result[3] = matrix[3] * scaleRatioY;
|
|
880
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
881
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
882
|
+
result[6] = matrix[6] * scaleRatioZ;
|
|
883
|
+
result[7] = matrix[7] * scaleRatioZ;
|
|
884
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
885
|
+
|
|
886
|
+
return result;
|
|
887
|
+
}
|
|
1164
888
|
|
|
1165
|
-
/**
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
result[7] = matrix[7] * scalar;
|
|
1188
|
-
result[8] = matrix[8] * scalar;
|
|
1189
|
-
return result;
|
|
1190
|
-
};
|
|
889
|
+
/**
|
|
890
|
+
* Computes a new matrix that replaces the scale with the provided uniform scale.
|
|
891
|
+
* This assumes the matrix is an affine transformation.
|
|
892
|
+
*
|
|
893
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
894
|
+
* @param {number} scale The uniform scale that replaces the scale of the provided matrix.
|
|
895
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
896
|
+
* @returns {Matrix3} The modified result parameter.
|
|
897
|
+
*
|
|
898
|
+
* @see Matrix3.setScale
|
|
899
|
+
* @see Matrix3.fromScale
|
|
900
|
+
* @see Matrix3.fromUniformScale
|
|
901
|
+
* @see Matrix3.multiplyByScale
|
|
902
|
+
* @see Matrix3.multiplyByUniformScale
|
|
903
|
+
* @see Matrix3.getScale
|
|
904
|
+
*/
|
|
905
|
+
static setUniformScale(matrix, scale, result) {
|
|
906
|
+
//>>includeStart('debug', pragmas.debug);
|
|
907
|
+
Check.typeOf.object("matrix", matrix);
|
|
908
|
+
Check.typeOf.number("scale", scale);
|
|
909
|
+
Check.typeOf.object("result", result);
|
|
910
|
+
//>>includeEnd('debug');
|
|
1191
911
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
* @see Matrix3.setUniformScale
|
|
1210
|
-
* @see Matrix3.getScale
|
|
1211
|
-
*/
|
|
1212
|
-
Matrix3.multiplyByScale = function (matrix, scale, result) {
|
|
1213
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1214
|
-
Check.typeOf.object("matrix", matrix);
|
|
1215
|
-
Check.typeOf.object("scale", scale);
|
|
1216
|
-
Check.typeOf.object("result", result);
|
|
1217
|
-
//>>includeEnd('debug');
|
|
1218
|
-
|
|
1219
|
-
result[0] = matrix[0] * scale.x;
|
|
1220
|
-
result[1] = matrix[1] * scale.x;
|
|
1221
|
-
result[2] = matrix[2] * scale.x;
|
|
1222
|
-
result[3] = matrix[3] * scale.y;
|
|
1223
|
-
result[4] = matrix[4] * scale.y;
|
|
1224
|
-
result[5] = matrix[5] * scale.y;
|
|
1225
|
-
result[6] = matrix[6] * scale.z;
|
|
1226
|
-
result[7] = matrix[7] * scale.z;
|
|
1227
|
-
result[8] = matrix[8] * scale.z;
|
|
912
|
+
const existingScale = Matrix3.getScale(matrix, scaleScratch2);
|
|
913
|
+
const scaleRatioX = scale / existingScale.x;
|
|
914
|
+
const scaleRatioY = scale / existingScale.y;
|
|
915
|
+
const scaleRatioZ = scale / existingScale.z;
|
|
916
|
+
|
|
917
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
918
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
919
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
920
|
+
result[3] = matrix[3] * scaleRatioY;
|
|
921
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
922
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
923
|
+
result[6] = matrix[6] * scaleRatioZ;
|
|
924
|
+
result[7] = matrix[7] * scaleRatioZ;
|
|
925
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
926
|
+
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
1228
929
|
|
|
1229
|
-
|
|
1230
|
-
|
|
930
|
+
/**
|
|
931
|
+
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
932
|
+
*
|
|
933
|
+
* @param {Matrix3} matrix The matrix.
|
|
934
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
935
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
936
|
+
*
|
|
937
|
+
* @see Matrix3.multiplyByScale
|
|
938
|
+
* @see Matrix3.multiplyByUniformScale
|
|
939
|
+
* @see Matrix3.fromScale
|
|
940
|
+
* @see Matrix3.fromUniformScale
|
|
941
|
+
* @see Matrix3.setScale
|
|
942
|
+
* @see Matrix3.setUniformScale
|
|
943
|
+
*/
|
|
944
|
+
static getScale(matrix, result) {
|
|
945
|
+
//>>includeStart('debug', pragmas.debug);
|
|
946
|
+
Check.typeOf.object("matrix", matrix);
|
|
947
|
+
Check.typeOf.object("result", result);
|
|
948
|
+
//>>includeEnd('debug');
|
|
1231
949
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
*
|
|
1244
|
-
* @see Matrix3.multiplyByScale
|
|
1245
|
-
* @see Matrix3.fromScale
|
|
1246
|
-
* @see Matrix3.fromUniformScale
|
|
1247
|
-
* @see Matrix3.setScale
|
|
1248
|
-
* @see Matrix3.setUniformScale
|
|
1249
|
-
* @see Matrix3.getScale
|
|
1250
|
-
*/
|
|
1251
|
-
Matrix3.multiplyByUniformScale = function (matrix, scale, result) {
|
|
1252
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1253
|
-
Check.typeOf.object("matrix", matrix);
|
|
1254
|
-
Check.typeOf.number("scale", scale);
|
|
1255
|
-
Check.typeOf.object("result", result);
|
|
1256
|
-
//>>includeEnd('debug');
|
|
1257
|
-
|
|
1258
|
-
result[0] = matrix[0] * scale;
|
|
1259
|
-
result[1] = matrix[1] * scale;
|
|
1260
|
-
result[2] = matrix[2] * scale;
|
|
1261
|
-
result[3] = matrix[3] * scale;
|
|
1262
|
-
result[4] = matrix[4] * scale;
|
|
1263
|
-
result[5] = matrix[5] * scale;
|
|
1264
|
-
result[6] = matrix[6] * scale;
|
|
1265
|
-
result[7] = matrix[7] * scale;
|
|
1266
|
-
result[8] = matrix[8] * scale;
|
|
950
|
+
result.x = Cartesian3.magnitude(
|
|
951
|
+
Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn),
|
|
952
|
+
);
|
|
953
|
+
result.y = Cartesian3.magnitude(
|
|
954
|
+
Cartesian3.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn),
|
|
955
|
+
);
|
|
956
|
+
result.z = Cartesian3.magnitude(
|
|
957
|
+
Cartesian3.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn),
|
|
958
|
+
);
|
|
959
|
+
return result;
|
|
960
|
+
}
|
|
1267
961
|
|
|
1268
|
-
|
|
1269
|
-
|
|
962
|
+
/**
|
|
963
|
+
* Computes the maximum scale assuming the matrix is an affine transformation.
|
|
964
|
+
* The maximum scale is the maximum length of the column vectors.
|
|
965
|
+
*
|
|
966
|
+
* @param {Matrix3} matrix The matrix.
|
|
967
|
+
* @returns {number} The maximum scale.
|
|
968
|
+
*/
|
|
969
|
+
static getMaximumScale(matrix) {
|
|
970
|
+
Matrix3.getScale(matrix, scaleScratch3);
|
|
971
|
+
return Cartesian3.maximumComponent(scaleScratch3);
|
|
972
|
+
}
|
|
1270
973
|
|
|
1271
|
-
/**
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
result[2] = -matrix[2];
|
|
1287
|
-
result[3] = -matrix[3];
|
|
1288
|
-
result[4] = -matrix[4];
|
|
1289
|
-
result[5] = -matrix[5];
|
|
1290
|
-
result[6] = -matrix[6];
|
|
1291
|
-
result[7] = -matrix[7];
|
|
1292
|
-
result[8] = -matrix[8];
|
|
1293
|
-
return result;
|
|
1294
|
-
};
|
|
974
|
+
/**
|
|
975
|
+
* Sets the rotation assuming the matrix is an affine transformation.
|
|
976
|
+
*
|
|
977
|
+
* @param {Matrix3} matrix The matrix.
|
|
978
|
+
* @param {Matrix3} rotation The rotation matrix.
|
|
979
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
980
|
+
* @returns {Matrix3} The modified result parameter.
|
|
981
|
+
*
|
|
982
|
+
* @see Matrix3.getRotation
|
|
983
|
+
*/
|
|
984
|
+
static setRotation(matrix, rotation, result) {
|
|
985
|
+
//>>includeStart('debug', pragmas.debug);
|
|
986
|
+
Check.typeOf.object("matrix", matrix);
|
|
987
|
+
Check.typeOf.object("result", result);
|
|
988
|
+
//>>includeEnd('debug');
|
|
1295
989
|
|
|
1296
|
-
|
|
1297
|
-
* Computes the transpose of the provided matrix.
|
|
1298
|
-
*
|
|
1299
|
-
* @param {Matrix3} matrix The matrix to transpose.
|
|
1300
|
-
* @param {Matrix3} result The object onto which to store the result.
|
|
1301
|
-
* @returns {Matrix3} The modified result parameter.
|
|
1302
|
-
*/
|
|
1303
|
-
Matrix3.transpose = function (matrix, result) {
|
|
1304
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1305
|
-
Check.typeOf.object("matrix", matrix);
|
|
1306
|
-
Check.typeOf.object("result", result);
|
|
1307
|
-
//>>includeEnd('debug');
|
|
1308
|
-
|
|
1309
|
-
const column0Row0 = matrix[0];
|
|
1310
|
-
const column0Row1 = matrix[3];
|
|
1311
|
-
const column0Row2 = matrix[6];
|
|
1312
|
-
const column1Row0 = matrix[1];
|
|
1313
|
-
const column1Row1 = matrix[4];
|
|
1314
|
-
const column1Row2 = matrix[7];
|
|
1315
|
-
const column2Row0 = matrix[2];
|
|
1316
|
-
const column2Row1 = matrix[5];
|
|
1317
|
-
const column2Row2 = matrix[8];
|
|
1318
|
-
|
|
1319
|
-
result[0] = column0Row0;
|
|
1320
|
-
result[1] = column0Row1;
|
|
1321
|
-
result[2] = column0Row2;
|
|
1322
|
-
result[3] = column1Row0;
|
|
1323
|
-
result[4] = column1Row1;
|
|
1324
|
-
result[5] = column1Row2;
|
|
1325
|
-
result[6] = column2Row0;
|
|
1326
|
-
result[7] = column2Row1;
|
|
1327
|
-
result[8] = column2Row2;
|
|
1328
|
-
return result;
|
|
1329
|
-
};
|
|
990
|
+
const scale = Matrix3.getScale(matrix, scaleScratch4);
|
|
1330
991
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
992
|
+
result[0] = rotation[0] * scale.x;
|
|
993
|
+
result[1] = rotation[1] * scale.x;
|
|
994
|
+
result[2] = rotation[2] * scale.x;
|
|
995
|
+
result[3] = rotation[3] * scale.y;
|
|
996
|
+
result[4] = rotation[4] * scale.y;
|
|
997
|
+
result[5] = rotation[5] * scale.y;
|
|
998
|
+
result[6] = rotation[6] * scale.z;
|
|
999
|
+
result[7] = rotation[7] * scale.z;
|
|
1000
|
+
result[8] = rotation[8] * scale.z;
|
|
1001
|
+
|
|
1002
|
+
return result;
|
|
1336
1003
|
}
|
|
1337
1004
|
|
|
1338
|
-
|
|
1339
|
-
|
|
1005
|
+
/**
|
|
1006
|
+
* Extracts the rotation matrix assuming the matrix is an affine transformation.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {Matrix3} matrix The matrix.
|
|
1009
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1010
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1011
|
+
*
|
|
1012
|
+
* @see Matrix3.setRotation
|
|
1013
|
+
*/
|
|
1014
|
+
static getRotation(matrix, result) {
|
|
1015
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1016
|
+
Check.typeOf.object("matrix", matrix);
|
|
1017
|
+
Check.typeOf.object("result", result);
|
|
1018
|
+
//>>includeEnd('debug');
|
|
1340
1019
|
|
|
1341
|
-
const
|
|
1342
|
-
const colVal = [2, 2, 1];
|
|
1020
|
+
const scale = Matrix3.getScale(matrix, scaleScratch5);
|
|
1343
1021
|
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1022
|
+
result[0] = matrix[0] / scale.x;
|
|
1023
|
+
result[1] = matrix[1] / scale.x;
|
|
1024
|
+
result[2] = matrix[2] / scale.x;
|
|
1025
|
+
result[3] = matrix[3] / scale.y;
|
|
1026
|
+
result[4] = matrix[4] / scale.y;
|
|
1027
|
+
result[5] = matrix[5] / scale.y;
|
|
1028
|
+
result[6] = matrix[6] / scale.z;
|
|
1029
|
+
result[7] = matrix[7] / scale.z;
|
|
1030
|
+
result[8] = matrix[8] / scale.z;
|
|
1347
1031
|
|
|
1348
|
-
|
|
1349
|
-
for (let i = 0; i < 3; ++i) {
|
|
1350
|
-
const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
|
|
1351
|
-
norm += 2.0 * temp * temp;
|
|
1032
|
+
return result;
|
|
1352
1033
|
}
|
|
1353
1034
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1035
|
+
/**
|
|
1036
|
+
* Computes the product of two matrices.
|
|
1037
|
+
*
|
|
1038
|
+
* @param {Matrix3} left The first matrix.
|
|
1039
|
+
* @param {Matrix3} right The second matrix.
|
|
1040
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1041
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1042
|
+
*/
|
|
1043
|
+
static multiply(left, right, result) {
|
|
1044
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1045
|
+
Check.typeOf.object("left", left);
|
|
1046
|
+
Check.typeOf.object("right", right);
|
|
1047
|
+
Check.typeOf.object("result", result);
|
|
1048
|
+
//>>includeEnd('debug');
|
|
1356
1049
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1050
|
+
const column0Row0 =
|
|
1051
|
+
left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
|
|
1052
|
+
const column0Row1 =
|
|
1053
|
+
left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
|
|
1054
|
+
const column0Row2 =
|
|
1055
|
+
left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
|
|
1056
|
+
|
|
1057
|
+
const column1Row0 =
|
|
1058
|
+
left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
|
|
1059
|
+
const column1Row1 =
|
|
1060
|
+
left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
|
|
1061
|
+
const column1Row2 =
|
|
1062
|
+
left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
|
|
1063
|
+
|
|
1064
|
+
const column2Row0 =
|
|
1065
|
+
left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
|
|
1066
|
+
const column2Row1 =
|
|
1067
|
+
left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
|
|
1068
|
+
const column2Row2 =
|
|
1069
|
+
left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
|
|
1070
|
+
|
|
1071
|
+
result[0] = column0Row0;
|
|
1072
|
+
result[1] = column0Row1;
|
|
1073
|
+
result[2] = column0Row2;
|
|
1074
|
+
result[3] = column1Row0;
|
|
1075
|
+
result[4] = column1Row1;
|
|
1076
|
+
result[5] = column1Row2;
|
|
1077
|
+
result[6] = column2Row0;
|
|
1078
|
+
result[7] = column2Row1;
|
|
1079
|
+
result[8] = column2Row2;
|
|
1080
|
+
return result;
|
|
1081
|
+
}
|
|
1364
1082
|
|
|
1365
|
-
|
|
1083
|
+
/**
|
|
1084
|
+
* Computes the sum of two matrices.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {Matrix3} left The first matrix.
|
|
1087
|
+
* @param {Matrix3} right The second matrix.
|
|
1088
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1089
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1090
|
+
*/
|
|
1091
|
+
static add(left, right, result) {
|
|
1092
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1093
|
+
Check.typeOf.object("left", left);
|
|
1094
|
+
Check.typeOf.object("right", right);
|
|
1095
|
+
Check.typeOf.object("result", result);
|
|
1096
|
+
//>>includeEnd('debug');
|
|
1366
1097
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1098
|
+
result[0] = left[0] + right[0];
|
|
1099
|
+
result[1] = left[1] + right[1];
|
|
1100
|
+
result[2] = left[2] + right[2];
|
|
1101
|
+
result[3] = left[3] + right[3];
|
|
1102
|
+
result[4] = left[4] + right[4];
|
|
1103
|
+
result[5] = left[5] + right[5];
|
|
1104
|
+
result[6] = left[6] + right[6];
|
|
1105
|
+
result[7] = left[7] + right[7];
|
|
1106
|
+
result[8] = left[8] + right[8];
|
|
1107
|
+
return result;
|
|
1108
|
+
}
|
|
1369
1109
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1110
|
+
/**
|
|
1111
|
+
* Computes the difference of two matrices.
|
|
1112
|
+
*
|
|
1113
|
+
* @param {Matrix3} left The first matrix.
|
|
1114
|
+
* @param {Matrix3} right The second matrix.
|
|
1115
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1116
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1117
|
+
*/
|
|
1118
|
+
static subtract(left, right, result) {
|
|
1119
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1120
|
+
Check.typeOf.object("left", left);
|
|
1121
|
+
Check.typeOf.object("right", right);
|
|
1122
|
+
Check.typeOf.object("result", result);
|
|
1123
|
+
//>>includeEnd('debug');
|
|
1124
|
+
|
|
1125
|
+
result[0] = left[0] - right[0];
|
|
1126
|
+
result[1] = left[1] - right[1];
|
|
1127
|
+
result[2] = left[2] - right[2];
|
|
1128
|
+
result[3] = left[3] - right[3];
|
|
1129
|
+
result[4] = left[4] - right[4];
|
|
1130
|
+
result[5] = left[5] - right[5];
|
|
1131
|
+
result[6] = left[6] - right[6];
|
|
1132
|
+
result[7] = left[7] - right[7];
|
|
1133
|
+
result[8] = left[8] - right[8];
|
|
1134
|
+
return result;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Computes the product of a matrix and a column vector.
|
|
1139
|
+
*
|
|
1140
|
+
* @param {Matrix3} matrix The matrix.
|
|
1141
|
+
* @param {Cartesian3} cartesian The column.
|
|
1142
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
1143
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
1144
|
+
*/
|
|
1145
|
+
static multiplyByVector(matrix, cartesian, result) {
|
|
1146
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1147
|
+
Check.typeOf.object("matrix", matrix);
|
|
1148
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
1149
|
+
Check.typeOf.object("result", result);
|
|
1150
|
+
//>>includeEnd('debug');
|
|
1151
|
+
|
|
1152
|
+
const vX = cartesian.x;
|
|
1153
|
+
const vY = cartesian.y;
|
|
1154
|
+
const vZ = cartesian.z;
|
|
1155
|
+
|
|
1156
|
+
const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
|
|
1157
|
+
const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
|
|
1158
|
+
const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
|
|
1159
|
+
|
|
1160
|
+
result.x = x;
|
|
1161
|
+
result.y = y;
|
|
1162
|
+
result.z = z;
|
|
1163
|
+
return result;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Computes the product of a matrix and a scalar.
|
|
1168
|
+
*
|
|
1169
|
+
* @param {Matrix3} matrix The matrix.
|
|
1170
|
+
* @param {number} scalar The number to multiply by.
|
|
1171
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1172
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1173
|
+
*/
|
|
1174
|
+
static multiplyByScalar(matrix, scalar, result) {
|
|
1175
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1176
|
+
Check.typeOf.object("matrix", matrix);
|
|
1177
|
+
Check.typeOf.number("scalar", scalar);
|
|
1178
|
+
Check.typeOf.object("result", result);
|
|
1179
|
+
//>>includeEnd('debug');
|
|
1180
|
+
|
|
1181
|
+
result[0] = matrix[0] * scalar;
|
|
1182
|
+
result[1] = matrix[1] * scalar;
|
|
1183
|
+
result[2] = matrix[2] * scalar;
|
|
1184
|
+
result[3] = matrix[3] * scalar;
|
|
1185
|
+
result[4] = matrix[4] * scalar;
|
|
1186
|
+
result[5] = matrix[5] * scalar;
|
|
1187
|
+
result[6] = matrix[6] * scalar;
|
|
1188
|
+
result[7] = matrix[7] * scalar;
|
|
1189
|
+
result[8] = matrix[8] * scalar;
|
|
1190
|
+
return result;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
|
|
1195
|
+
*
|
|
1196
|
+
* @param {Matrix3} matrix The matrix on the left-hand side.
|
|
1197
|
+
* @param {Cartesian3} scale The non-uniform scale on the right-hand side.
|
|
1198
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1199
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1200
|
+
*
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromScale(scale), m);
|
|
1204
|
+
* Cesium.Matrix3.multiplyByScale(m, scale, m);
|
|
1205
|
+
*
|
|
1206
|
+
* @see Matrix3.multiplyByUniformScale
|
|
1207
|
+
* @see Matrix3.fromScale
|
|
1208
|
+
* @see Matrix3.fromUniformScale
|
|
1209
|
+
* @see Matrix3.setScale
|
|
1210
|
+
* @see Matrix3.setUniformScale
|
|
1211
|
+
* @see Matrix3.getScale
|
|
1212
|
+
*/
|
|
1213
|
+
static multiplyByScale(matrix, scale, result) {
|
|
1214
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1215
|
+
Check.typeOf.object("matrix", matrix);
|
|
1216
|
+
Check.typeOf.object("scale", scale);
|
|
1217
|
+
Check.typeOf.object("result", result);
|
|
1218
|
+
//>>includeEnd('debug');
|
|
1219
|
+
|
|
1220
|
+
result[0] = matrix[0] * scale.x;
|
|
1221
|
+
result[1] = matrix[1] * scale.x;
|
|
1222
|
+
result[2] = matrix[2] * scale.x;
|
|
1223
|
+
result[3] = matrix[3] * scale.y;
|
|
1224
|
+
result[4] = matrix[4] * scale.y;
|
|
1225
|
+
result[5] = matrix[5] * scale.y;
|
|
1226
|
+
result[6] = matrix[6] * scale.z;
|
|
1227
|
+
result[7] = matrix[7] * scale.z;
|
|
1228
|
+
result[8] = matrix[8] * scale.z;
|
|
1229
|
+
|
|
1230
|
+
return result;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.
|
|
1235
|
+
*
|
|
1236
|
+
* @param {Matrix3} matrix The matrix on the left-hand side.
|
|
1237
|
+
* @param {number} scale The uniform scale on the right-hand side.
|
|
1238
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1239
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromUniformScale(scale), m);
|
|
1243
|
+
* Cesium.Matrix3.multiplyByUniformScale(m, scale, m);
|
|
1244
|
+
*
|
|
1245
|
+
* @see Matrix3.multiplyByScale
|
|
1246
|
+
* @see Matrix3.fromScale
|
|
1247
|
+
* @see Matrix3.fromUniformScale
|
|
1248
|
+
* @see Matrix3.setScale
|
|
1249
|
+
* @see Matrix3.setUniformScale
|
|
1250
|
+
* @see Matrix3.getScale
|
|
1251
|
+
*/
|
|
1252
|
+
static multiplyByUniformScale(matrix, scale, result) {
|
|
1253
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1254
|
+
Check.typeOf.object("matrix", matrix);
|
|
1255
|
+
Check.typeOf.number("scale", scale);
|
|
1256
|
+
Check.typeOf.object("result", result);
|
|
1257
|
+
//>>includeEnd('debug');
|
|
1258
|
+
|
|
1259
|
+
result[0] = matrix[0] * scale;
|
|
1260
|
+
result[1] = matrix[1] * scale;
|
|
1261
|
+
result[2] = matrix[2] * scale;
|
|
1262
|
+
result[3] = matrix[3] * scale;
|
|
1263
|
+
result[4] = matrix[4] * scale;
|
|
1264
|
+
result[5] = matrix[5] * scale;
|
|
1265
|
+
result[6] = matrix[6] * scale;
|
|
1266
|
+
result[7] = matrix[7] * scale;
|
|
1267
|
+
result[8] = matrix[8] * scale;
|
|
1268
|
+
|
|
1269
|
+
return result;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Creates a negated copy of the provided matrix.
|
|
1274
|
+
*
|
|
1275
|
+
* @param {Matrix3} matrix The matrix to negate.
|
|
1276
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1277
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1278
|
+
*/
|
|
1279
|
+
static negate(matrix, result) {
|
|
1280
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1281
|
+
Check.typeOf.object("matrix", matrix);
|
|
1282
|
+
Check.typeOf.object("result", result);
|
|
1283
|
+
//>>includeEnd('debug');
|
|
1284
|
+
|
|
1285
|
+
result[0] = -matrix[0];
|
|
1286
|
+
result[1] = -matrix[1];
|
|
1287
|
+
result[2] = -matrix[2];
|
|
1288
|
+
result[3] = -matrix[3];
|
|
1289
|
+
result[4] = -matrix[4];
|
|
1290
|
+
result[5] = -matrix[5];
|
|
1291
|
+
result[6] = -matrix[6];
|
|
1292
|
+
result[7] = -matrix[7];
|
|
1293
|
+
result[8] = -matrix[8];
|
|
1294
|
+
return result;
|
|
1379
1295
|
}
|
|
1380
1296
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1297
|
+
/**
|
|
1298
|
+
* Computes the transpose of the provided matrix.
|
|
1299
|
+
*
|
|
1300
|
+
* @param {Matrix3} matrix The matrix to transpose.
|
|
1301
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1302
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1303
|
+
*/
|
|
1304
|
+
static transpose(matrix, result) {
|
|
1305
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1306
|
+
Check.typeOf.object("matrix", matrix);
|
|
1307
|
+
Check.typeOf.object("result", result);
|
|
1308
|
+
//>>includeEnd('debug');
|
|
1383
1309
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1310
|
+
const column0Row0 = matrix[0];
|
|
1311
|
+
const column0Row1 = matrix[3];
|
|
1312
|
+
const column0Row2 = matrix[6];
|
|
1313
|
+
const column1Row0 = matrix[1];
|
|
1314
|
+
const column1Row1 = matrix[4];
|
|
1315
|
+
const column1Row2 = matrix[7];
|
|
1316
|
+
const column2Row0 = matrix[2];
|
|
1317
|
+
const column2Row1 = matrix[5];
|
|
1318
|
+
const column2Row2 = matrix[8];
|
|
1319
|
+
|
|
1320
|
+
result[0] = column0Row0;
|
|
1321
|
+
result[1] = column0Row1;
|
|
1322
|
+
result[2] = column0Row2;
|
|
1323
|
+
result[3] = column1Row0;
|
|
1324
|
+
result[4] = column1Row1;
|
|
1325
|
+
result[5] = column1Row2;
|
|
1326
|
+
result[6] = column2Row0;
|
|
1327
|
+
result[7] = column2Row1;
|
|
1328
|
+
result[8] = column2Row2;
|
|
1329
|
+
return result;
|
|
1330
|
+
}
|
|
1386
1331
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* Computes the eigenvectors and eigenvalues of a symmetric matrix.
|
|
1334
|
+
* <p>
|
|
1335
|
+
* Returns a diagonal matrix and unitary matrix such that:
|
|
1336
|
+
* <code>matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)</code>
|
|
1337
|
+
* </p>
|
|
1338
|
+
* <p>
|
|
1339
|
+
* The values along the diagonal of the diagonal matrix are the eigenvalues. The columns
|
|
1340
|
+
* of the unitary matrix are the corresponding eigenvectors.
|
|
1341
|
+
* </p>
|
|
1342
|
+
*
|
|
1343
|
+
* @param {Matrix3} matrix The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.
|
|
1344
|
+
* @param {EigenDecompositionResult} [result] An object with unitary and diagonal properties which are matrices onto which to store the result.
|
|
1345
|
+
* @returns {EigenDecompositionResult} An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
|
|
1346
|
+
*
|
|
1347
|
+
* @example
|
|
1348
|
+
* const a = //... symetric matrix
|
|
1349
|
+
* const result = {
|
|
1350
|
+
* unitary : new Cesium.Matrix3(),
|
|
1351
|
+
* diagonal : new Cesium.Matrix3()
|
|
1352
|
+
* };
|
|
1353
|
+
* Cesium.Matrix3.computeEigenDecomposition(a, result);
|
|
1354
|
+
*
|
|
1355
|
+
* const unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());
|
|
1356
|
+
* const b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());
|
|
1357
|
+
* Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
|
|
1358
|
+
*
|
|
1359
|
+
* const lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x; // first eigenvalue
|
|
1360
|
+
* const v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3()); // first eigenvector
|
|
1361
|
+
* const c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3()); // equal to Cesium.Matrix3.multiplyByVector(a, v)
|
|
1362
|
+
*/
|
|
1363
|
+
static computeEigenDecomposition(matrix, result) {
|
|
1364
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1365
|
+
Check.typeOf.object("matrix", matrix);
|
|
1366
|
+
//>>includeEnd('debug');
|
|
1391
1367
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1368
|
+
// This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
|
|
1369
|
+
// section 8.4.3 The Classical Jacobi Algorithm
|
|
1394
1370
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1371
|
+
const tolerance = CesiumMath.EPSILON20;
|
|
1372
|
+
const maxSweeps = 10;
|
|
1373
|
+
|
|
1374
|
+
let count = 0;
|
|
1375
|
+
let sweep = 0;
|
|
1376
|
+
|
|
1377
|
+
if (!defined(result)) {
|
|
1378
|
+
result = {};
|
|
1399
1379
|
}
|
|
1400
1380
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1381
|
+
const unitaryMatrix = (result.unitary = Matrix3.clone(
|
|
1382
|
+
Matrix3.IDENTITY,
|
|
1383
|
+
result.unitary,
|
|
1384
|
+
));
|
|
1385
|
+
const diagMatrix = (result.diagonal = Matrix3.clone(
|
|
1386
|
+
matrix,
|
|
1387
|
+
result.diagonal,
|
|
1388
|
+
));
|
|
1389
|
+
|
|
1390
|
+
const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
|
|
1391
|
+
|
|
1392
|
+
while (
|
|
1393
|
+
sweep < maxSweeps &&
|
|
1394
|
+
offDiagonalFrobeniusNorm(diagMatrix) > epsilon
|
|
1395
|
+
) {
|
|
1396
|
+
shurDecomposition(diagMatrix, jMatrix);
|
|
1397
|
+
Matrix3.transpose(jMatrix, jMatrixTranspose);
|
|
1398
|
+
Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
|
|
1399
|
+
Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
|
|
1400
|
+
Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
|
|
1401
|
+
|
|
1402
|
+
if (++count > 2) {
|
|
1403
|
+
++sweep;
|
|
1404
|
+
count = 0;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
return result;
|
|
1403
1409
|
}
|
|
1404
1410
|
|
|
1405
|
-
|
|
1411
|
+
/**
|
|
1412
|
+
* Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
|
|
1413
|
+
*
|
|
1414
|
+
* @param {Matrix3} matrix The matrix with signed elements.
|
|
1415
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1416
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1417
|
+
*/
|
|
1418
|
+
static abs(matrix, result) {
|
|
1419
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1420
|
+
Check.typeOf.object("matrix", matrix);
|
|
1421
|
+
Check.typeOf.object("result", result);
|
|
1422
|
+
//>>includeEnd('debug');
|
|
1406
1423
|
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1424
|
+
result[0] = Math.abs(matrix[0]);
|
|
1425
|
+
result[1] = Math.abs(matrix[1]);
|
|
1426
|
+
result[2] = Math.abs(matrix[2]);
|
|
1427
|
+
result[3] = Math.abs(matrix[3]);
|
|
1428
|
+
result[4] = Math.abs(matrix[4]);
|
|
1429
|
+
result[5] = Math.abs(matrix[5]);
|
|
1430
|
+
result[6] = Math.abs(matrix[6]);
|
|
1431
|
+
result[7] = Math.abs(matrix[7]);
|
|
1432
|
+
result[8] = Math.abs(matrix[8]);
|
|
1433
|
+
|
|
1434
|
+
return result;
|
|
1435
|
+
}
|
|
1412
1436
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1437
|
+
/**
|
|
1438
|
+
* Computes the determinant of the provided matrix.
|
|
1439
|
+
*
|
|
1440
|
+
* @param {Matrix3} matrix The matrix to use.
|
|
1441
|
+
* @returns {number} The value of the determinant of the matrix.
|
|
1442
|
+
*/
|
|
1443
|
+
static determinant(matrix) {
|
|
1444
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1445
|
+
Check.typeOf.object("matrix", matrix);
|
|
1446
|
+
//>>includeEnd('debug');
|
|
1415
1447
|
|
|
1416
|
-
const
|
|
1417
|
-
const
|
|
1448
|
+
const m11 = matrix[0];
|
|
1449
|
+
const m21 = matrix[3];
|
|
1450
|
+
const m31 = matrix[6];
|
|
1451
|
+
const m12 = matrix[1];
|
|
1452
|
+
const m22 = matrix[4];
|
|
1453
|
+
const m32 = matrix[7];
|
|
1454
|
+
const m13 = matrix[2];
|
|
1455
|
+
const m23 = matrix[5];
|
|
1456
|
+
const m33 = matrix[8];
|
|
1457
|
+
|
|
1458
|
+
return (
|
|
1459
|
+
m11 * (m22 * m33 - m23 * m32) +
|
|
1460
|
+
m12 * (m23 * m31 - m21 * m33) +
|
|
1461
|
+
m13 * (m21 * m32 - m22 * m31)
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1418
1464
|
|
|
1419
|
-
/**
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
*
|
|
1434
|
-
* @example
|
|
1435
|
-
* const a = //... symetric matrix
|
|
1436
|
-
* const result = {
|
|
1437
|
-
* unitary : new Cesium.Matrix3(),
|
|
1438
|
-
* diagonal : new Cesium.Matrix3()
|
|
1439
|
-
* };
|
|
1440
|
-
* Cesium.Matrix3.computeEigenDecomposition(a, result);
|
|
1441
|
-
*
|
|
1442
|
-
* const unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());
|
|
1443
|
-
* const b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());
|
|
1444
|
-
* Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
|
|
1445
|
-
*
|
|
1446
|
-
* const lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x; // first eigenvalue
|
|
1447
|
-
* const v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3()); // first eigenvector
|
|
1448
|
-
* const c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3()); // equal to Cesium.Matrix3.multiplyByVector(a, v)
|
|
1449
|
-
*/
|
|
1450
|
-
Matrix3.computeEigenDecomposition = function (matrix, result) {
|
|
1451
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1452
|
-
Check.typeOf.object("matrix", matrix);
|
|
1453
|
-
//>>includeEnd('debug');
|
|
1465
|
+
/**
|
|
1466
|
+
* Computes the inverse of the provided matrix.
|
|
1467
|
+
*
|
|
1468
|
+
* @param {Matrix3} matrix The matrix to invert.
|
|
1469
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1470
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1471
|
+
*
|
|
1472
|
+
* @exception {DeveloperError} matrix is not invertible.
|
|
1473
|
+
*/
|
|
1474
|
+
static inverse(matrix, result) {
|
|
1475
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1476
|
+
Check.typeOf.object("matrix", matrix);
|
|
1477
|
+
Check.typeOf.object("result", result);
|
|
1478
|
+
//>>includeEnd('debug');
|
|
1454
1479
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1480
|
+
const m11 = matrix[0];
|
|
1481
|
+
const m21 = matrix[1];
|
|
1482
|
+
const m31 = matrix[2];
|
|
1483
|
+
const m12 = matrix[3];
|
|
1484
|
+
const m22 = matrix[4];
|
|
1485
|
+
const m32 = matrix[5];
|
|
1486
|
+
const m13 = matrix[6];
|
|
1487
|
+
const m23 = matrix[7];
|
|
1488
|
+
const m33 = matrix[8];
|
|
1457
1489
|
|
|
1458
|
-
|
|
1459
|
-
const maxSweeps = 10;
|
|
1490
|
+
const determinant = Matrix3.determinant(matrix);
|
|
1460
1491
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1492
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1493
|
+
if (Math.abs(determinant) <= CesiumMath.EPSILON15) {
|
|
1494
|
+
throw new DeveloperError("matrix is not invertible");
|
|
1495
|
+
}
|
|
1496
|
+
//>>includeEnd('debug');
|
|
1463
1497
|
|
|
1464
|
-
|
|
1465
|
-
result =
|
|
1498
|
+
result[0] = m22 * m33 - m23 * m32;
|
|
1499
|
+
result[1] = m23 * m31 - m21 * m33;
|
|
1500
|
+
result[2] = m21 * m32 - m22 * m31;
|
|
1501
|
+
result[3] = m13 * m32 - m12 * m33;
|
|
1502
|
+
result[4] = m11 * m33 - m13 * m31;
|
|
1503
|
+
result[5] = m12 * m31 - m11 * m32;
|
|
1504
|
+
result[6] = m12 * m23 - m13 * m22;
|
|
1505
|
+
result[7] = m13 * m21 - m11 * m23;
|
|
1506
|
+
result[8] = m11 * m22 - m12 * m21;
|
|
1507
|
+
|
|
1508
|
+
const scale = 1.0 / determinant;
|
|
1509
|
+
return Matrix3.multiplyByScalar(result, scale, result);
|
|
1466
1510
|
}
|
|
1467
1511
|
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1512
|
+
/**
|
|
1513
|
+
* Computes the inverse transpose of a matrix.
|
|
1514
|
+
*
|
|
1515
|
+
* @param {Matrix3} matrix The matrix to transpose and invert.
|
|
1516
|
+
* @param {Matrix3} result The object onto which to store the result.
|
|
1517
|
+
* @returns {Matrix3} The modified result parameter.
|
|
1518
|
+
*/
|
|
1519
|
+
static inverseTranspose(matrix, result) {
|
|
1520
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1521
|
+
Check.typeOf.object("matrix", matrix);
|
|
1522
|
+
Check.typeOf.object("result", result);
|
|
1523
|
+
//>>includeEnd('debug');
|
|
1473
1524
|
|
|
1474
|
-
|
|
1525
|
+
return Matrix3.inverse(
|
|
1526
|
+
Matrix3.transpose(matrix, scratchTransposeMatrix),
|
|
1527
|
+
result,
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1475
1530
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1531
|
+
/**
|
|
1532
|
+
* Compares the provided matrices componentwise and returns
|
|
1533
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1534
|
+
*
|
|
1535
|
+
* @param {Matrix3} [left] The first matrix.
|
|
1536
|
+
* @param {Matrix3} [right] The second matrix.
|
|
1537
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
1538
|
+
*/
|
|
1539
|
+
static equals(left, right) {
|
|
1540
|
+
return (
|
|
1541
|
+
left === right ||
|
|
1542
|
+
(defined(left) &&
|
|
1543
|
+
defined(right) &&
|
|
1544
|
+
left[0] === right[0] &&
|
|
1545
|
+
left[1] === right[1] &&
|
|
1546
|
+
left[2] === right[2] &&
|
|
1547
|
+
left[3] === right[3] &&
|
|
1548
|
+
left[4] === right[4] &&
|
|
1549
|
+
left[5] === right[5] &&
|
|
1550
|
+
left[6] === right[6] &&
|
|
1551
|
+
left[7] === right[7] &&
|
|
1552
|
+
left[8] === right[8])
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1482
1555
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1556
|
+
/**
|
|
1557
|
+
* Compares the provided matrices componentwise and returns
|
|
1558
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
1559
|
+
* <code>false</code> otherwise.
|
|
1560
|
+
*
|
|
1561
|
+
* @param {Matrix3} [left] The first matrix.
|
|
1562
|
+
* @param {Matrix3} [right] The second matrix.
|
|
1563
|
+
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
1564
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
1565
|
+
*/
|
|
1566
|
+
static equalsEpsilon(left, right, epsilon) {
|
|
1567
|
+
epsilon = epsilon ?? 0;
|
|
1568
|
+
|
|
1569
|
+
return (
|
|
1570
|
+
left === right ||
|
|
1571
|
+
(defined(left) &&
|
|
1572
|
+
defined(right) &&
|
|
1573
|
+
Math.abs(left[0] - right[0]) <= epsilon &&
|
|
1574
|
+
Math.abs(left[1] - right[1]) <= epsilon &&
|
|
1575
|
+
Math.abs(left[2] - right[2]) <= epsilon &&
|
|
1576
|
+
Math.abs(left[3] - right[3]) <= epsilon &&
|
|
1577
|
+
Math.abs(left[4] - right[4]) <= epsilon &&
|
|
1578
|
+
Math.abs(left[5] - right[5]) <= epsilon &&
|
|
1579
|
+
Math.abs(left[6] - right[6]) <= epsilon &&
|
|
1580
|
+
Math.abs(left[7] - right[7]) <= epsilon &&
|
|
1581
|
+
Math.abs(left[8] - right[8]) <= epsilon)
|
|
1582
|
+
);
|
|
1487
1583
|
}
|
|
1488
1584
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1585
|
+
/**
|
|
1586
|
+
* Gets the number of items in the collection.
|
|
1587
|
+
*
|
|
1588
|
+
* @type {number}
|
|
1589
|
+
*/
|
|
1590
|
+
get length() {
|
|
1591
|
+
return Matrix3.packedLength;
|
|
1592
|
+
}
|
|
1491
1593
|
|
|
1492
|
-
/**
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
Matrix3.
|
|
1500
|
-
|
|
1501
|
-
Check.typeOf.object("matrix", matrix);
|
|
1502
|
-
Check.typeOf.object("result", result);
|
|
1503
|
-
//>>includeEnd('debug');
|
|
1504
|
-
|
|
1505
|
-
result[0] = Math.abs(matrix[0]);
|
|
1506
|
-
result[1] = Math.abs(matrix[1]);
|
|
1507
|
-
result[2] = Math.abs(matrix[2]);
|
|
1508
|
-
result[3] = Math.abs(matrix[3]);
|
|
1509
|
-
result[4] = Math.abs(matrix[4]);
|
|
1510
|
-
result[5] = Math.abs(matrix[5]);
|
|
1511
|
-
result[6] = Math.abs(matrix[6]);
|
|
1512
|
-
result[7] = Math.abs(matrix[7]);
|
|
1513
|
-
result[8] = Math.abs(matrix[8]);
|
|
1594
|
+
/**
|
|
1595
|
+
* Duplicates the provided Matrix3 instance.
|
|
1596
|
+
*
|
|
1597
|
+
* @param {Matrix3} [result] The object onto which to store the result.
|
|
1598
|
+
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
|
|
1599
|
+
*/
|
|
1600
|
+
clone(result) {
|
|
1601
|
+
return Matrix3.clone(this, result);
|
|
1602
|
+
}
|
|
1514
1603
|
|
|
1515
|
-
|
|
1516
|
-
|
|
1604
|
+
/**
|
|
1605
|
+
* Compares this matrix to the provided matrix componentwise and returns
|
|
1606
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1607
|
+
*
|
|
1608
|
+
* @param {Matrix3} [right] The right hand side matrix.
|
|
1609
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1610
|
+
*/
|
|
1611
|
+
equals(right) {
|
|
1612
|
+
return Matrix3.equals(this, right);
|
|
1613
|
+
}
|
|
1517
1614
|
|
|
1518
|
-
/**
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
return (
|
|
1540
|
-
m11 * (m22 * m33 - m23 * m32) +
|
|
1541
|
-
m12 * (m23 * m31 - m21 * m33) +
|
|
1542
|
-
m13 * (m21 * m32 - m22 * m31)
|
|
1543
|
-
);
|
|
1544
|
-
};
|
|
1615
|
+
/**
|
|
1616
|
+
* Compares provided matrix and array, starting from a given array offset.
|
|
1617
|
+
*
|
|
1618
|
+
* @param {Matrix3} matrix
|
|
1619
|
+
* @param {number[]} array
|
|
1620
|
+
* @param {number} offset
|
|
1621
|
+
* @private
|
|
1622
|
+
*/
|
|
1623
|
+
static equalsArray(matrix, array, offset) {
|
|
1624
|
+
return (
|
|
1625
|
+
matrix[0] === array[offset] &&
|
|
1626
|
+
matrix[1] === array[offset + 1] &&
|
|
1627
|
+
matrix[2] === array[offset + 2] &&
|
|
1628
|
+
matrix[3] === array[offset + 3] &&
|
|
1629
|
+
matrix[4] === array[offset + 4] &&
|
|
1630
|
+
matrix[5] === array[offset + 5] &&
|
|
1631
|
+
matrix[6] === array[offset + 6] &&
|
|
1632
|
+
matrix[7] === array[offset + 7] &&
|
|
1633
|
+
matrix[8] === array[offset + 8]
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1545
1636
|
|
|
1546
|
-
/**
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
Check.typeOf.object("matrix", matrix);
|
|
1558
|
-
Check.typeOf.object("result", result);
|
|
1559
|
-
//>>includeEnd('debug');
|
|
1560
|
-
|
|
1561
|
-
const m11 = matrix[0];
|
|
1562
|
-
const m21 = matrix[1];
|
|
1563
|
-
const m31 = matrix[2];
|
|
1564
|
-
const m12 = matrix[3];
|
|
1565
|
-
const m22 = matrix[4];
|
|
1566
|
-
const m32 = matrix[5];
|
|
1567
|
-
const m13 = matrix[6];
|
|
1568
|
-
const m23 = matrix[7];
|
|
1569
|
-
const m33 = matrix[8];
|
|
1570
|
-
|
|
1571
|
-
const determinant = Matrix3.determinant(matrix);
|
|
1572
|
-
|
|
1573
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1574
|
-
if (Math.abs(determinant) <= CesiumMath.EPSILON15) {
|
|
1575
|
-
throw new DeveloperError("matrix is not invertible");
|
|
1637
|
+
/**
|
|
1638
|
+
* Compares this matrix to the provided matrix componentwise and returns
|
|
1639
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
1640
|
+
* <code>false</code> otherwise.
|
|
1641
|
+
*
|
|
1642
|
+
* @param {Matrix3} [right] The right hand side matrix.
|
|
1643
|
+
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
1644
|
+
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
1645
|
+
*/
|
|
1646
|
+
equalsEpsilon(right, epsilon) {
|
|
1647
|
+
return Matrix3.equalsEpsilon(this, right, epsilon);
|
|
1576
1648
|
}
|
|
1577
|
-
//>>includeEnd('debug');
|
|
1578
|
-
|
|
1579
|
-
result[0] = m22 * m33 - m23 * m32;
|
|
1580
|
-
result[1] = m23 * m31 - m21 * m33;
|
|
1581
|
-
result[2] = m21 * m32 - m22 * m31;
|
|
1582
|
-
result[3] = m13 * m32 - m12 * m33;
|
|
1583
|
-
result[4] = m11 * m33 - m13 * m31;
|
|
1584
|
-
result[5] = m12 * m31 - m11 * m32;
|
|
1585
|
-
result[6] = m12 * m23 - m13 * m22;
|
|
1586
|
-
result[7] = m13 * m21 - m11 * m23;
|
|
1587
|
-
result[8] = m11 * m22 - m12 * m21;
|
|
1588
|
-
|
|
1589
|
-
const scale = 1.0 / determinant;
|
|
1590
|
-
return Matrix3.multiplyByScalar(result, scale, result);
|
|
1591
|
-
};
|
|
1592
1649
|
|
|
1593
|
-
|
|
1650
|
+
/**
|
|
1651
|
+
* Creates a string representing this Matrix with each row being
|
|
1652
|
+
* on a separate line and in the format '(column0, column1, column2)'.
|
|
1653
|
+
*
|
|
1654
|
+
* @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2)'.
|
|
1655
|
+
*/
|
|
1656
|
+
toString() {
|
|
1657
|
+
return (
|
|
1658
|
+
`(${this[0]}, ${this[3]}, ${this[6]})\n` +
|
|
1659
|
+
`(${this[1]}, ${this[4]}, ${this[7]})\n` +
|
|
1660
|
+
`(${this[2]}, ${this[5]}, ${this[8]})`
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1594
1664
|
|
|
1595
1665
|
/**
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1598
|
-
* @param {Matrix3} matrix The matrix to transpose and invert.
|
|
1599
|
-
* @param {Matrix3} result The object onto which to store the result.
|
|
1600
|
-
* @returns {Matrix3} The modified result parameter.
|
|
1666
|
+
* The number of elements used to pack the object into an array.
|
|
1667
|
+
* @type {number}
|
|
1601
1668
|
*/
|
|
1602
|
-
Matrix3.
|
|
1603
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1604
|
-
Check.typeOf.object("matrix", matrix);
|
|
1605
|
-
Check.typeOf.object("result", result);
|
|
1606
|
-
//>>includeEnd('debug');
|
|
1607
|
-
|
|
1608
|
-
return Matrix3.inverse(
|
|
1609
|
-
Matrix3.transpose(matrix, scratchTransposeMatrix),
|
|
1610
|
-
result,
|
|
1611
|
-
);
|
|
1612
|
-
};
|
|
1669
|
+
Matrix3.packedLength = 9;
|
|
1613
1670
|
|
|
1614
1671
|
/**
|
|
1615
|
-
*
|
|
1616
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1672
|
+
* Creates a Matrix3 from 9 consecutive elements in an array.
|
|
1617
1673
|
*
|
|
1618
|
-
* @
|
|
1619
|
-
* @param {
|
|
1620
|
-
* @
|
|
1621
|
-
|
|
1622
|
-
Matrix3
|
|
1623
|
-
return (
|
|
1624
|
-
left === right ||
|
|
1625
|
-
(defined(left) &&
|
|
1626
|
-
defined(right) &&
|
|
1627
|
-
left[0] === right[0] &&
|
|
1628
|
-
left[1] === right[1] &&
|
|
1629
|
-
left[2] === right[2] &&
|
|
1630
|
-
left[3] === right[3] &&
|
|
1631
|
-
left[4] === right[4] &&
|
|
1632
|
-
left[5] === right[5] &&
|
|
1633
|
-
left[6] === right[6] &&
|
|
1634
|
-
left[7] === right[7] &&
|
|
1635
|
-
left[8] === right[8])
|
|
1636
|
-
);
|
|
1637
|
-
};
|
|
1638
|
-
|
|
1639
|
-
/**
|
|
1640
|
-
* Compares the provided matrices componentwise and returns
|
|
1641
|
-
* <code>true</code> if they are within the provided epsilon,
|
|
1642
|
-
* <code>false</code> otherwise.
|
|
1674
|
+
* @function
|
|
1675
|
+
* @param {number[]} array The array whose 9 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
|
|
1676
|
+
* @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.
|
|
1677
|
+
* @param {Matrix3} [result] The object onto which to store the result.
|
|
1678
|
+
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
|
|
1643
1679
|
*
|
|
1644
|
-
* @
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1680
|
+
* @example
|
|
1681
|
+
* // Create the Matrix3:
|
|
1682
|
+
* // [1.0, 2.0, 3.0]
|
|
1683
|
+
* // [1.0, 2.0, 3.0]
|
|
1684
|
+
* // [1.0, 2.0, 3.0]
|
|
1685
|
+
*
|
|
1686
|
+
* const v = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
|
|
1687
|
+
* const m = Cesium.Matrix3.fromArray(v);
|
|
1688
|
+
*
|
|
1689
|
+
* // Create same Matrix3 with using an offset into an array
|
|
1690
|
+
* const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
|
|
1691
|
+
* const m2 = Cesium.Matrix3.fromArray(v2, 2);
|
|
1648
1692
|
*/
|
|
1649
|
-
Matrix3.
|
|
1650
|
-
epsilon = epsilon ?? 0;
|
|
1651
|
-
|
|
1652
|
-
return (
|
|
1653
|
-
left === right ||
|
|
1654
|
-
(defined(left) &&
|
|
1655
|
-
defined(right) &&
|
|
1656
|
-
Math.abs(left[0] - right[0]) <= epsilon &&
|
|
1657
|
-
Math.abs(left[1] - right[1]) <= epsilon &&
|
|
1658
|
-
Math.abs(left[2] - right[2]) <= epsilon &&
|
|
1659
|
-
Math.abs(left[3] - right[3]) <= epsilon &&
|
|
1660
|
-
Math.abs(left[4] - right[4]) <= epsilon &&
|
|
1661
|
-
Math.abs(left[5] - right[5]) <= epsilon &&
|
|
1662
|
-
Math.abs(left[6] - right[6]) <= epsilon &&
|
|
1663
|
-
Math.abs(left[7] - right[7]) <= epsilon &&
|
|
1664
|
-
Math.abs(left[8] - right[8]) <= epsilon)
|
|
1665
|
-
);
|
|
1666
|
-
};
|
|
1693
|
+
Matrix3.fromArray = Matrix3.unpack;
|
|
1667
1694
|
|
|
1668
1695
|
/**
|
|
1669
1696
|
* An immutable Matrix3 instance initialized to the identity matrix.
|
|
@@ -1757,82 +1784,123 @@ Matrix3.COLUMN2ROW1 = 7;
|
|
|
1757
1784
|
*/
|
|
1758
1785
|
Matrix3.COLUMN2ROW2 = 8;
|
|
1759
1786
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
*/
|
|
1767
|
-
length: {
|
|
1768
|
-
get: function () {
|
|
1769
|
-
return Matrix3.packedLength;
|
|
1770
|
-
},
|
|
1771
|
-
},
|
|
1772
|
-
});
|
|
1787
|
+
const scaleScratch1 = new Cartesian3();
|
|
1788
|
+
const scaleScratch2 = new Cartesian3();
|
|
1789
|
+
const scratchColumn = new Cartesian3();
|
|
1790
|
+
const scaleScratch3 = new Cartesian3();
|
|
1791
|
+
const scaleScratch4 = new Cartesian3();
|
|
1792
|
+
const scaleScratch5 = new Cartesian3();
|
|
1773
1793
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
* @param {Matrix3} [result] The object onto which to store the result.
|
|
1778
|
-
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
|
|
1779
|
-
*/
|
|
1780
|
-
Matrix3.prototype.clone = function (result) {
|
|
1781
|
-
return Matrix3.clone(this, result);
|
|
1782
|
-
};
|
|
1794
|
+
const jMatrix = new Matrix3();
|
|
1795
|
+
const jMatrixTranspose = new Matrix3();
|
|
1796
|
+
const scratchTransposeMatrix = new Matrix3();
|
|
1783
1797
|
|
|
1784
1798
|
/**
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
1787
|
-
*
|
|
1788
|
-
* @param {Matrix3} [right] The right hand side matrix.
|
|
1789
|
-
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1799
|
+
* @param {Matrix3} matrix
|
|
1800
|
+
* @ignore
|
|
1790
1801
|
*/
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1802
|
+
function computeFrobeniusNorm(matrix) {
|
|
1803
|
+
let norm = 0.0;
|
|
1804
|
+
for (let i = 0; i < 9; ++i) {
|
|
1805
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1806
|
+
const temp = matrix[i];
|
|
1807
|
+
norm += temp * temp;
|
|
1808
|
+
}
|
|
1794
1809
|
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
matrix[0] === array[offset] &&
|
|
1801
|
-
matrix[1] === array[offset + 1] &&
|
|
1802
|
-
matrix[2] === array[offset + 2] &&
|
|
1803
|
-
matrix[3] === array[offset + 3] &&
|
|
1804
|
-
matrix[4] === array[offset + 4] &&
|
|
1805
|
-
matrix[5] === array[offset + 5] &&
|
|
1806
|
-
matrix[6] === array[offset + 6] &&
|
|
1807
|
-
matrix[7] === array[offset + 7] &&
|
|
1808
|
-
matrix[8] === array[offset + 8]
|
|
1809
|
-
);
|
|
1810
|
-
};
|
|
1810
|
+
return Math.sqrt(norm);
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
const rowVal = [1, 0, 0];
|
|
1814
|
+
const colVal = [2, 2, 1];
|
|
1811
1815
|
|
|
1812
1816
|
/**
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1815
|
-
* <code>false</code> otherwise.
|
|
1816
|
-
*
|
|
1817
|
-
* @param {Matrix3} [right] The right hand side matrix.
|
|
1818
|
-
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
1819
|
-
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
1817
|
+
* @param {Matrix3} matrix
|
|
1818
|
+
* @ignore
|
|
1820
1819
|
*/
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1820
|
+
function offDiagonalFrobeniusNorm(matrix) {
|
|
1821
|
+
// Computes the "off-diagonal" Frobenius norm.
|
|
1822
|
+
// Assumes matrix is symmetric.
|
|
1823
|
+
|
|
1824
|
+
let norm = 0.0;
|
|
1825
|
+
for (let i = 0; i < 3; ++i) {
|
|
1826
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1827
|
+
const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
|
|
1828
|
+
norm += 2.0 * temp * temp;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
return Math.sqrt(norm);
|
|
1832
|
+
}
|
|
1824
1833
|
|
|
1825
1834
|
/**
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1835
|
+
* This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
|
|
1836
|
+
* section 8.4.2 The 2by2 Symmetric Schur Decomposition.
|
|
1837
|
+
*
|
|
1838
|
+
* The routine takes a matrix, which is assumed to be symmetric, and
|
|
1839
|
+
* finds the largest off-diagonal term, and then creates
|
|
1840
|
+
* a matrix (result) which can be used to help reduce it
|
|
1828
1841
|
*
|
|
1829
|
-
* @
|
|
1842
|
+
* @param {Matrix3} matrix
|
|
1843
|
+
* @param {Matrix3} result
|
|
1844
|
+
* @ignore
|
|
1830
1845
|
*/
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1846
|
+
function shurDecomposition(matrix, result) {
|
|
1847
|
+
const tolerance = CesiumMath.EPSILON15;
|
|
1848
|
+
|
|
1849
|
+
let maxDiagonal = 0.0;
|
|
1850
|
+
let rotAxis = 1;
|
|
1851
|
+
|
|
1852
|
+
// find pivot (rotAxis) based on max diagonal of matrix
|
|
1853
|
+
for (let i = 0; i < 3; ++i) {
|
|
1854
|
+
const temp = Math.abs(
|
|
1855
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1856
|
+
matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])],
|
|
1857
|
+
);
|
|
1858
|
+
if (temp > maxDiagonal) {
|
|
1859
|
+
rotAxis = i;
|
|
1860
|
+
maxDiagonal = temp;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
let c = 1.0;
|
|
1865
|
+
let s = 0.0;
|
|
1866
|
+
|
|
1867
|
+
const p = rowVal[rotAxis];
|
|
1868
|
+
const q = colVal[rotAxis];
|
|
1869
|
+
|
|
1870
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1871
|
+
if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
|
|
1872
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1873
|
+
const qq = matrix[Matrix3.getElementIndex(q, q)];
|
|
1874
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1875
|
+
const pp = matrix[Matrix3.getElementIndex(p, p)];
|
|
1876
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1877
|
+
const qp = matrix[Matrix3.getElementIndex(q, p)];
|
|
1878
|
+
|
|
1879
|
+
const tau = (qq - pp) / 2.0 / qp;
|
|
1880
|
+
let t;
|
|
1881
|
+
|
|
1882
|
+
if (tau < 0.0) {
|
|
1883
|
+
t = -1.0 / (-tau + Math.sqrt(1.0 + tau * tau));
|
|
1884
|
+
} else {
|
|
1885
|
+
t = 1.0 / (tau + Math.sqrt(1.0 + tau * tau));
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
c = 1.0 / Math.sqrt(1.0 + t * t);
|
|
1889
|
+
s = t * c;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
result = Matrix3.clone(Matrix3.IDENTITY, result);
|
|
1893
|
+
|
|
1894
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1895
|
+
result[Matrix3.getElementIndex(p, p)] = result[
|
|
1896
|
+
Matrix3.getElementIndex(q, q)
|
|
1897
|
+
] = c;
|
|
1898
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1899
|
+
result[Matrix3.getElementIndex(q, p)] = s;
|
|
1900
|
+
// @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
|
|
1901
|
+
result[Matrix3.getElementIndex(p, q)] = -s;
|
|
1902
|
+
|
|
1903
|
+
return result;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1838
1906
|
export default Matrix3;
|