@JsType(isNative=true, namespace="Cesium", name="Matrix2") public class Matrix2 extends Object
Modifier and Type | Field and Description |
---|---|
int |
length
Gets the number of items in the collection.
|
static int |
packedLength
The number of elements used to pack the object into an array.
|
Constructor and Description |
---|
Matrix2()
A 2x2 matrix, indexable as a column-major order array.
|
Matrix2(double column0Row0,
double column1Row0,
double column0Row1,
double column1Row1)
A 2x2 matrix, indexable as a column-major order array.
|
Modifier and Type | Method and Description |
---|---|
static Matrix2 |
abs(Matrix2 matrix,
Matrix2 result)
Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
|
static Matrix2 |
add(Matrix2 left,
Matrix2 right,
Matrix2 result)
Computes the sum of two matrices.
|
Matrix2 |
clone()
Duplicates the provided Matrix2 instance.
|
Matrix2 |
clone(Matrix2 result)
Duplicates the provided Matrix2 instance.
|
static Matrix2 |
clone(Matrix2 matrix,
Matrix2 result)
Duplicates a Matrix2 instance.
|
static int |
COLUMN0ROW0()
The index into Matrix2 for column 0, row 0.
|
static int |
COLUMN0ROW1()
The index into Matrix2 for column 0, row 0.
|
static int |
COLUMN1ROW0()
The index into Matrix2 for column 0, row 0.
|
static int |
COLUMN1ROW1()
The index into Matrix2 for column 0, row 0.
|
boolean |
equals(Matrix2 right)
Compares this matrix to the provided matrix componentwise and returns true if they are equal, false otherwise.
|
static boolean |
equals(Matrix2 left,
Matrix2 right)
Compares the provided matrices componentwise and returns true if they are equal, false otherwise.
|
boolean |
equalsEpsilon(Matrix2 right,
double epsilon)
Compares this matrix to the provided matrix componentwise and returns true if they are within the provided epsilon, false otherwise.
|
static boolean |
equalsEpsilon(Matrix2 left,
Matrix2 right,
double epsilon)
Compares the provided matrices componentwise and returns true if they are within the provided epsilon, false otherwise.
|
static Matrix2 |
fromArray(double[] array)
Creates a Matrix2 from 4 consecutive elements in an array.
|
static Matrix2 |
fromArray(double[] array,
int startingIndex)
Creates a Matrix2 from 4 consecutive elements in an array.
|
static Matrix2 |
fromArray(double[] array,
int startingIndex,
Matrix2 result)
Creates a Matrix2 from 4 consecutive elements in an array.
|
static Matrix2 |
fromColumnMajorArray(double[] values)
Creates a Matrix2 instance from a column-major order array.
|
static Matrix2 |
fromColumnMajorArray(double[] values,
Matrix2 result)
Creates a Matrix2 instance from a column-major order array.
|
static Matrix2 |
fromRotation(double angle)
Creates a rotation matrix.
|
static Matrix2 |
fromRotation(double angle,
Matrix2 result)
Creates a rotation matrix.
|
static Matrix2 |
fromRowMajorArray(double[] values)
Creates a Matrix2 instance from a row-major order array.
|
static Matrix2 |
fromRowMajorArray(double[] values,
Matrix2 result)
Creates a Matrix2 instance from a row-major order array.
|
static Matrix2 |
fromScale(Cartesian2 scale)
Computes a Matrix2 instance representing a non-uniform scale.
|
static Matrix2 |
fromScale(Cartesian2 scale,
Matrix2 result)
Computes a Matrix2 instance representing a non-uniform scale.
|
static Matrix2 |
fromUniformScale(double scale)
Computes a Matrix2 instance representing a uniform scale.
|
static Matrix2 |
fromUniformScale(double scale,
Matrix2 result)
Computes a Matrix2 instance representing a uniform scale.
|
static Cartesian2 |
getColumn(Matrix2 matrix,
int index,
Cartesian2 result)
Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
|
static double |
getElementIndex(int row,
int column)
Computes the array index of the element at the provided row and column.
|
static double |
getMaximumScale(Matrix2 matrix)
Computes the maximum scale assuming the matrix is an affine transformation.
|
static Cartesian2 |
getRow(Matrix2 matrix,
int index,
Cartesian2 result)
Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
|
static Cartesian2 |
getScale(Matrix2 matrix,
Cartesian2 result)
Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
static Matrix2 |
IDENTITY()
An immutable Matrix2 instance initialized to the identity matrix.
|
static Matrix2 |
multiply(Matrix2 left,
Matrix2 right,
Matrix2 result)
Computes the product of two matrices.
|
static Matrix2 |
multiplyByScalar(Matrix2 matrix,
double scalar,
Matrix2 result)
Computes the product of a matrix and a scalar.
|
static Matrix2 |
multiplyByScale(Matrix2 matrix,
Cartesian2 scale,
Matrix2 result)
Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
|
static Cartesian2 |
multiplyByVector(Matrix2 matrix,
Cartesian2 cartesian,
Cartesian2 result)
Computes the product of a matrix and a column vector.
|
static Matrix2 |
negate(Matrix2 matrix,
Matrix2 result)
Creates a negated copy of the provided matrix.
|
static double[] |
pack(Matrix2 value,
double[] array)
Stores the provided instance into the provided array.
|
static double[] |
pack(Matrix2 value,
double[] array,
int startingIndex)
Stores the provided instance into the provided array.
|
static Matrix2 |
setColumn(Matrix2 matrix,
int index,
Cartesian2 cartesian,
Matrix2 result)
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
|
static Matrix2 |
setRow(Matrix2 matrix,
int index,
Cartesian2 cartesian,
Matrix2 result)
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
|
static Matrix2 |
subtract(Matrix2 left,
Matrix2 right,
Matrix2 result)
Computes the difference of two matrices.
|
static double[] |
toArray(Matrix2 matrix)
Creates an Array from the provided Matrix2 instance.
|
static double[] |
toArray(Matrix2 matrix,
double[] result)
Creates an Array from the provided Matrix2 instance.
|
String |
toString()
Creates a string representing this Matrix with each row being on a separate line and in the format '(column0, column1)'.
|
static Matrix2 |
transpose(Matrix2 matrix,
Matrix2 result)
Computes the transpose of the provided matrix.
|
static Matrix2 |
unpack(double[] array)
Retrieves an instance from a packed array.
|
static Matrix2 |
unpack(double[] array,
int startingIndex)
Retrieves an instance from a packed array.
|
static Matrix2 |
unpack(double[] array,
int startingIndex,
Matrix2 result)
Retrieves an instance from a packed array.
|
static Matrix2 |
ZERO()
An immutable Matrix2 instance initialized to the zero matrix.
|
@JsProperty public int length
@JsProperty public static int packedLength
@JsConstructor public Matrix2()
@JsConstructor public Matrix2(double column0Row0, double column1Row0, double column0Row1, double column1Row1)
column0Row0
- The value for column 0, row 0.column1Row0
- The value for column 1, row 0.column0Row1
- The value for column 0, row 1.column1Row1
- The value for column 1, row 1.fromColumnMajorArray(double[])
,
fromColumnMajorArray(double[], Matrix2)
,
fromRowMajorArray(double[])
,
fromRowMajorArray(double[], Matrix2)
,
fromScale(Cartesian2)
,
fromScale(Cartesian2, Matrix2)
,
Matrix3
,
Matrix4
@JsProperty(name="COLUMN0ROW0") public static int COLUMN0ROW0()
Example:
Matrix2 matrix = new Matrix2();
matrix[Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0
@JsProperty(name="COLUMN0ROW1") public static int COLUMN0ROW1()
Example:
Matrix2 matrix = new Matrix2();
matrix[Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0
@JsProperty(name="COLUMN0ROW0") public static int COLUMN1ROW0()
Example:
Matrix2 matrix = new Matrix2();
matrix[Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0
@JsProperty(name="COLUMN0ROW0") public static int COLUMN1ROW1()
Example:
Matrix2 matrix = new Matrix2();
matrix[Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0
@JsProperty(name="IDENTITY") public static Matrix2 IDENTITY()
@JsProperty(name="ZERO") public static Matrix2 ZERO()
@JsMethod public Matrix2 clone()
@JsMethod public Matrix2 clone(Matrix2 result)
result
- The object onto which to store the result.@JsMethod public boolean equals(Matrix2 right)
right
- The right hand side matrix.@JsMethod public boolean equalsEpsilon(Matrix2 right, double epsilon)
right
- The right hand side matrix.epsilon
- The epsilon to use for equality testing.@JsMethod public String toString()
@JsMethod public static Matrix2 abs(Matrix2 matrix, Matrix2 result)
matrix
- The matrix with signed elements.result
- The object onto which to store the result.@JsMethod public static Matrix2 add(Matrix2 left, Matrix2 right, Matrix2 result)
left
- The first matrix.right
- The second matrix.result
- The object onto which to store the result.@JsMethod public static Matrix2 clone(Matrix2 matrix, Matrix2 result)
matrix
- The matrix to duplicate.result
- The object onto which to store the result.@JsMethod public static boolean equals(Matrix2 left, Matrix2 right)
left
- The first matrix.right
- The second matrix.@JsMethod public static boolean equalsEpsilon(Matrix2 left, Matrix2 right, double epsilon)
left
- The first matrix.right
- The second matrix.epsilon
- The epsilon to use for equality testing.@JsMethod public static Matrix2 fromArray(double[] array)
// Create the Matrix2:
// [1.0, 2.0]
// [1.0, 2.0]
double[] v = {1.0, 1.0, 2.0, 2.0};
Matrix2 m = Matrix2.fromArray(v);
// Create same Matrix2 with using an offset into an array
double[] v2 = {0.0, 0.0, 1.0, 1.0, 2.0, 2.0};
Matrix2 m2 = Matrix2.fromArray(v2, 2);
array
- The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.@JsMethod public static Matrix2 fromArray(double[] array, int startingIndex)
// Create the Matrix2:
// [1.0, 2.0]
// [1.0, 2.0]
double[] v = {1.0, 1.0, 2.0, 2.0};
Matrix2 m = Matrix2.fromArray(v);
// Create same Matrix2 with using an offset into an array
double[] v2 = {0.0, 0.0, 1.0, 1.0, 2.0, 2.0};
Matrix2 m2 = Matrix2.fromArray(v2, 2);
array
- The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.startingIndex
- The offset into the array of the first element, which corresponds to first column first row position in the matrix.
Default 0@JsMethod public static Matrix2 fromArray(double[] array, int startingIndex, Matrix2 result)
// Create the Matrix2:
// [1.0, 2.0]
// [1.0, 2.0]
double[] v = {1.0, 1.0, 2.0, 2.0};
Matrix2 m = Matrix2.fromArray(v);
// Create same Matrix2 with using an offset into an array
double[] v2 = {0.0, 0.0, 1.0, 1.0, 2.0, 2.0};
Matrix2 m2 = Matrix2.fromArray(v2, 2);
array
- The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.startingIndex
- The offset into the array of the first element, which corresponds to first column first row position in the matrix.
Default 0result
- The object onto which to store the result.@JsMethod public static Matrix2 fromColumnMajorArray(double[] values)
values
- The column-major order array.@JsMethod public static Matrix2 fromColumnMajorArray(double[] values, Matrix2 result)
values
- The column-major order array.result
- The object in which the result will be stored, if undefined a new instance will be created.@JsMethod public static Matrix2 fromRotation(double angle)
Example:
// Rotate a point 45 degrees counterclockwise.
Cartesian2 p = new Cartesian2(5, 6);
Matrix2 m = Matrix2.fromRotation(Math.toRadians(45.0));
Matrix2 rotated = Matrix2.multiplyByVector(m, p, new Cartesian2());
angle
- The angle, in radians, of the rotation. Positive angles are counterclockwise.@JsMethod public static Matrix2 fromRotation(double angle, Matrix2 result)
Example:
// Rotate a point 45 degrees counterclockwise.
Cartesian2 p = new Cartesian2(5, 6);
Matrix2 m = Matrix2.fromRotation(Math.toRadians(45.0));
Matrix2 rotated = Matrix2.multiplyByVector(m, p, new Cartesian2());
angle
- The angle, in radians, of the rotation. Positive angles are counterclockwise.result
- The object in which the result will be stored, if undefined a new instance will be created.@JsMethod public static Matrix2 fromRowMajorArray(double[] values)
values
- The row-major order array.@JsMethod public static Matrix2 fromRowMajorArray(double[] values, Matrix2 result)
values
- The row-major order array.result
- The object in which the result will be stored, if undefined a new instance will be created.@JsMethod public static Matrix2 fromScale(Cartesian2 scale)
// Creates
// [7.0, 0.0]
// [0.0, 8.0]
Matrix2 m = Matrix2.fromScale(new Cartesian2(7.0, 8.0));
scale
- The x and y scale factors.@JsMethod public static Matrix2 fromScale(Cartesian2 scale, Matrix2 result)
// Creates
// [7.0, 0.0]
// [0.0, 8.0]
Matrix2 m = Matrix2.fromScale(new Cartesian2(7.0, 8.0));
scale
- The x and y scale factors.result
- The object in which the result will be stored, if undefined a new instance will be created.@JsMethod public static Matrix2 fromUniformScale(double scale)
// Creates
// [2.0, 0.0]
// [0.0, 2.0]
Matrix m = Matrix2.fromUniformScale(2.0);
scale
- The uniform scale factor.@JsMethod public static Matrix2 fromUniformScale(double scale, Matrix2 result)
// Creates
// [2.0, 0.0]
// [0.0, 2.0]
Matrix m = Matrix2.fromUniformScale(2.0);
scale
- The uniform scale factor.result
- The object in which the result will be stored, if undefined a new instance will be created.@JsMethod public static Cartesian2 getColumn(Matrix2 matrix, int index, Cartesian2 result)
matrix
- The matrix to use.index
- The zero-based index of the column to retrieve.result
- The object onto which to store the result.@JsMethod public static double getElementIndex(int row, int column)
Matrix2 myMatrix = new Matrix2();
int column1Row0Index = Matrix2.getElementIndex(1, 0);
int column1Row0 = myMatrix[column1Row0Index]
myMatrix[column1Row0Index] = 10.0;
row
- The zero-based index of the row.column
- The zero-based index of the column.@JsMethod public static double getMaximumScale(Matrix2 matrix)
matrix
- Matrix2 The matrix.@JsMethod public static Cartesian2 getRow(Matrix2 matrix, int index, Cartesian2 result)
matrix
- The matrix to use.index
- The zero-based index of the row to retrieve.result
- The object onto which to store the result.@JsMethod public static Cartesian2 getScale(Matrix2 matrix, Cartesian2 result)
matrix
- The matrix.result
- The object onto which to store the result.@JsMethod public static Matrix2 multiply(Matrix2 left, Matrix2 right, Matrix2 result)
left
- The first matrix.right
- The second matrix.result
- The object onto which to store the result.@JsMethod public static Matrix2 multiplyByScalar(Matrix2 matrix, double scalar, Matrix2 result)
matrix
- The matrix.scalar
- The number to multiply by.result
- The object onto which to store the result.@JsMethod public static Matrix2 multiplyByScale(Matrix2 matrix, Cartesian2 scale, Matrix2 result)
Example:
// Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m);
Matrix2.multiplyByScale(m, scale, m);
matrix
- The matrix on the left-hand side.scale
- The non-uniform scale on the right-hand side.result
- The object onto which to store the result.fromScale(org.cesiumjs.cs.core.Cartesian2)
,
fromScale(org.cesiumjs.cs.core.Cartesian2, org.cesiumjs.cs.core.Matrix2)
@JsMethod public static Cartesian2 multiplyByVector(Matrix2 matrix, Cartesian2 cartesian, Cartesian2 result)
matrix
- The matrix.cartesian
- The column.result
- The object onto which to store the result.@JsMethod public static Matrix2 negate(Matrix2 matrix, Matrix2 result)
matrix
- The matrix to negate.result
- The object onto which to store the result.@JsMethod public static double[] pack(Matrix2 value, double[] array)
value
- The value to pack.array
- The value to pack.@JsMethod public static double[] pack(Matrix2 value, double[] array, int startingIndex)
value
- The value to pack.array
- The value to pack.startingIndex
- The index into the array at which to start packing the elements. Default: 0@JsMethod public static Matrix2 setColumn(Matrix2 matrix, int index, Cartesian2 cartesian, Matrix2 result)
matrix
- The matrix to use.index
- The zero-based index of the column to set.cartesian
- The Cartesian whose values will be assigned to the specified column.result
- The object onto which to store the result.@JsMethod public static Matrix2 setRow(Matrix2 matrix, int index, Cartesian2 cartesian, Matrix2 result)
matrix
- The matrix to use.index
- The zero-based index of the row to set.cartesian
- The Cartesian whose values will be assigned to the specified row.result
- The object onto which to store the result.@JsMethod public static Matrix2 subtract(Matrix2 left, Matrix2 right, Matrix2 result)
left
- The first matrix.right
- The second matrix.result
- The object onto which to store the result.@JsMethod public static double[] toArray(Matrix2 matrix)
matrix
- The matrix to use.@JsMethod public static double[] toArray(Matrix2 matrix, double[] result)
matrix
- The matrix to use.result
- The Array onto which to store the result.@JsMethod public static Matrix2 transpose(Matrix2 matrix, Matrix2 result)
matrix
- The matrix to transpose.result
- The object onto which to store the result.@JsMethod public static Matrix2 unpack(double[] array)
array
- The packed array.@JsMethod public static Matrix2 unpack(double[] array, int startingIndex)
array
- The packed array.startingIndex
- The starting index of the element to be unpacked.@JsMethod public static Matrix2 unpack(double[] array, int startingIndex, Matrix2 result)
array
- The packed array.startingIndex
- The starting index of the element to be unpacked.result
- The object into which to store the result.Copyright © 2019. All rights reserved.