Appearance
KBE3D / KBCore / Cesium / Matrix2
类: Matrix2
A 2x2 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.
参数
The value for column 0, row 0.
参数
The value for column 1, row 0.
参数
The value for column 0, row 1.
参数
The value for column 1, row 1.
继承
ArrayLike<number>
实现
ArrayLike<number>
可索引
[n: number]: number
属性
packedLength
staticpackedLength:number
The number of elements used to pack the object into an array.
IDENTITY
readonlystaticIDENTITY:Matrix2
An immutable Matrix2 instance initialized to the identity matrix.
ZERO
readonlystaticZERO:Matrix2
An immutable Matrix2 instance initialized to the zero matrix.
COLUMN0ROW0
readonlystaticCOLUMN0ROW0:number
The index into Matrix2 for column 0, row 0.
示例
ts
const matrix = new Cesium.Matrix2();
matrix[Cesium.Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0COLUMN0ROW1
readonlystaticCOLUMN0ROW1:number
The index into Matrix2 for column 0, row 1.
示例
ts
const matrix = new Cesium.Matrix2();
matrix[Cesium.Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0COLUMN1ROW0
readonlystaticCOLUMN1ROW0:number
The index into Matrix2 for column 1, row 0.
示例
ts
const matrix = new Cesium.Matrix2();
matrix[Cesium.Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0COLUMN1ROW1
readonlystaticCOLUMN1ROW1:number
The index into Matrix2 for column 1, row 1.
示例
ts
const matrix = new Cesium.Matrix2();
matrix[Cesium.Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0length
length:
number
Gets the number of items in the collection.
继承自
ArrayLike.length
方法
pack()
staticpack(value:Matrix2,array:number[],startingIndex?:number):number[]
Stores the provided instance into the provided array.
参数
value
Matrix2
The value to pack.
array
number[]
The array to pack into.
startingIndex?
number
The index into the array at which to start packing the elements.
返回
number[]
The array that was packed into
unpack()
staticunpack(array:number[],startingIndex?:number,result?:Matrix2):Matrix2
Retrieves an instance from a packed array.
参数
array
number[]
The packed array.
startingIndex?
number
The starting index of the element to be unpacked.
result?
Matrix2
The object into which to store the result.
返回
Matrix2
The modified result parameter or a new Matrix2 instance if one was not provided.
packArray()
staticpackArray(array:Matrix2[],result?:number[]):number[]
Flattens an array of Matrix2s into an array of components. The components are stored in column-major order.
参数
array
Matrix2[]
The array of matrices to pack.
result?
number[]
The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a DeveloperError will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
返回
number[]
The packed array.
unpackArray()
staticunpackArray(array:number[],result?:Matrix2[]):Matrix2[]
Unpacks an array of column-major matrix components into an array of Matrix2s.
参数
array
number[]
The array of components to unpack.
result?
Matrix2[]
The array onto which to store the result.
返回
Matrix2[]
The unpacked array.
clone()
staticclone(matrix:Matrix2,result?:Matrix2):Matrix2
Duplicates a Matrix2 instance.
参数
matrix
Matrix2
The matrix to duplicate.
result?
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)
fromArray()
staticfromArray(array:number[],startingIndex?:number,result?:Matrix2):Matrix2
Creates a Matrix2 from 4 consecutive elements in an array.
参数
array
number[]
The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
startingIndex?
number
The offset into the array of the first element, which corresponds to first column first row position in the matrix.
result?
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter or a new Matrix2 instance if one was not provided.
示例
ts
// Create the Matrix2:
// [1.0, 2.0]
// [1.0, 2.0]
const v = [1.0, 1.0, 2.0, 2.0];
const m = Cesium.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 = Cesium.Matrix2.fromArray(v2, 2);fromColumnMajorArray()
staticfromColumnMajorArray(values:number[],result?:Matrix2):Matrix2
Creates a Matrix2 instance from a column-major order array.
参数
values
number[]
The column-major order array.
result?
Matrix2
The object in which the result will be stored, if undefined a new instance will be created.
返回
Matrix2
The modified result parameter, or a new Matrix2 instance if one was not provided.
fromRowMajorArray()
staticfromRowMajorArray(values:number[],result?:Matrix2):Matrix2
Creates a Matrix2 instance from a row-major order array. The resulting matrix will be in column-major order.
参数
values
number[]
The row-major order array.
result?
Matrix2
The object in which the result will be stored, if undefined a new instance will be created.
返回
Matrix2
The modified result parameter, or a new Matrix2 instance if one was not provided.
fromScale()
staticfromScale(scale:Cartesian2,result?:Matrix2):Matrix2
Computes a Matrix2 instance representing a non-uniform scale.
参数
scale
The x and y scale factors.
result?
Matrix2
The object in which the result will be stored, if undefined a new instance will be created.
返回
Matrix2
The modified result parameter, or a new Matrix2 instance if one was not provided.
示例
ts
// Creates
// [7.0, 0.0]
// [0.0, 8.0]
const m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));fromUniformScale()
staticfromUniformScale(scale:number,result?:Matrix2):Matrix2
Computes a Matrix2 instance representing a uniform scale.
参数
scale
number
The uniform scale factor.
result?
Matrix2
The object in which the result will be stored, if undefined a new instance will be created.
返回
Matrix2
The modified result parameter, or a new Matrix2 instance if one was not provided.
示例
ts
// Creates
// [2.0, 0.0]
// [0.0, 2.0]
const m = Cesium.Matrix2.fromUniformScale(2.0);fromRotation()
staticfromRotation(angle:number,result?:Matrix2):Matrix2
Creates a rotation matrix.
参数
angle
number
The angle, in radians, of the rotation. Positive angles are counterclockwise.
result?
Matrix2
The object in which the result will be stored, if undefined a new instance will be created.
返回
Matrix2
The modified result parameter, or a new Matrix2 instance if one was not provided.
示例
ts
// Rotate a point 45 degrees counterclockwise.
const p = new Cesium.Cartesian2(5, 6);
const m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0));
const rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2());toArray()
statictoArray(matrix:Matrix2,result?:number[]):number[]
Creates an Array from the provided Matrix2 instance. The array will be in column-major order.
参数
matrix
Matrix2
The matrix to use..
result?
number[]
The Array onto which to store the result.
返回
number[]
The modified Array parameter or a new Array instance if one was not provided.
getElementIndex()
staticgetElementIndex(row:number,column:number):number
Computes the array index of the element at the provided row and column.
参数
row
number
The zero-based index of the row.
column
number
The zero-based index of the column.
返回
number
The index of the element at the provided row and column.
示例
ts
const myMatrix = new Cesium.Matrix2();
const column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0);
const column1Row0 = myMatrix[column1Row0Index]
myMatrix[column1Row0Index] = 10.0;getColumn()
staticgetColumn(matrix:Matrix2,index:number,result:Cartesian2):Cartesian2
Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
参数
matrix
Matrix2
The matrix to use.
index
number
The zero-based index of the column to retrieve.
result
The object onto which to store the result.
返回
The modified result parameter.
setColumn()
staticsetColumn(matrix:Matrix2,index:number,cartesian:Cartesian2,result:Cartesian2):Matrix2
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
参数
matrix
Matrix2
The matrix to use.
index
number
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.
返回
Matrix2
The modified result parameter.
getRow()
staticgetRow(matrix:Matrix2,index:number,result:Cartesian2):Cartesian2
Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
参数
matrix
Matrix2
The matrix to use.
index
number
The zero-based index of the row to retrieve.
result
The object onto which to store the result.
返回
The modified result parameter.
setRow()
staticsetRow(matrix:Matrix2,index:number,cartesian:Cartesian2,result:Matrix2):Matrix2
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
参数
matrix
Matrix2
The matrix to use.
index
number
The zero-based index of the row to set.
cartesian
The Cartesian whose values will be assigned to the specified row.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
setScale()
staticsetScale(matrix:Matrix2,scale:Cartesian2,result:Matrix2):Matrix2
Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.
参数
matrix
Matrix2
The matrix to use.
scale
The scale that replaces the scale of the provided matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
setUniformScale()
staticsetUniformScale(matrix:Matrix2,scale:number,result:Matrix2):Matrix2
Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.
参数
matrix
Matrix2
The matrix to use.
scale
number
The uniform scale that replaces the scale of the provided matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
getScale()
staticgetScale(matrix:Matrix2,result:Cartesian2):Cartesian2
Extracts the non-uniform scale assuming the matrix is an affine transformation.
参数
matrix
Matrix2
The matrix.
result
The object onto which to store the result.
返回
The modified result parameter.
getMaximumScale()
staticgetMaximumScale(matrix:Matrix2):number
Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.
参数
matrix
Matrix2
The matrix.
返回
number
The maximum scale.
setRotation()
staticsetRotation(matrix:Matrix2,rotation:Matrix2,result:Matrix2):Matrix2
Sets the rotation assuming the matrix is an affine transformation.
参数
matrix
Matrix2
The matrix.
rotation
Matrix2
The rotation matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
getRotation()
staticgetRotation(matrix:Matrix2,result:Matrix2):Matrix2
Extracts the rotation matrix assuming the matrix is an affine transformation.
参数
matrix
Matrix2
The matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
multiply()
staticmultiply(left:Matrix2,right:Matrix2,result:Matrix2):Matrix2
Computes the product of two matrices.
参数
left
Matrix2
The first matrix.
right
Matrix2
The second matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
add()
staticadd(left:Matrix2,right:Matrix2,result:Matrix2):Matrix2
Computes the sum of two matrices.
参数
left
Matrix2
The first matrix.
right
Matrix2
The second matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
subtract()
staticsubtract(left:Matrix2,right:Matrix2,result:Matrix2):Matrix2
Computes the difference of two matrices.
参数
left
Matrix2
The first matrix.
right
Matrix2
The second matrix.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
multiplyByVector()
staticmultiplyByVector(matrix:Matrix2,cartesian:Cartesian2,result:Cartesian2):Cartesian2
Computes the product of a matrix and a column vector.
参数
matrix
Matrix2
The matrix.
cartesian
The column.
result
The object onto which to store the result.
返回
The modified result parameter.
multiplyByScalar()
staticmultiplyByScalar(matrix:Matrix2,scalar:number,result:Matrix2):Matrix2
Computes the product of a matrix and a scalar.
参数
matrix
Matrix2
The matrix.
scalar
number
The number to multiply by.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
multiplyByScale()
staticmultiplyByScale(matrix:Matrix2,scale:Cartesian2,result:Matrix2):Matrix2
Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
参数
matrix
Matrix2
The matrix on the left-hand side.
scale
The non-uniform scale on the right-hand side.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
示例
ts
// Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m);
Cesium.Matrix2.multiplyByScale(m, scale, m);multiplyByUniformScale()
staticmultiplyByUniformScale(matrix:Matrix2,scale:number,result:Matrix2):Matrix2
Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.
参数
matrix
Matrix2
The matrix on the left-hand side.
scale
number
The uniform scale on the right-hand side.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
示例
ts
// Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromUniformScale(scale), m);
Cesium.Matrix2.multiplyByUniformScale(m, scale, m);negate()
staticnegate(matrix:Matrix2,result:Matrix2):Matrix2
Creates a negated copy of the provided matrix.
参数
matrix
Matrix2
The matrix to negate.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
transpose()
statictranspose(matrix:Matrix2,result:Matrix2):Matrix2
Computes the transpose of the provided matrix.
参数
matrix
Matrix2
The matrix to transpose.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
abs()
staticabs(matrix:Matrix2,result:Matrix2):Matrix2
Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
参数
matrix
Matrix2
The matrix with signed elements.
result
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter.
equals()
staticequals(left?:Matrix2,right?:Matrix2):boolean
Compares the provided matrices componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.
参数
left?
Matrix2
The first matrix.
right?
Matrix2
The second matrix.
返回
boolean
true if left and right are equal, false otherwise.
equalsEpsilon()
staticequalsEpsilon(left?:Matrix2,right?:Matrix2,epsilon?:number):boolean
Compares the provided matrices componentwise and returns <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
参数
left?
Matrix2
The first matrix.
right?
Matrix2
The second matrix.
epsilon?
number
The epsilon to use for equality testing.
返回
boolean
true if left and right are within the provided epsilon, false otherwise.
clone()
clone(
result?:Matrix2):Matrix2
Duplicates the provided Matrix2 instance.
参数
result?
Matrix2
The object onto which to store the result.
返回
Matrix2
The modified result parameter or a new Matrix2 instance if one was not provided.
equals()
equals(
right?:Matrix2):boolean
Compares this matrix to the provided matrix componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.
参数
right?
Matrix2
The right hand side matrix.
返回
boolean
true if they are equal, false otherwise.
equalsEpsilon()
equalsEpsilon(
right?:Matrix2,epsilon?:number):boolean
Compares this matrix to the provided matrix componentwise and returns <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
参数
right?
Matrix2
The right hand side matrix.
epsilon?
number
The epsilon to use for equality testing.
返回
boolean
true if they are within the provided epsilon, false otherwise.
toString()
toString():
string
Creates a string representing this Matrix with each row being on a separate line and in the format '(column0, column1)'.
返回
string
A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'.
构造函数
构造函数
new Matrix2(
column0Row0?:number,column1Row0?:number,column0Row1?:number,column1Row1?:number):Matrix2
参数
column0Row0?
number
column1Row0?
number
column0Row1?
number
column1Row1?
number
返回
Matrix2
继承自
ArrayLike<number>.constructor
