Matrix2

Matrix2

new

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

Parameters:
Name Type Argument Default Description
column0Row0 Number <optional>
0.0 The value for column 0, row 0.
column1Row0 Number <optional>
0.0 The value for column 1, row 0.
column0Row1 Number <optional>
0.0 The value for column 0, row 1.
column1Row1 Number <optional>
0.0 The value for column 1, row 1.
See:
Source:

Members

<static>

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

<static>

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

<static>

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

<static>

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

<static>

An immutable Matrix2 instance initialized to the identity matrix.

Methods

Duplicates the provided Matrix2 instance.

Parameters:
Name Type Argument Description
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.

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

Parameters:
Name Type Argument Description
right Matrix2 <optional>
The right hand side matrix.
Returns:
Boolean true if they are equal, false otherwise.

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

Parameters:
Name Type Argument Description
right Matrix2 <optional>
The right hand side matrix.
epsilon Number The epsilon to use for equality testing.
Returns:
Boolean true if they are within the provided epsilon, false otherwise.

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

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

<static>

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

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix with signed elements.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.

<static>

Duplicates a Matrix2 instance.

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to duplicate.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)

<static>

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

Parameters:
Name Type Argument Description
left Matrix2 <optional>
The first matrix.
right Matrix2 <optional>
The second matrix.
Returns:
Boolean true if left and right are equal, false otherwise.

<static>

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

Parameters:
Name Type Argument Description
left Matrix2 <optional>
The first matrix.
right Matrix2 <optional>
The second matrix.
epsilon Number The epsilon to use for equality testing.
Returns:
Boolean true if left and right are within the provided epsilon, false otherwise.

<static>

Creates a Matrix2 from 4 consecutive elements in an array.

Parameters:
Name Type Argument Default Description
array Array The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
startingIndex Number <optional>
0 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:
Matrix2 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);

<static>

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

Parameters:
Name Type Argument Description
values Array 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.

<static>

Creates a rotation matrix.

Parameters:
Name Type Argument 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);

<static>

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

Parameters:
Name Type Argument Description
values Array 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.

<static>

Computes a Matrix2 instance representing a non-uniform scale.

Parameters:
Name Type Argument 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));

<static>

Computes a Matrix2 instance representing a uniform scale.

Parameters:
Name Type Argument 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);

<static>

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

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to use.
index Number The zero-based index of the column to retrieve.
result Cartesian2 <optional>
The object onto which to store the result.
Throws:
DeveloperError : index must be 0 or 1.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided.
See:

<static>

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

Parameters:
Name Type Description
row Number The zero-based index of the row.
column Number The zero-based index of the column.
Throws:
Returns:
Number The index of the element at the provided row and column.
Example
var myMatrix = new Cesium.Matrix2();
var column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0);
var column1Row0 = myMatrix[column1Row0Index]
myMatrix[column1Row0Index] = 10.0;

<static>

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

Parameters:
Name Type Description
matrix Matrix2 The matrix.
Returns:
Number The maximum scale.

<static>

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

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to use.
index Number The zero-based index of the row to retrieve.
result Cartesian2 <optional>
The object onto which to store the result.
Throws:
DeveloperError : index must be 0 or 1.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided.
See:

<static>

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

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix.
result Cartesian2 <optional>
The object onto which to store the result.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided.

<static>

Computes the product of two matrices.

Parameters:
Name Type Argument Description
left Matrix2 The first matrix.
right Matrix2 The second matrix.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.

<static>

Computes the product of a matrix and a scalar.

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix.
scalar Number The number to multiply by.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Cartesian2 instance if one was not provided.

<static>

Computes the product of a matrix and a column vector.

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix.
cartesian Cartesian2 The column.
result Cartesian2 <optional>
The object onto which to store the result.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided.

<static>

Creates a negated copy of the provided matrix.

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to negate.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.

<static>

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

Parameters:
Name Type Argument 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 <optional>
The object onto which to store the result.
Throws:
DeveloperError : index must be 0 or 1.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.
See:

<static>

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

Parameters:
Name Type Argument 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 Cartesian2 <optional>
The object onto which to store the result.
Throws:
DeveloperError : index must be 0 or 1.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.
See:

<static>

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

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to use..
result Array <optional>
The Array onto which to store the result.
Returns:
Array The modified Array parameter or a new Array instance if one was not provided.

<static>

Computes the transpose of the provided matrix.

Parameters:
Name Type Argument Description
matrix Matrix2 The matrix to transpose.
result Matrix2 <optional>
The object onto which to store the result.
Returns:
Matrix2 The modified result parameter or a new Matrix2 instance if one was not provided.