Cesium JS API
AppearanceArcGisMapServerImageryProviderArcGISTiledElevationTerrainProviderArcTypeAssociativeArrayAxisAxisAlignedBoundingBoxbarycentricCoordinatesBillboardBillboardCollectionBillboardGraphicsBillboardVisualizerbinarySearchbinarySearchComparatorBingMapsGeocoderServiceBingMapsImageryProviderBingMapsStyleBlendEquationBlendFunctionBlendingStateBlendOptionBoundingRectangleBoundingSphereBoxEmitterBoxGeometryBoxGeometryUpdaterBoxGraphicsBoxOutlineGeometrybuildModuleUrlCallbackPropertyCameraCameraEventAggregatorCameraEventTypeCartesian2Cartesian3Cartesian4CartographicCartographicGeocoderServiceCatmullRomSplineCesium3DTileCesium3DTileColorBlendModeCesium3DTileContentCesium3DTileFeatureCesium3DTilePointFeatureCesium3DTilesetCesium3DTilesetGraphicsCesium3DTilesetVisualizerCesium3DTileStyleCesium3DTilesVoxelProviderCesiumTerrainProviderCesiumWidgetCheckerboardMaterialPropertyCircleEmitterCircleGeometryCircleOutlineGeometryClassificationPrimitiveClassificationTypeClippingPlaneClippingPlaneCollectionClockClockRangeClockStepcloneCloudCollectionCloudTypeColorColorBlendModeColorGeometryInstanceAttributeColorMaterialPropertycombineComponentDatatypeCompositeEntityCollectionCompositeMaterialPropertyCompositePositionPropertyCompositePropertyCompressedTextureBufferConditionsExpressionConeEmitterConstantPositionPropertyConstantPropertyConstantSplineContextOptionsCoplanarPolygonGeometryCoplanarPolygonOutlineGeometryCornerTypeCorridorGeometryCorridorGeometryUpdaterCorridorGraphicsCorridorOutlineGeometrycreateElevationBandMaterialcreateElevationBandMaterialBandcreateElevationBandMaterialEntrycreateGuidcreateOsmBuildingscreateTangentSpaceDebugPrimitivecreateWorldImagerycreateWorldTerrainCreditCreditDisplayCubicRealPolynomialCullFaceCullingVolumeCumulusCloudCustomDataSourceCustomHeightmapTerrainProviderCustomShaderCustomShaderModeCustomShaderTranslucencyModeCylinderGeometryCylinderGeometryUpdaterCylinderGraphicsCylinderOutlineGeometryCzmlDataSourceDataSourceDataSourceClockDataSourceCollectionDataSourceDisplayDebugAppearanceDebugCameraPrimitiveDebugModelMatrixPrimitiveDefaultProxydefaultValuedefinedDepthFunctiondestroyObjectDeveloperErrorDirectionalLightDirectionUpDiscardEmptyTileImagePolicyDiscardMissingTileImagePolicyDistanceDisplayConditionDistanceDisplayConditionGeometryInstanceAttributeEasingFunctionEllipseGeometryEllipseGeometryUpdaterEllipseGraphicsEllipseOutlineGeometryEllipsoidEllipsoidGeodesicEllipsoidGeometryEllipsoidGeometryUpdaterEllipsoidGraphicsEllipsoidOutlineGeometryEllipsoidRhumbLineEllipsoidSurfaceAppearanceEllipsoidTangentPlaneEllipsoidTerrainProviderEntityEntityClusterEntityCollectionEntityViewEventEventHelperexcludesReverseAxisexportKmlexportKmlModelCallbackexportKmlResultKmlexportKmlResultKmzExpressionExtrapolationTypeFeatureDetectionFogformatErrorFrameRateMonitorFrustumGeometryFrustumOutlineGeometryFullscreenGeocoderServiceGeocodeTypeGeographicProjectionGeographicTilingSchemeGeoJsonDataSourceGeometryGeometryAttributeGeometryAttributesGeometryFactoryGeometryInstanceGeometryInstanceAttributeGeometryPipelineGeometryUpdaterGeometryVisualizergetAbsoluteUrigetBaseUrigetExtensionFromUriGetFeatureInfoFormatgetFilenameFromUrigetImagePixelsgetTimestampGlobeGlobeTranslucencyGoogleEarthEnterpriseImageryProviderGoogleEarthEnterpriseMapsProviderGoogleEarthEnterpriseMetadataGoogleEarthEnterpriseTerrainDataGoogleEarthEnterpriseTerrainProviderGpxDataSourceGregorianDateGridImageryProviderGridMaterialPropertyGroundGeometryUpdaterGroundPolylineGeometryGroundPolylinePrimitiveGroundPrimitiveHeadingPitchRangeHeadingPitchRollHeadingPitchRollValuesHeightmapEncodingHeightmapTerrainDataHeightReferenceHermitePolynomialApproximationHermiteSplineHilbertOrderHorizontalOriginI3SDataProviderI3SFeatureI3SFieldI3SGeometryI3SLayerI3SNodeImageBasedLightingImageMaterialPropertyImageryLayerImageryLayerCollectionImageryLayerFeatureInfoImageryProviderImageryTypesincludesReverseAxisIndexDatatypeIntersectIntersections2DIntersectionTestsIntervalIonIonGeocoderServiceIonImageryProviderIonResourceIonWorldImageryStyleisLeapYearIso8601JulianDateKeyboardEventModifierKmlCameraKmlDataSourceKmlFeatureDataKmlLookAtKmlTourKmlTourFlyToKmlTourWaitLabelLabelCollectionLabelGraphicsLabelStyleLabelVisualizerLagrangePolynomialApproximationLeapSecondLightLightingModelLinearApproximationLinearSplineMapboxImageryProviderMapboxStyleImageryProviderMapMode2DMapProjectionMaterialMaterialAppearanceMaterialSupportMaterialPropertyMathMatrix2Matrix3Matrix4mergeSortmergeSortComparatorMetadataClassMetadataClassPropertyMetadataComponentTypeMetadataEnumMetadataEnumValueMetadataSchemaMetadataTypeModelModelAnimationModelAnimationCollectionModelAnimationLoopModelFeatureModelGraphicsModelNodeModelVisualizerMoonMorphWeightSplineNearFarScalarNeverTileDiscardPolicyNodeTransformationPropertyobjectToQueryOccluderOpenCageGeocoderServiceOpenStreetMapImageryProviderOrientedBoundingBoxOrthographicFrustumOrthographicOffCenterFrustumPackableForInterpolationParticleParticleBurstParticleEmitterParticleSystemPathGraphicsPathVisualizerPeliasGeocoderServicePerInstanceColorAppearancePerspectiveFrustumPerspectiveOffCenterFrustumPinBuilderPixelDatatypePixelFormatPlanePlaneGeometryPlaneGeometryUpdaterPlaneGraphicsPlaneOutlineGeometryPointCloudShadingPointGraphicspointInsideTrianglePointPrimitivePointPrimitiveCollectionPointVisualizerPolygonGeometryPolygonGeometryUpdaterPolygonGraphicsPolygonHierarchyPolygonOutlineGeometryPolylinePolylineArrowMaterialPropertyPolylineCollectionPolylineColorAppearancePolylineDashMaterialPropertyPolylineGeometryPolylineGeometryUpdaterPolylineGlowMaterialPropertyPolylineGraphicsPolylineMaterialAppearancePolylineOutlineMaterialPropertyPolylineVisualizerPolylineVolumeGeometryPolylineVolumeGeometryUpdaterPolylineVolumeGraphicsPolylineVolumeOutlineGeometryPositionPropertyPositionPropertyArrayPostProcessStagePostProcessStageCollectionPostProcessStageCompositePostProcessStageLibraryPostProcessStageSampleModePrimitivePrimitiveCollectionPrimitiveTypePropertyPropertyArrayPropertyBagProxyQuadraticRealPolynomialQuantizedMeshTerrainDataQuarticRealPolynomialQuaternionQuaternionSplinequeryToObjectQueueRayreadyPromiseRectangleRectangleGeometryRectangleGeometryUpdaterRectangleGraphicsRectangleOutlineGeometryReferenceFrameReferencePropertyremoveExtensionRequestRequestErrorEventRequestSchedulerRequestStateRequestTypeResourceRuntimeErrorSampledPositionPropertySampledPropertysampleTerrainsampleTerrainMostDetailedSceneSceneModeSceneTransformsScreenSpaceCameraControllerScreenSpaceEventHandlerScreenSpaceEventTypeshaderDefinesshaderMaximumIntersectionsLengthshaderUniformsShadowMapShadowModeShowGeometryInstanceAttributeSimon1994PlanetaryPositionsSimplePolylineGeometrySingleTileImageryProviderSkyAtmosphereSkyBoxSphereEmitterSphereGeometrySphereOutlineGeometrySphericalSplineSplitDirectionStencilFunctionStencilOperationSteppedSplineStripeMaterialPropertyStripeOrientationStyleExpressionsubdivideArraySunSunLightTaskProcessorTerrainDataTerrainProviderTextureMagnificationFilterTextureMinificationFilterTextureUniformTileAvailabilityTileCoordinatesImageryProviderTileDiscardPolicyTileMapServiceImageryProviderTileProviderErrorTilingSchemeTimeDynamicImageryTimeDynamicPointCloudTimeIntervalTimeIntervalCollectionTimeIntervalCollectionPositionPropertyTimeIntervalCollectionPropertyTimeStandardTransformsTranslationRotationScaleTridiagonalSystemSolverTrustedServersUniformSpecifierUniformTypeUrlTemplateImageryProviderVaryingTypeVelocityOrientationPropertyVelocityVectorPropertyVertexFormatVerticalOriginVideoSynchronizerViewportQuadVisibilityVisualizerVoxelPrimitiveVoxelProviderVoxelShapeTypeVRTheWorldTerrainProviderWallGeometryWallGeometryUpdaterWallGraphicsWallOutlineGeometryWebGLConstantsWebGLOptionsWebMapServiceImageryProviderWebMapTileServiceImageryProviderWebMercatorProjectionWebMercatorTilingSchemeWindingOrderwriteTextToCanvasAnimationAnimationViewModelBaseLayerPickerBaseLayerPickerViewModelCesium3DTilesInspectorCesium3DTilesInspectorViewModelCesiumInspectorCesiumInspectorViewModelClockViewModelCommandcreateCommandFullscreenButtonFullscreenButtonViewModelGeocoderGeocoderViewModelHomeButtonHomeButtonViewModelInfoBoxInfoBoxViewModelNavigationHelpButtonNavigationHelpButtonViewModelPerformanceWatchdogPerformanceWatchdogViewModelProjectionPickerProjectionPickerViewModelProviderViewModelSceneModePickerSceneModePickerViewModelSelectionIndicatorSelectionIndicatorViewModelSvgPathBindingHandlerTimelineToggleButtonViewModelViewerviewerCesium3DTilesInspectorMixinviewerCesiumInspectorMixinviewerDragDropMixinviewerPerformanceWatchdogMixinviewerVoxelInspectorMixinVoxelInspectorVoxelInspectorViewModelVRButtonVRButtonViewModel

Matrix2

概述

Matrix2 对象是表示二维矩阵的类。它提供了一些常见的矩阵操作方法,并可与 CesiumJS 中的其他对象一起使用。

构造函数

Matrix2()

创建 Matrix2 对象。

var myMatrix = new Cesium.Matrix2();

属性

Matrix2.ROW0、Matrix2.ROW1

这些属性是二维数组,表示 Matrix2 的两行元素。例如,ROW0 表示矩阵的第一行:

var myMatrix = new Cesium.Matrix2();
var firstRow = myMatrix[0];

Matrix2.COLUMN0、Matrix2.COLUMN1

这些属性是二维数组,表示 Matrix2 的两列元素。例如,COLUMN0 表示矩阵的第一列:

var myMatrix = new Cesium.Matrix2();
var firstColumn = myMatrix.COLUMN0;

方法

Matrix2.clone(matrix)

创建给定 matrix 的副本。

var myMatrix = new Cesium.Matrix2();
var myMatrixClone = Cesium.Matrix2.clone(myMatrix);

Matrix2.equals(left, right, relativeEpsilon)

比较两个 Matrix2 对象是否相等。

var matrix1 = new Cesium.Matrix2();
var matrix2 = new Cesium.Matrix2();
var equal = Cesium.Matrix2.equals(matrix1, matrix2);

Matrix2.multiply(left, right, result)

将左矩阵乘以右矩阵,并将结果写入 result,返回新的矩阵对象。

var matrix1 = new Cesium.Matrix2();
var matrix2 = new Cesium.Matrix2();
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.multiply(matrix1, matrix2, result);

Matrix2.multiplyByVector(matrix, cartesian2D, result)

matrix 矩阵与二维向量 cartesian2D 相乘,并将结果写入 result,返回新的矢量对象。

var myMatrix = new Cesium.Matrix2();
var myVector = new Cesium.Cartesian2(1, 2);
var result = new Cesium.Cartesian2();
var newVector = Cesium.Matrix2.multiplyByVector(myMatrix, myVector, result);

Matrix2.multiplyByScalar(matrix, scalar, result)

将矩阵 matrix 的每个元素乘以标量 scalar,并将结果写入 result,返回新的矩阵对象。

var myMatrix = new Cesium.Matrix2();
var scalar = 2.0;
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.multiplyByScalar(myMatrix, scalar, result);

Matrix2.toArray(matrix, result)

Matrix2 对象转换为一维数组,并将结果写入 result,返回新的一维数组。

var myMatrix = new Cesium.Matrix2();
var result = [];
var newArray = Cesium.Matrix2.toArray(myMatrix, result);

Matrix2.fromArray(array, startingIndex, result)

从一维数组 array 中的 startingIndex 索引开始构造一个新的 Matrix2 对象,并将结果写入 result。返回新的矩阵对象。

var myArray = [1, 0, 0, 1];
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.fromArray(myArray, 0, result);

Matrix2.fromColumnMajorArray(values, result)

从以列主序排列的数组 values 中创建新的 Matrix2 对象,并将结果写入 result。返回新的矩阵对象。

var myArray = [1, 0, 0, 1];
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.fromColumnMajorArray(myArray, result);

Matrix2.fromRowMajorArray(values, result)

从以行主序排列的数组 values 中创建新的 Matrix2 对象,并将结果写入 result。返回新的矩阵对象。

var myArray = [1, 0, 0, 1];
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.fromRowMajorArray(myArray, result);

Matrix2.IDENTITY

一个矩阵对象,表示二维单位矩阵。

var myIdentity = Cesium.Matrix2.IDENTITY;

Matrix2.ZERO

一个矩阵对象,表示所有元素都为零的二维矩阵。

var myZeroMatrix = Cesium.Matrix2.ZERO;

Matrix2.pack(value, array, startingIndex)

value 对象打包到数组 array 中的指定位置 startingIndex。返回处理后的数组。

var myMatrix = new Cesium.Matrix2();
var myArray = new Array(4);
Cesium.Matrix2.pack(myMatrix, myArray, 0);

Matrix2.unpack(array, startingIndex, result)

从数组 array 的指定位置 startingIndex 开始解包一个 Matrix2 对象。返回新的矩阵对象。

var myArray = [1, 0, 0, 1];
var result = new Cesium.Matrix2();
var newMatrix = Cesium.Matrix2.unpack(myArray, 0, result);

示例

以下示例代码展示了 Matrix2 类的基本用法。

使用 Matrix2.multiply 计算两个矩阵的乘积

var matrix1 = new Cesium.Matrix2(1, 2, 3, 4);
var matrix2 = new Cesium.Matrix2(5, 6, 7, 8);
var result = new Cesium.Matrix2();
var multiplicationResult = Cesium.Matrix2.multiply(matrix1, matrix2, result);

使用 Matrix2.multiplyByVector 将矩阵乘以向量

var matrix = new Cesium.Matrix2(1, 2, 3, 4);
var vector = new Cesium.Cartesian2(5, 6);
var result = new Cesium.Cartesian2();
var multipliedVector = Cesium.Matrix2.multiplyByVector(matrix, vector, result);

创建一个 Matrix2 对象数组

var array = [];
for (var i = 0; i < 10; i++) {
    var matrix = new Cesium.Matrix2(i, i * 2, i * 3, i * 4);
    array.push(matrix);
}