API Reference > geometry-core > Numerics > Matrix4d Matrix4d Class A Matrix4d is a matrix with 4 rows and 4 columns. The 4 rows may be described as the x,y,z,w rows. The 4 columns may be described as the x,y,z,w columns. The matrix is physically stored as a Float64Array with 16 numbers. The layout in the Float64Array is "by row" indices 0,1,2,3 are the "x row". They may be called the xx,xy,xz,xw entries indices 4,5,6,7 are the "y row" They may be called the yx,yy,yz,yw entries indices 8,9,10,11 are the "z row" They may be called the zx,zy,zz,zw entries indices 12,13,14,15 are the "w row". They may be called the wx,wy,wz,ww entries If "w row" contains numeric values 0,0,0,1, the Matrix4d is equivalent to a Transform with The upper right 3x3 matrix (entries 0,1,2,4,5,6,8,9,10) are the 3x3 matrix part of the transform The far right column entries xw,yw,zw are the "origin" (sometimes called "translation") part of the transform. Implements BeJSONFunctions Methods Name Description addMomentsInPlace(x: number, y: number, z: number, w: number): void Add the product terms [xx,xy,xz,xw, yx, yy, yz, yw, zx, zy, zz, zs, wx, wy, wz, ww] to respective entries in the matrix addScaledInPlace(other: Matrix4d, scale: number = 1.0): void accumulate all coefficients of other to this. addScaledOuterProductInPlace(vectorU: Point4d, vectorV: Point4d, scale: number): void add an outer product (single column times single row times scale factor) to this matrix. addTranslationSandwichInPlace(matrixB: Matrix4d, ax: number, ay: number, az: number, scale: number): void ADD (n place) scaleAB*AT where atIJ(rowIndex: number, columnIndex: number): number Return a matrix entry by row and column index. clone(result?: Matrix4d): Matrix4d Return a deep clone. cloneTransposed(result?: Matrix4d): Matrix4d Return a transposed matrix. columnDotColumn(columnIndexThis: number, other: Matrix4d, columnIndexOther: number): number Returns dot product of row rowIndexThis of this with row rowIndexOther of other. columnDotRow(columnIndexThis: number, other: Matrix4d, rowIndexOther: number): number Returns dot product of column columnIndexThis of this with row rowIndexOther other. columnW(): Point4d Return column 3 as Point4d. columnX(): Point4d Return column 0 as Point4d. columnY(): Point4d Return column 1 as Point4d. columnZ(): Point4d Return column 2 as Point4d. createInverse(result?: Matrix4d): undefined | Matrix4d Compute an inverse matrix. determinant(): number Return the determinant of the matrix. diagonal(): Point4d Return a Point4d with the diagonal entries of the matrix getSteppedPoint(i0: number, step: number, result?: Point4d): Point4d Return a point with entries from positions [i0, i0+step, i0+2step, i0+3step]. isAlmostEqual(other: Matrix4d): boolean Test for near-equality with other isExactEqual(other: Matrix4d): boolean Test for exact (bitwise) equality with other. isIdentity(tol: number = 1.0e-10): boolean set to identity. matrixPart(): Matrix3d return the leading 3x3 matrix part of this matrix maxAbs(): number Return the largest absolute value in the Matrix4d maxDiff(other: Matrix4d): number Return the largest (absolute) difference between this and other Matrix4d. multiplyBlockedFloat64ArrayInPlace(data: Float64Array): void multiply matrix times column vectors [x,y,z,w] where [x,y,z,w] appear in blocks in an array. multiplyMatrixMatrix(other: Matrix4d, result?: Matrix4d): Matrix4d multiply this * other. multiplyMatrixMatrixTranspose(other: Matrix4d, result?: Matrix4d): Matrix4d multiply this * transpose(other). multiplyMatrixTransposeMatrix(other: Matrix4d, result?: Matrix4d): Matrix4d multiply transpose (this) * other. multiplyPoint3d(pt: Readonly<WritableXYAndZ>, w: number, result?: Point4d): Point4d multiply matrix times XYAndZ and w. multiplyPoint3dArray(pts: Readonly<WritableXYAndZ>[], results: Point4d[], w: number = 1.0): void multiply matrix times and array of XYAndZ. multiplyPoint3dArrayQuietNormalize(points: Point3d[]): void multiply each matrix * points[i]. multiplyPoint3dQuietNormalize(point: Readonly<WritableXYAndZ>, result?: Point3d): Point3d multiply matrix * point. multiplyPoint4d(point: Point4d, result?: Point4d): Point4d multiply a Point4d, return with the optional result convention. multiplyPoint4dArrayQuietRenormalize(pts: Point4d[], results: Point3d[]): void multiply matrix * an array of Point4d. multiplyTranslationSandwichInPlace(ax: number, ay: number, az: number): void Multiply and replace contents of this matrix by AthisAT where multiplyTransposePoint4d(point: Point4d, result?: Point4d): Point4d multiply a Point4d, return with the optional result convention. multiplyTransposeXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d multiply [x,y,z,w] times matrix. multiplyXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d multiply matrix times column [x,y,z,w]. multiplyXYZWQuietRenormalize(x: number, y: number, z: number, w: number, result?: Point3d): Point3d multiply matrix * [x,y,z,w]. plusScaled(matrixB: Matrix4d, scale: number, result?: Matrix4d): Matrix4d return this matrix plus scale times matrixB. rowArrays(f?: (value: number) => any): any Returns an array-of-arrays of the matrix rows, optionally passing each value through a function. rowDotColumn(rowIndex: number, other: Matrix4d, columnIndex: number): number Returns dot product of row rowIndex of this with column columnIndex of other. rowDotRow(rowIndexThis: number, other: Matrix4d, rowIndexOther: number): number Returns dot product of row rowIndexThis of this with row rowIndexOther of other. rowDotXYZW(rowIndex: number, x: number, y: number, z: number, w: number): number Returns dot product of row rowIndex of this with [x y z w] rowOperation(rowIndexA: number, rowIndexB: number, firstColumnIndex: number, scale: number): void Add scale times rowA to rowB. rowW(): Point4d Return row 3 as Point4d. rowX(): Point4d Return row 0 as Point4d. rowY(): Point4d Return row 1 as Point4d. rowZ(): Point4d Return row 2 as Point4d. scaleRowsInPlace(ax: number, ay: number, az: number, aw: number): void Scale each row by respective scale factors. setAtIJ(rowIndex: number, columnIndex: number, value: number): void Set a matrix entry by row and column index. setFrom(other: Matrix4d): void Copy matrix entries from other setFromJSON(json?: Matrix4dProps): void Set from nested array json e.g. setIdentity(): void set to identity. setOriginAndVectors(origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d): void directly set columns from typical 3d data: setZero(): void zero this matrix4d in place. toJSON(): Matrix4dProps Convert an Matrix4d to a Matrix4dProps. weight(): number return the weight component of this matrix createBoxToBox(lowA: Point3d, highA: Point3d, lowB: Point3d, highB: Point3d, result?: Matrix4d): undefined | Matrix4d Static Create a mapping the scales and translates (no rotation) from box A to boxB createIdentity(result?: Matrix4d): Matrix4d Static return an identity matrix. createRowValues(cxx: number, cxy: number, cxz: number, cxw: number, cyx: number, cyy: number, cyz: number, cyw: number, czx: number, czy: number, czz: number, czw: number, cwx: number, cwy: number, cwz: number, cww: number, result?: Matrix4d): Matrix4d Static create a Matrix4d with values supplied "across the rows" createRows(rowX: Point4d, rowY: Point4d, rowZ: Point4d, rowW: Point4d, result?: Matrix4d): Matrix4d Static Create a Matrix4d from 16 values appearing as Point4d for each row. createTransform(source: Transform, result?: Matrix4d): Matrix4d Static promote a transform to full Matrix4d (with 0001 in final row) createTranslationAndScaleXYZ(tx: number, ty: number, tz: number, scaleX: number, scaleY: number, scaleZ: number, result?: Matrix4d): Matrix4d Static Create a Matrix4d with translation and scaling values directly inserted (along with 1 as final diagonal entry) createTranslationXYZ(x: number, y: number, z: number, result?: Matrix4d): Matrix4d Static return matrix with translation directly inserted (along with 1 on diagonal) createZero(result?: Matrix4d): Matrix4d Static create a Matrix4d filled with zeros. fromJSON(json?: Matrix4dProps): Matrix4d Static Create from nested array json e.g. Properties Name Type Description asTransform Accessor ReadOnly undefined | Transform Return the (affine, non-perspective) Transform with the upper 3 rows of this matrix hasPerspective Accessor ReadOnly boolean Returns true if the w row has content other than [0,0,0,1] Defined in geometry4d/Matrix4d.ts Line 37 Last Updated: 12 June, 2024