main.cesium.Matrix2.kt Maven / Gradle / Ivy
The newest version!
// Automatically generated - do not modify!
@file:JsModule("cesium")
package cesium
/**
* A 2x2 matrix, indexable as a column-major order array.
* Constructor parameters are in row-major order for code readability.
* @see Online Documentation
*
* @constructor
* @param [column0Row0] The value for column 0, row 0.
* Default value - `0.0`
* @param [column1Row0] The value for column 1, row 0.
* Default value - `0.0`
* @param [column0Row1] The value for column 0, row 1.
* Default value - `0.0`
* @param [column1Row1] The value for column 1, row 1.
* Default value - `0.0`
* @see Online Documentation
*/
external class Matrix2(
column0Row0: Double? = definedExternally,
column1Row0: Double? = definedExternally,
column0Row1: Double? = definedExternally,
column1Row1: Double? = definedExternally,
) {
/**
* Gets the number of items in the collection.
* @see Online Documentation
*/
var length: Int
/**
* Duplicates the provided Matrix2 instance.
* @param [result] The object onto which to store the result.
* @return The modified result parameter or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun clone(result: Matrix2? = definedExternally): Matrix2
/**
* Compares this matrix to the provided matrix componentwise and returns
* `true` if they are within the provided epsilon,
* `false` otherwise.
* @param [right] The right hand side matrix.
* @param [epsilon] The epsilon to use for equality testing.
* Default value - `0`
* @return `true` if they are within the provided epsilon, `false` otherwise.
* @see Online Documentation
*/
fun equalsEpsilon(
right: Matrix2? = definedExternally,
epsilon: Double? = definedExternally,
): Boolean
companion object : Packable {
/**
* The number of elements used to pack the object into an array.
* @see Online Documentation
*/
override val packedLength: Int
/**
* Stores the provided instance into the provided array.
* @param [value] The value to pack.
* @param [array] The array to pack into.
* @param [startingIndex] The index into the array at which to start packing the elements.
* Default value - `0`
* @return The array that was packed into
* @see Online Documentation
*/
override fun pack(
value: Matrix2,
array: Array,
startingIndex: Int?,
): Array
/**
* Retrieves an instance from a packed array.
* @param [array] The packed array.
* @param [startingIndex] The starting index of the element to be unpacked.
* Default value - `0`
* @param [result] The object into which to store the result.
* @return The modified result parameter or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
override fun unpack(
array: Array,
startingIndex: Int?,
result: Matrix2?,
): Matrix2
/**
* Duplicates a Matrix2 instance.
* @param [matrix] The matrix to duplicate.
* @param [result] The object onto which to store the result.
* @return The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)
* @see Online Documentation
*/
fun clone(
matrix: Matrix2,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Creates a Matrix2 from 4 consecutive elements in an array.
* ```
* // Create the Matrix2:
* // [1.0, 2.0]
* // [1.0, 2.0]
*
* const v = [1.0, 1.0, 2.0, 2.0];
* const m = Matrix2.fromArray(v);
*
* // Create same Matrix2 with using an offset into an array
* const v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];
* const m2 = Matrix2.fromArray(v2, 2);
* ```
* @param [array] The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
* @param [startingIndex] The offset into the array of the first element, which corresponds to first column first row position in the matrix.
* Default value - `0`
* @param [result] The object onto which to store the result.
* @return The modified result parameter or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromArray(
array: Array,
startingIndex: Int? = definedExternally,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Creates a Matrix2 instance from a column-major order array.
* @param [values] The column-major order array.
* @param [result] The object in which the result will be stored, if undefined a new instance will be created.
* @return The modified result parameter, or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromColumnMajorArray(
values: Array,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Creates a Matrix2 instance from a row-major order array.
* The resulting matrix will be in column-major order.
* @param [values] The row-major order array.
* @param [result] The object in which the result will be stored, if undefined a new instance will be created.
* @return The modified result parameter, or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromRowMajorArray(
values: Array,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Computes a Matrix2 instance representing a non-uniform scale.
* ```
* // Creates
* // [7.0, 0.0]
* // [0.0, 8.0]
* const m = Matrix2.fromScale(new Cartesian2(7.0, 8.0));
* ```
* @param [scale] The x and y scale factors.
* @param [result] The object in which the result will be stored, if undefined a new instance will be created.
* @return The modified result parameter, or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromScale(
scale: Cartesian2,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Computes a Matrix2 instance representing a uniform scale.
* ```
* // Creates
* // [2.0, 0.0]
* // [0.0, 2.0]
* const m = Matrix2.fromUniformScale(2.0);
* ```
* @param [scale] The uniform scale factor.
* @param [result] The object in which the result will be stored, if undefined a new instance will be created.
* @return The modified result parameter, or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromUniformScale(
scale: Double,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Creates a rotation matrix.
* ```
* // Rotate a point 45 degrees counterclockwise.
* const p = new Cartesian2(5, 6);
* const m = Matrix2.fromRotation(Math.toRadians(45.0));
* const rotated = Matrix2.multiplyByVector(m, p, new Cartesian2());
* ```
* @param [angle] The angle, in radians, of the rotation. Positive angles are counterclockwise.
* @param [result] The object in which the result will be stored, if undefined a new instance will be created.
* @return The modified result parameter, or a new Matrix2 instance if one was not provided.
* @see Online Documentation
*/
fun fromRotation(
angle: Double,
result: Matrix2? = definedExternally,
): Matrix2
/**
* Creates an Array from the provided Matrix2 instance.
* The array will be in column-major order.
* @param [matrix] The matrix to use..
* @param [result] The Array onto which to store the result.
* @return The modified Array parameter or a new Array instance if one was not provided.
* @see Online Documentation
*/
fun toArray(
matrix: Matrix2,
result: Array? = definedExternally,
): Array
/**
* Computes the array index of the element at the provided row and column.
* ```
* const myMatrix = new Matrix2();
* const column1Row0Index = Matrix2.getElementIndex(1, 0);
* const column1Row0 = myMatrix[column1Row0Index]
* myMatrix[column1Row0Index] = 10.0;
* ```
* @param [row] The zero-based index of the row.
* @param [column] The zero-based index of the column.
* @return The index of the element at the provided row and column.
* @see Online Documentation
*/
fun getElementIndex(
row: Int,
column: Int,
): Int
/**
* Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
* @param [matrix] The matrix to use.
* @param [index] The zero-based index of the column to retrieve.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun getColumn(
matrix: Matrix2,
index: Int,
result: Cartesian2,
): Cartesian2
/**
* Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
* @param [matrix] The matrix to use.
* @param [index] The zero-based index of the column to set.
* @param [cartesian] The Cartesian whose values will be assigned to the specified column.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun setColumn(
matrix: Matrix2,
index: Int,
cartesian: Cartesian2,
result: Cartesian2,
): Matrix2
/**
* Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
* @param [matrix] The matrix to use.
* @param [index] The zero-based index of the row to retrieve.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun getRow(
matrix: Matrix2,
index: Int,
result: Cartesian2,
): Cartesian2
/**
* Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
* @param [matrix] The matrix to use.
* @param [index] The zero-based index of the row to set.
* @param [cartesian] The Cartesian whose values will be assigned to the specified row.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun setRow(
matrix: Matrix2,
index: Int,
cartesian: Cartesian2,
result: Matrix2,
): Matrix2
/**
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
* @param [matrix] The matrix.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun getScale(
matrix: Matrix2,
result: Cartesian2,
): Cartesian2
/**
* Computes the maximum scale assuming the matrix is an affine transformation.
* The maximum scale is the maximum length of the column vectors.
* @param [matrix] The matrix.
* @return The maximum scale.
* @see Online Documentation
*/
fun getMaximumScale(matrix: Matrix2): Double
/**
* Computes the product of two matrices.
* @param [left] The first matrix.
* @param [right] The second matrix.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun multiply(
left: Matrix2,
right: Matrix2,
result: Matrix2,
): Matrix2
/**
* Computes the sum of two matrices.
* @param [left] The first matrix.
* @param [right] The second matrix.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun add(
left: Matrix2,
right: Matrix2,
result: Matrix2,
): Matrix2
/**
* Computes the difference of two matrices.
* @param [left] The first matrix.
* @param [right] The second matrix.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun subtract(
left: Matrix2,
right: Matrix2,
result: Matrix2,
): Matrix2
/**
* Computes the product of a matrix and a column vector.
* @param [matrix] The matrix.
* @param [cartesian] The column.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun multiplyByVector(
matrix: Matrix2,
cartesian: Cartesian2,
result: Cartesian2,
): Cartesian2
/**
* Computes the product of a matrix and a scalar.
* @param [matrix] The matrix.
* @param [scalar] The number to multiply by.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun multiplyByScalar(
matrix: Matrix2,
scalar: Double,
result: Matrix2,
): Matrix2
/**
* Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
* ```
* // Instead of Matrix2.multiply(m, Matrix2.fromScale(scale), m);
* Matrix2.multiplyByScale(m, scale, m);
* ```
* @param [matrix] The matrix on the left-hand side.
* @param [scale] The non-uniform scale on the right-hand side.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun multiplyByScale(
matrix: Matrix2,
scale: Cartesian2,
result: Matrix2,
): Matrix2
/**
* Creates a negated copy of the provided matrix.
* @param [matrix] The matrix to negate.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun negate(
matrix: Matrix2,
result: Matrix2,
): Matrix2
/**
* Computes the transpose of the provided matrix.
* @param [matrix] The matrix to transpose.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun transpose(
matrix: Matrix2,
result: Matrix2,
): Matrix2
/**
* Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
* @param [matrix] The matrix with signed elements.
* @param [result] The object onto which to store the result.
* @return The modified result parameter.
* @see Online Documentation
*/
fun abs(
matrix: Matrix2,
result: Matrix2,
): Matrix2
/**
* Compares the provided matrices componentwise and returns
* `true` if they are equal, `false` otherwise.
* @param [left] The first matrix.
* @param [right] The second matrix.
* @return `true` if left and right are equal, `false` otherwise.
* @see Online Documentation
*/
fun equals(
left: Matrix2? = definedExternally,
right: Matrix2? = definedExternally,
): Boolean
/**
* Compares the provided matrices componentwise and returns
* `true` if they are within the provided epsilon,
* `false` otherwise.
* @param [left] The first matrix.
* @param [right] The second matrix.
* @param [epsilon] The epsilon to use for equality testing.
* Default value - `0`
* @return `true` if left and right are within the provided epsilon, `false` otherwise.
* @see Online Documentation
*/
fun equalsEpsilon(
left: Matrix2? = definedExternally,
right: Matrix2? = definedExternally,
epsilon: Double? = definedExternally,
): Boolean
/**
* An immutable Matrix2 instance initialized to the identity matrix.
* @see Online Documentation
*/
val IDENTITY: Matrix2
/**
* An immutable Matrix2 instance initialized to the zero matrix.
* @see Online Documentation
*/
val ZERO: Matrix2
/**
* The index into Matrix2 for column 0, row 0.
* ```
* const matrix = new Matrix2();
* matrix[Cesium.Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0
* ```
* @see Online Documentation
*/
val COLUMN0ROW0: Double
/**
* The index into Matrix2 for column 0, row 1.
* ```
* const matrix = new Matrix2();
* matrix[Cesium.Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0
* ```
* @see Online Documentation
*/
val COLUMN0ROW1: Double
/**
* The index into Matrix2 for column 1, row 0.
* ```
* const matrix = new Matrix2();
* matrix[Cesium.Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0
* ```
* @see Online Documentation
*/
val COLUMN1ROW0: Double
/**
* The index into Matrix2 for column 1, row 1.
* ```
* const matrix = new Matrix2();
* matrix[Cesium.Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0
* ```
* @see Online Documentation
*/
val COLUMN1ROW1: Double
}
}