Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Matrix4
    • Matrix4

Index

Constructors

constructor

  • new Matrix4(column0Row0?: number, column1Row0?: number, column2Row0?: number, column3Row0?: number, column0Row1?: number, column1Row1?: number, column2Row1?: number, column3Row1?: number, column0Row2?: number, column1Row2?: number, column2Row2?: number, column3Row2?: number, column0Row3?: number, column1Row3?: number, column2Row3?: number, column3Row3?: number): Matrix4
  • Parameters

    • Optional column0Row0: number
    • Optional column1Row0: number
    • Optional column2Row0: number
    • Optional column3Row0: number
    • Optional column0Row1: number
    • Optional column1Row1: number
    • Optional column2Row1: number
    • Optional column3Row1: number
    • Optional column0Row2: number
    • Optional column1Row2: number
    • Optional column2Row2: number
    • Optional column3Row2: number
    • Optional column0Row3: number
    • Optional column1Row3: number
    • Optional column2Row3: number
    • Optional column3Row3: number

    Returns Matrix4

Properties

length

length: number

Gets the number of items in the collection.

Static Readonly COLUMN0ROW0

COLUMN0ROW0: number

The index into Matrix4 for column 0, row 0.

Static Readonly COLUMN0ROW1

COLUMN0ROW1: number

The index into Matrix4 for column 0, row 1.

Static Readonly COLUMN0ROW2

COLUMN0ROW2: number

The index into Matrix4 for column 0, row 2.

Static Readonly COLUMN0ROW3

COLUMN0ROW3: number

The index into Matrix4 for column 0, row 3.

Static Readonly COLUMN1ROW0

COLUMN1ROW0: number

The index into Matrix4 for column 1, row 0.

Static Readonly COLUMN1ROW1

COLUMN1ROW1: number

The index into Matrix4 for column 1, row 1.

Static Readonly COLUMN1ROW2

COLUMN1ROW2: number

The index into Matrix4 for column 1, row 2.

Static Readonly COLUMN1ROW3

COLUMN1ROW3: number

The index into Matrix4 for column 1, row 3.

Static Readonly COLUMN2ROW0

COLUMN2ROW0: number

The index into Matrix4 for column 2, row 0.

Static Readonly COLUMN2ROW1

COLUMN2ROW1: number

The index into Matrix4 for column 2, row 1.

Static Readonly COLUMN2ROW2

COLUMN2ROW2: number

The index into Matrix4 for column 2, row 2.

Static Readonly COLUMN2ROW3

COLUMN2ROW3: number

The index into Matrix4 for column 2, row 3.

Static Readonly COLUMN3ROW0

COLUMN3ROW0: number

The index into Matrix4 for column 3, row 0.

Static Readonly COLUMN3ROW1

COLUMN3ROW1: number

The index into Matrix4 for column 3, row 1.

Static Readonly COLUMN3ROW2

COLUMN3ROW2: number

The index into Matrix4 for column 3, row 2.

Static Readonly COLUMN3ROW3

COLUMN3ROW3: number

The index into Matrix4 for column 3, row 3.

Static Readonly IDENTITY

IDENTITY: Matrix4

An immutable Matrix4 instance initialized to the identity matrix.

Static Readonly ZERO

ZERO: Matrix4

An immutable Matrix4 instance initialized to the zero matrix.

Static packedLength

packedLength: number

The number of elements used to pack the object into an array.

Methods

clone

  • clone(result?: Matrix4): Matrix4
  • Duplicates the provided Matrix4 instance.

    Parameters

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter or a new Matrix4 instance if one was not provided.

createInverse

  • createInverse(): Matrix4
  • createInverse

    Returns Matrix4

    new inverse matrix

equals

  • equals(right?: Matrix4): boolean
  • Compares this matrix to the provided matrix componentwise and returns true if they are equal, false otherwise.

    Parameters

    • Optional right: Matrix4

    Returns boolean

    true if they are equal, false otherwise.

equalsEpsilon

  • equalsEpsilon(right?: Matrix4, epsilon?: number): boolean
  • Compares this matrix to the provided matrix componentwise and returns true if they are within the provided epsilon, false otherwise.

    Parameters

    • Optional right: Matrix4
    • Optional epsilon: number

    Returns boolean

    true if they are within the provided epsilon, false otherwise.

leftTransformBy

  • leftTransformBy(matrix: Matrix4): Matrix4
  • leftTransformBy

    Parameters

    • matrix: Matrix4

      input.

    Returns Matrix4

    self

rightTransformBy

  • rightTransformBy(matrix: Matrix4): Matrix4
  • rightTransformBy

    Parameters

    • matrix: Matrix4

      input.

    Returns Matrix4

    self

toString

  • toString(): string
  • Computes a string representing this Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.

    Returns string

    A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.

Static abs

  • abs(matrix: Matrix4, result: Matrix4): Matrix4
  • Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.

    Parameters

    • matrix: Matrix4

      The matrix with signed elements.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static add

  • add(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4
  • Computes the sum of two matrices.

    Parameters

    • left: Matrix4

      The first matrix.

    • right: Matrix4

      The second matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static addTransform

  • addTransform(matrix: Matrix4, transform: Cartesian3, result: Matrix4): Matrix4
  • Parameters

    • matrix: Matrix4

      The matrix to use.

    • transform: Cartesian3

      The transform by matrix's position

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static clone

  • clone(matrix: Matrix4, result?: Matrix4): Matrix4
  • Duplicates a Matrix4 instance.

    Parameters

    • matrix: Matrix4

      The matrix to duplicate.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter or a new Matrix4 instance if one was not provided. (Returns undefined if matrix is undefined)

Static computeInfinitePerspectiveOffCenter

  • computeInfinitePerspectiveOffCenter(left: number, right: number, bottom: number, top: number, near: number, result: Matrix4): Matrix4
  • Computes a Matrix4 instance representing an infinite off center perspective transformation.

    Parameters

    • left: number

      The number of meters to the left of the camera that will be in view.

    • right: number

      The number of meters to the right of the camera that will be in view.

    • bottom: number

      The number of meters below of the camera that will be in view.

    • top: number

      The number of meters above of the camera that will be in view.

    • near: number

      The distance to the near plane in meters.

    • result: Matrix4

      The object in which the result will be stored.

    Returns Matrix4

    The modified result parameter.

Static computeOrthographicOffCenter

  • computeOrthographicOffCenter(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4): Matrix4
  • Computes a Matrix4 instance representing an orthographic transformation matrix.

    Parameters

    • left: number

      The number of meters to the left of the camera that will be in view.

    • right: number

      The number of meters to the right of the camera that will be in view.

    • bottom: number

      The number of meters below of the camera that will be in view.

    • top: number

      The number of meters above of the camera that will be in view.

    • near: number

      The distance to the near plane in meters.

    • far: number

      The distance to the far plane in meters.

    • result: Matrix4

      The object in which the result will be stored.

    Returns Matrix4

    The modified result parameter.

Static computePerspectiveFieldOfView

  • computePerspectiveFieldOfView(fovY: number, aspectRatio: number, near: number, far: number, result: Matrix4): Matrix4
  • Computes a Matrix4 instance representing a perspective transformation matrix.

    Parameters

    • fovY: number

      The field of view along the Y axis in radians.

    • aspectRatio: number

      The aspect ratio.

    • near: number

      The distance to the near plane in meters.

    • far: number

      The distance to the far plane in meters.

    • result: Matrix4

      The object in which the result will be stored.

    Returns Matrix4

    The modified result parameter.

Static computePerspectiveOffCenter

  • computePerspectiveOffCenter(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4): Matrix4
  • Computes a Matrix4 instance representing an off center perspective transformation.

    Parameters

    • left: number

      The number of meters to the left of the camera that will be in view.

    • right: number

      The number of meters to the right of the camera that will be in view.

    • bottom: number

      The number of meters below of the camera that will be in view.

    • top: number

      The number of meters above of the camera that will be in view.

    • near: number

      The distance to the near plane in meters.

    • far: number

      The distance to the far plane in meters.

    • result: Matrix4

      The object in which the result will be stored.

    Returns Matrix4

    The modified result parameter.

Static computeView

  • computeView(position: Cartesian3, direction: Cartesian3, up: Cartesian3, right: Cartesian3, result: Matrix4): Matrix4
  • Computes a Matrix4 instance that transforms from world space to view space.

    Parameters

    • position: Cartesian3

      The position of the camera.

    • direction: Cartesian3

      The forward direction.

    • up: Cartesian3

      The up direction.

    • right: Cartesian3

      The right direction.

    • result: Matrix4

      The object in which the result will be stored.

    Returns Matrix4

    The modified result parameter.

Static computeViewportTransformation

  • computeViewportTransformation(viewport?: any, nearDepthRange?: number, farDepthRange?: number, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance that transforms from normalized device coordinates to window coordinates.

    example

    // Create viewport transformation using an explicit viewport and depth range. var m = Cesium.Matrix4.computeViewportTransformation({ x : 0.0, y : 0.0, width : 1024.0, height : 768.0 }, 0.0, 1.0, new Cesium.Matrix4());

    Parameters

    • Optional viewport: any
    • Optional nearDepthRange: number
    • Optional farDepthRange: number
    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter.

Static equals

  • equals(left?: Matrix4, right?: Matrix4): boolean
  • Compares the provided matrices componentwise and returns true if they are equal, false otherwise.

    example

    //compares two Matrix4 instances

    // a = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]

    // b = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]

    if(Cesium.Matrix4.equals(a,b)) { console.log("Both matrices are equal"); } else { console.log("They are not equal"); }

    //Prints "Both matrices are equal" on the console

    Parameters

    • Optional left: Matrix4
    • Optional right: Matrix4

    Returns boolean

    true if left and right are equal, false otherwise.

Static equalsEpsilon

  • equalsEpsilon(left?: Matrix4, right?: Matrix4, epsilon?: number): boolean
  • Compares the provided matrices componentwise and returns true if they are within the provided epsilon, false otherwise.

    example

    //compares two Matrix4 instances

    // a = [10.5, 14.5, 18.5, 22.5] // [11.5, 15.5, 19.5, 23.5] // [12.5, 16.5, 20.5, 24.5] // [13.5, 17.5, 21.5, 25.5]

    // b = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]

    if(Cesium.Matrix4.equalsEpsilon(a,b,0.1)){ console.log("Difference between both the matrices is less than 0.1"); } else { console.log("Difference between both the matrices is not less than 0.1"); }

    //Prints "Difference between both the matrices is not less than 0.1" on the console

    Parameters

    • Optional left: Matrix4
    • Optional right: Matrix4
    • Optional epsilon: number

    Returns boolean

    true if left and right are within the provided epsilon, false otherwise.

Static fromArray

Static fromCamera

  • fromCamera(camera: Camera, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a Camera.

    Parameters

    • camera: Camera

      The camera to use.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromCameraDetail

  • fromCameraDetail(position: Cartesian3, direction: Cartesian3, up: Cartesian3, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a Camera Detail.

    Parameters

    • position: Cartesian3

      The camera position.

    • direction: Cartesian3

      The camera direction.

    • up: Cartesian3

      The camera up.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromColumnMajorArray

  • fromColumnMajorArray(values: number[], result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a column-major order array.

    Parameters

    • values: number[]

      The column-major order array.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromCoordSysTransform

  • fromCoordSysTransform(position: Cartesian3, x: Cartesian3, y: Cartesian3, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a Camera Detail.

    Parameters

    • position: Cartesian3

      origin.

    • x: Cartesian3

      direction.

    • y: Cartesian3

      direction.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromRotation

  • fromRotation(rotation: Matrix3, result?: Matrix4): Matrix4
  • Creates a rotation matrix.

    Parameters

    • rotation: Matrix3

      The rotation matrix.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromRotationTranslation

  • fromRotationTranslation(rotation: Matrix3, translation?: Cartesian3, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a Matrix3 representing the rotation and a Cartesian3 representing the translation.

    Parameters

    • rotation: Matrix3

      The upper left portion of the matrix representing the rotation.

    • Optional translation: Cartesian3
    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromRowMajorArray

  • fromRowMajorArray(values: number[], result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a row-major order array. The resulting matrix will be in column-major order.

    Parameters

    • values: number[]

      The row-major order array.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromScale

  • fromScale(scale: Cartesian3, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance representing a non-uniform scale.

    example

    // Creates // [7.0, 0.0, 0.0, 0.0] // [0.0, 8.0, 0.0, 0.0] // [0.0, 0.0, 9.0, 0.0] // [0.0, 0.0, 0.0, 1.0] var m = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));

    Parameters

    • scale: Cartesian3

      The x, y, and z scale factors.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromTranslation

  • fromTranslation(translation: Cartesian3, result?: Matrix4): Matrix4
  • Creates a Matrix4 instance from a Cartesian3 representing the translation.

    Parameters

    • translation: Cartesian3

      The upper right portion of the matrix representing the translation.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromTranslationQuaternionRotationScale

  • fromTranslationQuaternionRotationScale(translation: Cartesian3, rotation: Quaternion, scale: Cartesian3, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance from a translation, rotation, and scale (TRS) representation with the rotation represented as a quaternion.

    example

    var result = Cesium.Matrix4.fromTranslationQuaternionRotationScale( new Cesium.Cartesian3(1.0, 2.0, 3.0), // translation Cesium.Quaternion.IDENTITY, // rotation new Cesium.Cartesian3(7.0, 8.0, 9.0), // scale result);

    Parameters

    • translation: Cartesian3

      The translation transformation.

    • rotation: Quaternion

      The rotation transformation.

    • scale: Cartesian3

      The non-uniform scale transformation.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromTranslationRotationScale

  • fromTranslationRotationScale(translationRotationScale: TranslationRotationScale, result?: Matrix4): Matrix4
  • Creates a Matrix4 instance from a TranslationRotationScale instance.

    Parameters

    • translationRotationScale: TranslationRotationScale

      The instance.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static fromUniformScale

  • fromUniformScale(scale: number, result?: Matrix4): Matrix4
  • Computes a Matrix4 instance representing a uniform scale.

    example

    // Creates // [2.0, 0.0, 0.0, 0.0] // [0.0, 2.0, 0.0, 0.0] // [0.0, 0.0, 2.0, 0.0] // [0.0, 0.0, 0.0, 1.0] var m = Cesium.Matrix4.fromUniformScale(2.0);

    Parameters

    • scale: number

      The uniform scale factor.

    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter, or a new Matrix4 instance if one was not provided.

Static getColumn

  • getColumn(matrix: Matrix4, index: number, result: Cartesian4): Cartesian4
  • Retrieves a copy of the matrix column at the provided index as a Cartesian4 instance.

    example

    //returns a Cartesian4 instance with values from the specified column // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    //Example 1: Creates an instance of Cartesian var a = Cesium.Matrix4.getColumn(m, 2, new Cesium.Cartesian4());

    example

    //Example 2: Sets values for Cartesian instance var a = new Cesium.Cartesian4(); Cesium.Matrix4.getColumn(m, 2, a);

    // a.x = 12.0; a.y = 16.0; a.z = 20.0; a.w = 24.0;

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • index: number

      The zero-based index of the column to retrieve.

    • result: Cartesian4

      The object onto which to store the result.

    Returns Cartesian4

    The modified result parameter.

Static getElementIndex

  • getElementIndex(row: number, column: number): number
  • Computes the array index of the element at the provided row and column.

    example

    var myMatrix = new Cesium.Matrix4(); var column1Row0Index = Cesium.Matrix4.getElementIndex(1, 0); var column1Row0 = myMatrix[column1Row0Index]; myMatrix[column1Row0Index] = 10.0;

    Parameters

    • row: number

      The zero-based index of the row.

    • column: number

      The zero-based index of the column.

    Returns number

    The index of the element at the provided row and column.

Static getMatrix3

  • getMatrix3(matrix: Matrix4, result: Matrix3): Matrix3
  • Gets the upper left 3x3 rotation matrix of the provided matrix, assuming the matrix is an affine transformation matrix.

    example

    // returns a Matrix3 instance from a Matrix4 instance

    // m = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]

    var b = new Cesium.Matrix3(); Cesium.Matrix4.getMatrix3(m,b);

    // b = [10.0, 14.0, 18.0] // [11.0, 15.0, 19.0] // [12.0, 16.0, 20.0]

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • result: Matrix3

      The object onto which to store the result.

    Returns Matrix3

    The modified result parameter.

Static getMaximumScale

  • getMaximumScale(matrix: Matrix4): number
  • Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors in the upper-left 3x3 matrix.

    Parameters

    • matrix: Matrix4

      The matrix.

    Returns number

    The maximum scale.

Static getProjectionMatrixByPictureNormalRightAndPosition

  • getProjectionMatrixByPictureNormalRightAndPosition(normal: Cartesian3, right: Cartesian3, widthHeight: Cartesian2, worldPosition: Cartesian3, cullingPosition: Cartesian2, backwardDepth: number): Matrix4
  • Parameters

    • normal: Cartesian3
    • right: Cartesian3

      图片的右方向(y坐标值)

    • widthHeight: Cartesian2

      视锥体的宽高

    • worldPosition: Cartesian3

      世界坐标系下的点位

    • cullingPosition: Cartesian2

      裁剪坐标系下的点位

    • backwardDepth: number

    Returns Matrix4

Static getProjectionMatrixByPositions

  • getProjectionMatrixByPositions(worldPositions: Cartesian3[], cullingPositions: Cartesian2[], backwardDepth: number): Matrix4
  • 通过投影前后的点集合获取投影矩阵和视角矩阵

    Parameters

    • worldPositions: Cartesian3[]
    • cullingPositions: Cartesian2[]
    • backwardDepth: number

    Returns Matrix4

Static getRotation

  • getRotation(matrix: Matrix4, result: Matrix3): Matrix3
  • Extracts the rotation matrix assuming the matrix is an affine transformation.

    Parameters

    • matrix: Matrix4

      The matrix.

    • result: Matrix3

      The object onto which to store the result.

    Returns Matrix3

    The modified result parameter.

Static getRow

  • getRow(matrix: Matrix4, index: number, result: Cartesian4): Cartesian4
  • Retrieves a copy of the matrix row at the provided index as a Cartesian4 instance.

    example

    //returns a Cartesian4 instance with values from the specified column // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    //Example 1: Returns an instance of Cartesian var a = Cesium.Matrix4.getRow(m, 2, new Cesium.Cartesian4());

    example

    //Example 2: Sets values for a Cartesian instance var a = new Cesium.Cartesian4(); Cesium.Matrix4.getRow(m, 2, a);

    // a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0;

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • index: number

      The zero-based index of the row to retrieve.

    • result: Cartesian4

      The object onto which to store the result.

    Returns Cartesian4

    The modified result parameter.

Static getScale

  • getScale(matrix: Matrix4, result: Cartesian3): Cartesian3
  • Extracts the non-uniform scale assuming the matrix is an affine transformation.

    Parameters

    • matrix: Matrix4

      The matrix.

    • result: Cartesian3

      The object onto which to store the result.

    Returns Cartesian3

    The modified result parameter

Static getTranslation

  • getTranslation(matrix: Matrix4, result: Cartesian3): Cartesian3
  • Gets the translation portion of the provided matrix, assuming the matrix is a affine transformation matrix.

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • result: Cartesian3

      The object onto which to store the result.

    Returns Cartesian3

    The modified result parameter.

Static inverse

  • inverse(matrix: Matrix4, result: Matrix4): Matrix4
  • Computes the inverse of the provided matrix using Cramers Rule. If the determinant is zero, the matrix can not be inverted, and an exception is thrown. If the matrix is an affine transformation matrix, it is more efficient to invert it with Matrix4.inverseTransformation.

    Parameters

    • matrix: Matrix4

      The matrix to invert.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static inverseTransformation

  • inverseTransformation(matrix: Matrix4, result: Matrix4): Matrix4
  • Computes the inverse of the provided matrix assuming it is an affine transformation matrix, where the upper left 3x3 elements are a rotation matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the inverse for a general 4x4 matrix using Matrix4.inverse.

    Parameters

    • matrix: Matrix4

      The matrix to invert.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiply

  • multiply(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4
  • Computes the product of two matrices.

    Parameters

    • left: Matrix4

      The first matrix.

    • right: Matrix4

      The second matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByMatrix3

  • multiplyByMatrix3(matrix: Matrix4, rotation: Matrix3, result: Matrix4): Matrix4
  • Multiplies a transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0]) by a 3x3 rotation matrix. This is an optimization for Matrix4.multiply(m, Matrix4.fromRotationTranslation(rotation), m); with less allocations and arithmetic operations.

    example

    // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromRotationTranslation(rotation), m); Cesium.Matrix4.multiplyByMatrix3(m, rotation, m);

    Parameters

    • matrix: Matrix4

      The matrix on the left-hand side.

    • rotation: Matrix3

      The 3x3 rotation matrix on the right-hand side.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByPoint

  • multiplyByPoint(matrix: Matrix4, cartesian: Cartesian3, result: Cartesian3): Cartesian3
  • Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling Matrix4.multiplyByVector with a {@link Cartesian4} with a w component of 1, but returns a {@link Cartesian3} instead of a {@link Cartesian4}.

    example

    var p = new Cesium.Cartesian3(1.0, 2.0, 3.0); var result = Cesium.Matrix4.multiplyByPoint(matrix, p, new Cesium.Cartesian3());

    Parameters

    • matrix: Matrix4

      The matrix.

    • cartesian: Cartesian3

      The point.

    • result: Cartesian3

      The object onto which to store the result.

    Returns Cartesian3

    The modified result parameter.

Static multiplyByPointAsVector

  • multiplyByPointAsVector(matrix: Matrix4, cartesian: Cartesian3, result: Cartesian3): Cartesian3
  • Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling Matrix4.multiplyByVector with a {@link Cartesian4} with a w component of zero.

    example

    var p = new Cesium.Cartesian3(1.0, 2.0, 3.0); var result = Cesium.Matrix4.multiplyByPointAsVector(matrix, p, new Cesium.Cartesian3()); // A shortcut for // Cartesian3 p = ... // Cesium.Matrix4.multiplyByVector(matrix, new Cesium.Cartesian4(p.x, p.y, p.z, 0.0), result);

    Parameters

    • matrix: Matrix4

      The matrix.

    • cartesian: Cartesian3

      The point.

    • result: Cartesian3

      The object onto which to store the result.

    Returns Cartesian3

    The modified result parameter.

Static multiplyByScalar

  • multiplyByScalar(matrix: Matrix4, scalar: number, result: Matrix4): Matrix4
  • Computes the product of a matrix and a scalar.

    example

    //create a Matrix4 instance which is a scaled version of the supplied Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    var a = Cesium.Matrix4.multiplyByScalar(m, -2, new Cesium.Matrix4());

    // m remains the same // a = [-20.0, -22.0, -24.0, -26.0] // [-28.0, -30.0, -32.0, -34.0] // [-36.0, -38.0, -40.0, -42.0] // [-44.0, -46.0, -48.0, -50.0]

    Parameters

    • matrix: Matrix4

      The matrix.

    • scalar: number

      The number to multiply by.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByScale

  • multiplyByScale(matrix: Matrix4, scale: Cartesian3, result: Matrix4): Matrix4
  • Multiplies an affine transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0]) by an implicit non-uniform scale matrix. This is an optimization for Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m);, where m must be an affine matrix. This function performs fewer allocations and arithmetic operations.

    example

    // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromScale(scale), m); Cesium.Matrix4.multiplyByScale(m, scale, m);

    Parameters

    • matrix: Matrix4

      The affine matrix on the left-hand side.

    • scale: Cartesian3

      The non-uniform scale on the right-hand side.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByTranslation

  • multiplyByTranslation(matrix: Matrix4, translation: Cartesian3, result: Matrix4): Matrix4
  • Multiplies a transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0]) by an implicit translation matrix defined by a {@link Cartesian3}. This is an optimization for Matrix4.multiply(m, Matrix4.fromTranslation(position), m); with less allocations and arithmetic operations.

    example

    // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromTranslation(position), m); Cesium.Matrix4.multiplyByTranslation(m, position, m);

    Parameters

    • matrix: Matrix4

      The matrix on the left-hand side.

    • translation: Cartesian3

      The translation on the right-hand side.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByUniformScale

  • multiplyByUniformScale(matrix: Matrix4, scale: number, result: Matrix4): Matrix4
  • Multiplies an affine transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0]) by an implicit uniform scale matrix. This is an optimization for Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m);, where m must be an affine matrix. This function performs fewer allocations and arithmetic operations.

    example

    // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromUniformScale(scale), m); Cesium.Matrix4.multiplyByUniformScale(m, scale, m);

    Parameters

    • matrix: Matrix4

      The affine matrix on the left-hand side.

    • scale: number

      The uniform scale on the right-hand side.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static multiplyByVector

  • multiplyByVector(matrix: Matrix4, cartesian: Cartesian4, result: Cartesian4): Cartesian4
  • Computes the product of a matrix and a column vector.

    Parameters

    • matrix: Matrix4

      The matrix.

    • cartesian: Cartesian4

      The vector.

    • result: Cartesian4

      The object onto which to store the result.

    Returns Cartesian4

    The modified result parameter.

Static multiplyTransformation

  • multiplyTransformation(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4
  • Computes the product of two matrices assuming the matrices are affine transformation matrices, where the upper left 3x3 elements are a rotation matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the product for general 4x4 matrices using Matrix4.multiply.

    example

    var m1 = new Cesium.Matrix4(1.0, 6.0, 7.0, 0.0, 2.0, 5.0, 8.0, 0.0, 3.0, 4.0, 9.0, 0.0, 0.0, 0.0, 0.0, 1.0); var m2 = Cesium.Transforms.eastNorthUpToFixedFrame(new Cesium.Cartesian3(1.0, 1.0, 1.0)); var m3 = Cesium.Matrix4.multiplyTransformation(m1, m2, new Cesium.Matrix4());

    Parameters

    • left: Matrix4

      The first matrix.

    • right: Matrix4

      The second matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static negate

  • negate(matrix: Matrix4, result: Matrix4): Matrix4
  • Computes a negated copy of the provided matrix.

    example

    //create a new Matrix4 instance which is a negation of a Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    var a = Cesium.Matrix4.negate(m, new Cesium.Matrix4());

    // m remains the same // a = [-10.0, -11.0, -12.0, -13.0] // [-14.0, -15.0, -16.0, -17.0] // [-18.0, -19.0, -20.0, -21.0] // [-22.0, -23.0, -24.0, -25.0]

    Parameters

    • matrix: Matrix4

      The matrix to negate.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static pack

  • pack(value: Matrix4, array: number[], startingIndex?: number): number[]
  • Stores the provided instance into the provided array.

    Parameters

    • value: Matrix4

      The value to pack.

    • array: number[]

      The array to pack into.

    • Optional startingIndex: number

    Returns number[]

    The array that was packed into

Static setColumn

  • setColumn(matrix: Matrix4, index: number, cartesian: Cartesian4, result: Matrix4): Matrix4
  • Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian4 instance.

    example

    //creates a new Matrix4 instance with new column values from the Cartesian4 instance // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    var a = Cesium.Matrix4.setColumn(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());

    // m remains the same // a = [10.0, 11.0, 99.0, 13.0] // [14.0, 15.0, 98.0, 17.0] // [18.0, 19.0, 97.0, 21.0] // [22.0, 23.0, 96.0, 25.0]

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • index: number

      The zero-based index of the column to set.

    • cartesian: Cartesian4

      The Cartesian whose values will be assigned to the specified column.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static setRotation

  • setRotation(matrix: Matrix4, rotation: Matrix3, result: Matrix4): Matrix4
  • Sets the rotation assuming the matrix is an affine transformation.

    Parameters

    • matrix: Matrix4

      The matrix.

    • rotation: Matrix3

      The rotation matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static setRow

  • setRow(matrix: Matrix4, index: number, cartesian: Cartesian4, result: Matrix4): Matrix4
  • Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian4 instance.

    example

    //create a new Matrix4 instance with new row values from the Cartesian4 instance // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    var a = Cesium.Matrix4.setRow(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());

    // m remains the same // a = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [99.0, 98.0, 97.0, 96.0] // [22.0, 23.0, 24.0, 25.0]

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • index: number

      The zero-based index of the row to set.

    • cartesian: Cartesian4

      The Cartesian whose values will be assigned to the specified row.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static setScale

  • setScale(matrix: Matrix4, scale: Cartesian3, result: Matrix4): Matrix4
  • Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • scale: Cartesian3

      The scale that replaces the scale of the provided matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static setTranslation

  • setTranslation(matrix: Matrix4, translation: Cartesian3, result: Matrix4): Matrix4
  • Computes a new matrix that replaces the translation in the rightmost column of the provided matrix with the provided translation. This assumes the matrix is an affine transformation

    Parameters

    • matrix: Matrix4

      The matrix to use.

    • translation: Cartesian3

      The translation that replaces the translation of the provided matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static subTransform

  • subTransform(matrix: Matrix4, transform: Cartesian3, result: Matrix4): Matrix4
  • Parameters

    • matrix: Matrix4

      The matrix to use.

    • transform: Cartesian3

      The transform need to subtract

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static subtract

  • subtract(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4
  • Computes the difference of two matrices.

    Parameters

    • left: Matrix4

      The first matrix.

    • right: Matrix4

      The second matrix.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static toArray

Static transpose

  • transpose(matrix: Matrix4, result: Matrix4): Matrix4
  • Computes the transpose of the provided matrix.

    example

    //returns transpose of a Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0]

    var a = Cesium.Matrix4.transpose(m, new Cesium.Matrix4());

    // m remains the same // a = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]

    Parameters

    • matrix: Matrix4

      The matrix to transpose.

    • result: Matrix4

      The object onto which to store the result.

    Returns Matrix4

    The modified result parameter.

Static unpack

  • unpack(array: number[], startingIndex?: number, result?: Matrix4): Matrix4
  • Retrieves an instance from a packed array.

    Parameters

    • array: number[]

      The packed array.

    • Optional startingIndex: number
    • Optional result: Matrix4

    Returns Matrix4

    The modified result parameter or a new Matrix4 instance if one was not provided.