# Matrix2

#### new Cesium.Matrix2(column0Row0, column1Row0, column0Row1, column1Row1)
Core/Matrix2.js 34

  A 2x2 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `column0Row0` | Number | `0.0` | optional The value for column 0, row 0.
  `column1Row0` | Number | `0.0` | optional The value for column 1, row 0.
  `column0Row1` | Number | `0.0` | optional The value for column 0, row 1.
  `column1Row1` | Number | `0.0` | optional The value for column 1, row 1.

  ##### See:

  - Matrix2.fromColumnMajorArray
  - Matrix2.fromRowMajorArray
  - Matrix2.fromScale
  - Matrix2.fromUniformScale
  - Matrix3
  - Matrix4

### Members

#### static constantCesium.Matrix2.COLUMN0ROW0 : Number
Core/Matrix2.js 871

  The index into Matrix2 for column 0, row 0.

  ##### Example:

      var matrix = new Cesium.Matrix2();
      matrix[Cesium.Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0

#### static constantCesium.Matrix2.COLUMN0ROW1 : Number
Core/Matrix2.js 883

  The index into Matrix2 for column 0, row 1.

  ##### Example:

      var matrix = new Cesium.Matrix2();
      matrix[Cesium.Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0

#### static constantCesium.Matrix2.COLUMN1ROW0 : Number
Core/Matrix2.js 895

  The index into Matrix2 for column 1, row 0.

  ##### Example:

      var matrix = new Cesium.Matrix2();
      matrix[Cesium.Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0

#### static constantCesium.Matrix2.COLUMN1ROW1 : Number
Core/Matrix2.js 907

  The index into Matrix2 for column 1, row 1.

  ##### Example:

      var matrix = new Cesium.Matrix2();
      matrix[Cesium.Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0

#### static constantCesium.Matrix2.IDENTITY : Matrix2
Core/Matrix2.js 849

  An immutable Matrix2 instance initialized to the identity matrix.

#### staticCesium.Matrix2.packedLength : Number
Core/Matrix2.js 45

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

#### static constantCesium.Matrix2.ZERO : Matrix2
Core/Matrix2.js 858

  An immutable Matrix2 instance initialized to the zero matrix.

### Methods

#### clone(result) → Matrix2
Core/Matrix2.js 915

  Duplicates the provided Matrix2 instance.

  Name | Type | Description
  --- | --- | ---
  `result` | Matrix2 | optional The object onto which to store the result.

  ##### Returns:

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

#### equals(right) → Boolean
Core/Matrix2.js 926

  Compares this matrix to the provided matrix componentwise and returns `true` if they are equal, `false` otherwise.

  Name | Type | Description
  --- | --- | ---
  `right` | Matrix2 | optional The right hand side matrix.

  ##### Returns:

  `true` if they are equal, `false` otherwise.

#### equalsEpsilon(right, epsilon) → Boolean
Core/Matrix2.js 939

  Compares this matrix to the provided matrix componentwise and returns `true` if they are within the provided epsilon, `false` otherwise.

  Name | Type | Description
  --- | --- | ---
  `right` | Matrix2 | optional The right hand side matrix.
  `epsilon` | Number | The epsilon to use for equality testing.

  ##### Returns:

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

#### toString() → String
Core/Matrix2.js 949

  Creates a string representing this Matrix with each row being on a separate line and in the format '(column0, column1)'.

  ##### Returns:

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

#### staticCesium.Matrix2.abs(matrix, result) → Matrix2
Core/Matrix2.js 771

  Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix with signed elements.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.add(left, right, result) → Matrix2
Core/Matrix2.js 570

  Computes the sum of two matrices.

  Name | Type | Description
  --- | --- | ---
  `left` | Matrix2 | The first matrix.
  `right` | Matrix2 | The second matrix.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.clone(matrix, result) → Matrix2
Core/Matrix2.js 108

  Duplicates a Matrix2 instance.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to duplicate.
  `result` | Matrix2 | optional The object onto which to store the result.

  ##### Returns:

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

#### staticCesium.Matrix2.equals(left, right) → Boolean
Core/Matrix2.js 797

  Compares the provided matrices componentwise and returns `true` if they are equal, `false` otherwise.

  Name | Type | Description
  --- | --- | ---
  `left` | Matrix2 | optional The first matrix.
  `right` | Matrix2 | optional The second matrix.

  ##### Returns:

  `true` if left and right are equal, `false` otherwise.

#### staticCesium.Matrix2.equalsEpsilon(left, right, epsilon) → Boolean
Core/Matrix2.js 827

  Compares the provided matrices componentwise and returns `true` if they are within the provided epsilon, `false` otherwise.

  Name | Type | Description
  --- | --- | ---
  `left` | Matrix2 | optional The first matrix.
  `right` | Matrix2 | optional The second matrix.
  `epsilon` | Number | The epsilon to use for equality testing.

  ##### Returns:

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

#### staticCesium.Matrix2.fromArray(array, startingIndex, result) → Matrix2
Core/Matrix2.js 143

  Creates a Matrix2 from 4 consecutive elements in an array.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `array` | Array.<Number> |  | The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
  `startingIndex` | Number | `0` | optional The offset into the array of the first element, which corresponds to first column first row position in the matrix.
  `result` | Matrix2 |  | optional The object onto which to store the result.

  ##### Returns:

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

  ##### Example:

      // Create the Matrix2:
      // [1.0, 2.0]
      // [1.0, 2.0]

      var v = [1.0, 1.0, 2.0, 2.0];
      var m = Cesium.Matrix2.fromArray(v);

      // Create same Matrix2 with using an offset into an array
      var v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];
      var m2 = Cesium.Matrix2.fromArray(v2, 2);

#### staticCesium.Matrix2.fromColumnMajorArray(values, result) → Matrix2
Core/Matrix2.js 170

  Creates a Matrix2 instance from a column-major order array.

  Name | Type | Description
  --- | --- | ---
  `values` | Array.<Number> | The column-major order array.
  `result` | Matrix2 | optional The object in which the result will be stored, if undefined a new instance will be created.

  ##### Returns:

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

#### staticCesium.Matrix2.fromRotation(angle, result) → Matrix2
Core/Matrix2.js 285

  Creates a rotation matrix.

  Name | Type | Description
  --- | --- | ---
  `angle` | Number | The angle, in radians, of the rotation. Positive angles are counterclockwise.
  `result` | Matrix2 | optional The object in which the result will be stored, if undefined a new instance will be created.

  ##### Returns:

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

  ##### Example:

      // Rotate a point 45 degrees counterclockwise.
      var p = new Cesium.Cartesian2(5, 6);
      var m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0));
      var rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2());

#### staticCesium.Matrix2.fromRowMajorArray(values, result) → Matrix2
Core/Matrix2.js 188

  Creates a Matrix2 instance from a row-major order array. The resulting matrix will be in column-major order.

  Name | Type | Description
  --- | --- | ---
  `values` | Array.<Number> | The row-major order array.
  `result` | Matrix2 | optional The object in which the result will be stored, if undefined a new instance will be created.

  ##### Returns:

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

#### staticCesium.Matrix2.fromScale(scale, result) → Matrix2
Core/Matrix2.js 219

  Computes a Matrix2 instance representing a non-uniform scale.

  Name | Type | Description
  --- | --- | ---
  `scale` | Cartesian2 | The x and y scale factors.
  `result` | Matrix2 | optional The object in which the result will be stored, if undefined a new instance will be created.

  ##### Returns:

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

  ##### Example:

      // Creates
      //   [7.0, 0.0]
      //   [0.0, 8.0]
      var m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));

#### staticCesium.Matrix2.fromUniformScale(scale, result) → Matrix2
Core/Matrix2.js 252

  Computes a Matrix2 instance representing a uniform scale.

  Name | Type | Description
  --- | --- | ---
  `scale` | Number | The uniform scale factor.
  `result` | Matrix2 | optional The object in which the result will be stored, if undefined a new instance will be created.

  ##### Returns:

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

  ##### Example:

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

#### staticCesium.Matrix2.getColumn(matrix, index, result) → Cartesian2
Core/Matrix2.js 371

  Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to use.
  `index` | Number | The zero-based index of the column to retrieve.
  `result` | Cartesian2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

  ##### Throws:

  - DeveloperError : index must be 0 or 1.

#### staticCesium.Matrix2.getElementIndex(row, column) → Number
Core/Matrix2.js 348

  Computes the array index of the element at the provided row and column.

  Name | Type | Description
  --- | --- | ---
  `row` | Number | The zero-based index of the row.
  `column` | Number | The zero-based index of the column.

  ##### Returns:

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

  ##### Throws:

  - DeveloperError : row must be 0 or 1.
  - DeveloperError : column must be 0 or 1.

  ##### Example:

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

#### staticCesium.Matrix2.getMaximumScale(matrix) → Number
Core/Matrix2.js 524

  Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix.

  ##### Returns:

  The maximum scale.

#### staticCesium.Matrix2.getRow(matrix, index, result) → Cartesian2
Core/Matrix2.js 437

  Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to use.
  `index` | Number | The zero-based index of the row to retrieve.
  `result` | Cartesian2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

  ##### Throws:

  - DeveloperError : index must be 0 or 1.

#### staticCesium.Matrix2.getScale(matrix, result) → Cartesian2
Core/Matrix2.js 500

  Extracts the non-uniform scale assuming the matrix is an affine transformation.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix.
  `result` | Cartesian2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.multiply(left, right, result) → Matrix2
Core/Matrix2.js 537

  Computes the product of two matrices.

  Name | Type | Description
  --- | --- | ---
  `left` | Matrix2 | The first matrix.
  `right` | Matrix2 | The second matrix.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.multiplyByScalar(matrix, scalar, result) → Matrix2
Core/Matrix2.js 655

  Computes the product of a matrix and a scalar.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix.
  `scalar` | Number | The number to multiply by.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.multiplyByScale(matrix, scale, result) → Matrix2
Core/Matrix2.js 691

  Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix on the left-hand side.
  `scale` | Cartesian2 | The non-uniform scale on the right-hand side.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

  ##### Example:

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

  ##### See:

  - Matrix2.fromScale
  - Matrix2.multiplyByUniformScale

#### staticCesium.Matrix2.multiplyByVector(matrix, cartesian, result) → Cartesian2
Core/Matrix2.js 626

  Computes the product of a matrix and a column vector.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix.
  `cartesian` | Cartesian2 | The column.
  `result` | Cartesian2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.negate(matrix, result) → Matrix2
Core/Matrix2.js 718

  Creates a negated copy of the provided matrix.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to negate.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.pack(value, array, startingIndex)
Core/Matrix2.js 54

  Stores the provided instance into the provided array.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `value` | Matrix2 |  | The value to pack.
  `array` | Array.<Number> |  | The array to pack into.
  `startingIndex` | Number | `0` | optional The index into the array at which to start packing the elements.

#### staticCesium.Matrix2.setColumn(matrix, index, cartesian, result) → Matrix2
Core/Matrix2.js 404

  Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to use.
  `index` | Number | The zero-based index of the column to set.
  `cartesian` | Cartesian2 | The Cartesian whose values will be assigned to the specified column.
  `result` | Cartesian2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

  ##### Throws:

  - DeveloperError : index must be 0 or 1.

#### staticCesium.Matrix2.setRow(matrix, index, cartesian, result) → Matrix2
Core/Matrix2.js 469

  Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to use.
  `index` | Number | The zero-based index of the row to set.
  `cartesian` | Cartesian2 | The Cartesian whose values will be assigned to the specified row.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

  ##### Throws:

  - DeveloperError : index must be 0 or 1.

#### staticCesium.Matrix2.subtract(left, right, result) → Matrix2
Core/Matrix2.js 598

  Computes the difference of two matrices.

  Name | Type | Description
  --- | --- | ---
  `left` | Matrix2 | The first matrix.
  `right` | Matrix2 | The second matrix.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.toArray(matrix, result) → Array.<Number>
Core/Matrix2.js 315

  Creates an Array from the provided Matrix2 instance. The array will be in column-major order.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to use..
  `result` | Array.<Number> | optional The Array onto which to store the result.

  ##### Returns:

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

#### staticCesium.Matrix2.transpose(matrix, result) → Matrix2
Core/Matrix2.js 742

  Computes the transpose of the provided matrix.

  Name | Type | Description
  --- | --- | ---
  `matrix` | Matrix2 | The matrix to transpose.
  `result` | Matrix2 | The object onto which to store the result.

  ##### Returns:

  The modified result parameter.

#### staticCesium.Matrix2.unpack(array, startingIndex, result) → Matrix2
Core/Matrix2.js 81

  Retrieves an instance from a packed array.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `array` | Array.<Number> |  | The packed array.
  `startingIndex` | Number | `0` | optional The starting index of the element to be unpacked.
  `result` | Matrix2 |  | optional The object into which to store the result.

  ##### Returns:

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