Skip to content

KBE3D / KBCore / Cesium / Matrix3

类: Matrix3

A 3x3 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 2, row 0.

参数

The value for column 0, row 1.

参数

The value for column 1, row 1.

参数

The value for column 2, row 1.

参数

The value for column 0, row 2.

参数

The value for column 1, row 2.

参数

The value for column 2, row 2.

继承

  • ArrayLike<number>

实现

  • ArrayLike<number>

可索引

[n: number]: number

属性

packedLength

static packedLength: number

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


IDENTITY

readonly static IDENTITY: Matrix3

An immutable Matrix3 instance initialized to the identity matrix.


ZERO

readonly static ZERO: Matrix3

An immutable Matrix3 instance initialized to the zero matrix.


COLUMN0ROW0

readonly static COLUMN0ROW0: number

The index into Matrix3 for column 0, row 0.


COLUMN0ROW1

readonly static COLUMN0ROW1: number

The index into Matrix3 for column 0, row 1.


COLUMN0ROW2

readonly static COLUMN0ROW2: number

The index into Matrix3 for column 0, row 2.


COLUMN1ROW0

readonly static COLUMN1ROW0: number

The index into Matrix3 for column 1, row 0.


COLUMN1ROW1

readonly static COLUMN1ROW1: number

The index into Matrix3 for column 1, row 1.


COLUMN1ROW2

readonly static COLUMN1ROW2: number

The index into Matrix3 for column 1, row 2.


COLUMN2ROW0

readonly static COLUMN2ROW0: number

The index into Matrix3 for column 2, row 0.


COLUMN2ROW1

readonly static COLUMN2ROW1: number

The index into Matrix3 for column 2, row 1.


COLUMN2ROW2

readonly static COLUMN2ROW2: number

The index into Matrix3 for column 2, row 2.


length

length: number

Gets the number of items in the collection.

继承自

ArrayLike.length

方法

pack()

static pack(value: Matrix3, array: number[], startingIndex?: number): number[]

Stores the provided instance into the provided array.

参数

value

Matrix3

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()

static unpack(array: number[], startingIndex?: number, result?: Matrix3): Matrix3

Retrieves an instance from a packed array.

参数

array

number[]

The packed array.

startingIndex?

number

The starting index of the element to be unpacked.

result?

Matrix3

The object into which to store the result.

返回

Matrix3

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


packArray()

static packArray(array: Matrix3[], result?: number[]): number[]

Flattens an array of Matrix3s into an array of components. The components are stored in column-major order.

参数

array

Matrix3[]

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 * 9 components, else a DeveloperError will be thrown. If it is a regular array, it will be resized to have (array.length * 9) elements.

返回

number[]

The packed array.


unpackArray()

static unpackArray(array: number[], result?: Matrix3[]): Matrix3[]

Unpacks an array of column-major matrix components into an array of Matrix3s.

参数

array

number[]

The array of components to unpack.

result?

Matrix3[]

The array onto which to store the result.

返回

Matrix3[]

The unpacked array.


clone()

static clone(matrix: Matrix3, result?: Matrix3): Matrix3

Duplicates a Matrix3 instance.

参数

matrix

Matrix3

The matrix to duplicate.

result?

Matrix3

The object onto which to store the result.

返回

Matrix3

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


fromArray()

static fromArray(array: number[], startingIndex?: number, result?: Matrix3): Matrix3

Creates a Matrix3 from 9 consecutive elements in an array.

参数

array

number[]

The array whose 9 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?

Matrix3

The object onto which to store the result.

返回

Matrix3

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

示例

ts
// Create the Matrix3:
// [1.0, 2.0, 3.0]
// [1.0, 2.0, 3.0]
// [1.0, 2.0, 3.0]

const v = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
const m = Cesium.Matrix3.fromArray(v);

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

fromColumnMajorArray()

static fromColumnMajorArray(values: number[], result?: Matrix3): Matrix3

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

参数

values

number[]

The column-major order array.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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


fromRowMajorArray()

static fromRowMajorArray(values: number[], result?: Matrix3): Matrix3

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

参数

values

number[]

The row-major order array.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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


fromQuaternion()

static fromQuaternion(quaternion: Quaternion, result?: Matrix3): Matrix3

Computes a 3x3 rotation matrix from the provided quaternion.

参数

quaternion

Quaternion

the quaternion to use.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

The 3x3 rotation matrix from this quaternion.


fromHeadingPitchRoll()

static fromHeadingPitchRoll(headingPitchRoll: HeadingPitchRoll, result?: Matrix3): Matrix3

Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

)

参数

headingPitchRoll

HeadingPitchRoll

the headingPitchRoll to use.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

The 3x3 rotation matrix from this headingPitchRoll.


fromScale()

static fromScale(scale: Cartesian3, result?: Matrix3): Matrix3

Computes a Matrix3 instance representing a non-uniform scale.

参数

scale

Cartesian3

The x, y, and z scale factors.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Creates
//   [7.0, 0.0, 0.0]
//   [0.0, 8.0, 0.0]
//   [0.0, 0.0, 9.0]
const m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));

fromUniformScale()

static fromUniformScale(scale: number, result?: Matrix3): Matrix3

Computes a Matrix3 instance representing a uniform scale.

参数

scale

number

The uniform scale factor.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Creates
//   [2.0, 0.0, 0.0]
//   [0.0, 2.0, 0.0]
//   [0.0, 0.0, 2.0]
const m = Cesium.Matrix3.fromUniformScale(2.0);

fromCrossProduct()

static fromCrossProduct(vector: Cartesian3, result?: Matrix3): Matrix3

Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.

参数

vector

Cartesian3

the vector on the left hand side of the cross product operation.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Creates
//   [0.0, -9.0,  8.0]
//   [9.0,  0.0, -7.0]
//   [-8.0, 7.0,  0.0]
const m = Cesium.Matrix3.fromCrossProduct(new Cesium.Cartesian3(7.0, 8.0, 9.0));

fromRotationX()

static fromRotationX(angle: number, result?: Matrix3): Matrix3

Creates a rotation matrix around the x-axis.

参数

angle

number

The angle, in radians, of the rotation. Positive angles are counterclockwise.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Rotate a point 45 degrees counterclockwise around the x-axis.
const p = new Cesium.Cartesian3(5, 6, 7);
const m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));
const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());

fromRotationY()

static fromRotationY(angle: number, result?: Matrix3): Matrix3

Creates a rotation matrix around the y-axis.

参数

angle

number

The angle, in radians, of the rotation. Positive angles are counterclockwise.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Rotate a point 45 degrees counterclockwise around the y-axis.
const p = new Cesium.Cartesian3(5, 6, 7);
const m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));
const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());

fromRotationZ()

static fromRotationZ(angle: number, result?: Matrix3): Matrix3

Creates a rotation matrix around the z-axis.

参数

angle

number

The angle, in radians, of the rotation. Positive angles are counterclockwise.

result?

Matrix3

The object in which the result will be stored, if undefined a new instance will be created.

返回

Matrix3

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

示例

ts
// Rotate a point 45 degrees counterclockwise around the z-axis.
const p = new Cesium.Cartesian3(5, 6, 7);
const m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));
const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());

toArray()

static toArray(matrix: Matrix3, result?: number[]): number[]

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

参数

matrix

Matrix3

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()

static getElementIndex(column: number, row: number): number

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

参数

column

number

The zero-based index of the column.

row

number

The zero-based index of the row.

返回

number

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

示例

ts
const myMatrix = new Cesium.Matrix3();
const column1Row0Index = Cesium.Matrix3.getElementIndex(1, 0);
const column1Row0 = myMatrix[column1Row0Index]
myMatrix[column1Row0Index] = 10.0;

getColumn()

static getColumn(matrix: Matrix3, index: number, result: Cartesian3): Cartesian3

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

参数

matrix

Matrix3

The matrix to use.

index

number

The zero-based index of the column to retrieve.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


setColumn()

static setColumn(matrix: Matrix3, index: number, cartesian: Cartesian3, result: Matrix3): Matrix3

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

参数

matrix

Matrix3

The matrix to use.

index

number

The zero-based index of the column to set.

cartesian

Cartesian3

The Cartesian whose values will be assigned to the specified column.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


getRow()

static getRow(matrix: Matrix3, index: number, result: Cartesian3): Cartesian3

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

参数

matrix

Matrix3

The matrix to use.

index

number

The zero-based index of the row to retrieve.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


setRow()

static setRow(matrix: Matrix3, index: number, cartesian: Cartesian3, result: Matrix3): Matrix3

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

参数

matrix

Matrix3

The matrix to use.

index

number

The zero-based index of the row to set.

cartesian

Cartesian3

The Cartesian whose values will be assigned to the specified row.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


setScale()

static setScale(matrix: Matrix3, scale: Cartesian3, result: Matrix3): Matrix3

Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.

参数

matrix

Matrix3

The matrix to use.

scale

Cartesian3

The scale that replaces the scale of the provided matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


setUniformScale()

static setUniformScale(matrix: Matrix3, scale: number, result: Matrix3): Matrix3

Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.

参数

matrix

Matrix3

The matrix to use.

scale

number

The uniform scale that replaces the scale of the provided matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


getScale()

static getScale(matrix: Matrix3, result: Cartesian3): Cartesian3

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

参数

matrix

Matrix3

The matrix.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


getMaximumScale()

static getMaximumScale(matrix: Matrix3): number

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

参数

matrix

Matrix3

The matrix.

返回

number

The maximum scale.


setRotation()

static setRotation(matrix: Matrix3, rotation: Matrix3, result: Matrix3): Matrix3

Sets the rotation assuming the matrix is an affine transformation.

参数

matrix

Matrix3

The matrix.

rotation

Matrix3

The rotation matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


getRotation()

static getRotation(matrix: Matrix3, result: Matrix3): Matrix3

Extracts the rotation matrix assuming the matrix is an affine transformation.

参数

matrix

Matrix3

The matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


multiply()

static multiply(left: Matrix3, right: Matrix3, result: Matrix3): Matrix3

Computes the product of two matrices.

参数

left

Matrix3

The first matrix.

Matrix3

The second matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


add()

static add(left: Matrix3, right: Matrix3, result: Matrix3): Matrix3

Computes the sum of two matrices.

参数

left

Matrix3

The first matrix.

right

Matrix3

The second matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


subtract()

static subtract(left: Matrix3, right: Matrix3, result: Matrix3): Matrix3

Computes the difference of two matrices.

参数

left

Matrix3

The first matrix.

right

Matrix3

The second matrix.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


multiplyByVector()

static multiplyByVector(matrix: Matrix3, cartesian: Cartesian3, result: Cartesian3): Cartesian3

Computes the product of a matrix and a column vector.

参数

matrix

Matrix3

The matrix.

cartesian

Cartesian3

The column.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


multiplyByScalar()

static multiplyByScalar(matrix: Matrix3, scalar: number, result: Matrix3): Matrix3

Computes the product of a matrix and a scalar.

参数

matrix

Matrix3

The matrix.

scalar

number

The number to multiply by.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


multiplyByScale()

static multiplyByScale(matrix: Matrix3, scale: Cartesian3, result: Matrix3): Matrix3

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

参数

matrix

Matrix3

The matrix on the left-hand side.

scale

Cartesian3

The non-uniform scale on the right-hand side.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.

示例

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

multiplyByUniformScale()

static multiplyByUniformScale(matrix: Matrix3, scale: number, result: Matrix3): Matrix3

Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.

参数

matrix

Matrix3

The matrix on the left-hand side.

scale

number

The uniform scale on the right-hand side.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.

示例

ts
// Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromUniformScale(scale), m);
Cesium.Matrix3.multiplyByUniformScale(m, scale, m);

negate()

static negate(matrix: Matrix3, result: Matrix3): Matrix3

Creates a negated copy of the provided matrix.

参数

matrix

Matrix3

The matrix to negate.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


transpose()

static transpose(matrix: Matrix3, result: Matrix3): Matrix3

Computes the transpose of the provided matrix.

参数

matrix

Matrix3

The matrix to transpose.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


computeEigenDecomposition()

static computeEigenDecomposition(matrix: Matrix3, result?: any): any

Computes the eigenvectors and eigenvalues of a symmetric matrix. <p> Returns a diagonal matrix and unitary matrix such that: <code>matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)</code> </p> <p> The values along the diagonal of the diagonal matrix are the eigenvalues. The columns of the unitary matrix are the corresponding eigenvectors. </p>

参数

matrix

Matrix3

The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.

result?

any

An object with unitary and diagonal properties which are matrices onto which to store the result.

返回

any

An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.

示例

ts
const a = //... symetric matrix
const result = {
    unitary : new Cesium.Matrix3(),
    diagonal : new Cesium.Matrix3()
};
Cesium.Matrix3.computeEigenDecomposition(a, result);

const unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());
const b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());
Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a

const lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x;  // first eigenvalue
const v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3());          // first eigenvector
const c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3());        // equal to Cesium.Matrix3.multiplyByVector(a, v)

abs()

static abs(matrix: Matrix3, result: Matrix3): Matrix3

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

参数

matrix

Matrix3

The matrix with signed elements.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


determinant()

static determinant(matrix: Matrix3): number

Computes the determinant of the provided matrix.

参数

matrix

Matrix3

The matrix to use.

返回

number

The value of the determinant of the matrix.


inverse()

static inverse(matrix: Matrix3, result: Matrix3): Matrix3

Computes the inverse of the provided matrix.

参数

matrix

Matrix3

The matrix to invert.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


inverseTranspose()

static inverseTranspose(matrix: Matrix3, result: Matrix3): Matrix3

Computes the inverse transpose of a matrix.

参数

matrix

Matrix3

The matrix to transpose and invert.

result

Matrix3

The object onto which to store the result.

返回

Matrix3

The modified result parameter.


equals()

static equals(left?: Matrix3, right?: Matrix3): boolean

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

参数

left?

Matrix3

The first matrix.

right?

Matrix3

The second matrix.

返回

boolean

true if left and right are equal, false otherwise.


equalsEpsilon()

static equalsEpsilon(left?: Matrix3, right?: Matrix3, 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?

Matrix3

The first matrix.

right?

Matrix3

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?: Matrix3): Matrix3

Duplicates the provided Matrix3 instance.

参数

result?

Matrix3

The object onto which to store the result.

返回

Matrix3

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


equals()

equals(right?: Matrix3): boolean

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

参数

right?

Matrix3

The right hand side matrix.

返回

boolean

true if they are equal, false otherwise.


equalsEpsilon()

equalsEpsilon(right?: Matrix3, 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?

Matrix3

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, column2)'.

返回

string

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

构造函数

构造函数

new Matrix3(column0Row0?: number, column1Row0?: number, column2Row0?: number, column0Row1?: number, column1Row1?: number, column2Row1?: number, column0Row2?: number, column1Row2?: number, column2Row2?: number): Matrix3

参数

column0Row0?

number

column1Row0?

number

column2Row0?

number

column0Row1?

number

column1Row1?

number

column2Row1?

number

column0Row2?

number

column1Row2?

number

column2Row2?

number

返回

Matrix3

继承自

ArrayLike<number>.constructor

KBE3D @3.0.0 Copyright © 2024-present KBE3D