Google is committed to advancing racial equity for Black communities. See how.

# Matrix4

`data class Matrix4`
 kotlin.Any ↳ androidx.compose.ui.graphics.vectormath.Matrix4

## Summary

Public constructors
`<init>(right: Vector3, up: Vector3, forward: Vector3, position: Vector3 = Vector3())`

`<init>(m: Matrix4)`

`<init>(x: Vector4 = Vector4(x = 1.0f), y: Vector4 = Vector4(y = 1.0f), z: Vector4 = Vector4(z = 1.0f), w: Vector4 = Vector4(w = 1.0f))`

Public methods
Unit
`assignColumns(other: Matrix4)`

Unit
`assignFromStorage(storage: List<Float>)`

Float
`copyInverse(arg: Matrix4)`

Set this matrix to be the inverse of arg

operator Matrix4
`dec()`

operator Matrix4
`div(v: Float)`

operator Vector4
`get(column: Int)`

operator Float
`get(column: Int, row: Int)`

operator Vector4
`get(column: MatrixColumn)`

operator Float
`get(column: MatrixColumn, row: Int)`

Vector4
`getRow(row: Int)`

operator Matrix4
`inc()`

Float
`invert()`

Invert this.

operator Matrix4
`minus(v: Float)`

Vector3
`perspectiveTransform(arg: Vector3)`

Transform arg of type Vector3 using the perspective transformation defined by this.

operator Matrix4
`plus(v: Float)`

Unit
`rotateX(radians: Float)`

Unit
`rotateY(radians: Float)`

Sets the upper 3x3 to a rotation of radians around Y

Unit
`rotateZ(radians: Float)`

Sets the upper 3x3 to a rotation of radians around Z

Unit
`scale(x: Any, y: Float? = null, z: Float? = null)`

Scale this matrix by a Vector3, Vector4, or x,y,z

operator Unit
`set(column: Int, v: Vector4)`

operator Unit
`set(column: Int, row: Int, v: Float)`

Unit
`setFrom(arg: Matrix4)`

Sets the entire matrix to the matrix in arg.

Unit
`setTranslationRaw(x: Float, y: Float, z: Float)`

Sets the translation vector in this homogeneous transformation matrix.

operator Matrix4
`times(v: Float)`

operator Matrix4
`times(m: Matrix4)`

operator Vector4
`times(v: Vector4)`

operator Unit
`timesAssign(m: Matrix4)`

FloatArray
`toFloatArray()`

String
`toString()`

Unit
`translate(x: Any, y: Float = 0.0f, z: Float = 0.0f)`

Translate this matrix by a Vector3, Vector4, or x,y,z

operator Matrix4
`unaryMinus()`

Companion functions
Matrix4
`diagonal3(scale: Vector3)`

Matrix4
`diagonal3Values(x: Float, y: Float, z: Float)`

Matrix4
`identity()`

Matrix4
`of(vararg a: Float)`

Matrix4
`rotationX(radians: Float)`

Matrix4
`rotationY(radians: Float)`

Matrix4
`rotationZ(radians: Float)`

Matrix4
`translation(translation: Vector3)`

Matrix4
`translationValues(x: Float, y: Float, z: Float)`

Matrix4
`zero()`

Extension functions
From androidx.compose.ui.graphics.vectormath
 Float? `Matrix4.getAsScale()` Returns the given transform matrix as a Float describing a uniform scale, if the matrix is nothing but a symmetric 2D scale transform. Offset? `Matrix4.getAsTranslation()` Returns the given transform matrix as an Offset, if the matrix is nothing but a 2D translation. Boolean `Matrix4.isIdentity()` Whether the given matrix is the identity matrix. Offset `Matrix4.transformPoint(point: Offset)` Applies the given matrix as a perspective transform to the given point. Rect `Matrix4.transformRect(rect: Rect)` Returns a rect that bounds the result of applying the given matrix as a perspective transform to the given rect.
Properties
Float
`determinant`

Returns the determinant of this matrix.

Vector3
`forward`

List<Float>
`m4storage`

Vector3
`position`

Vector3
`right`

Vector3
`rotation`

Vector3
`scale`

Vector3
`translation`

Vector3
`up`

Matrix3
`upperLeft`

Vector4
`w`

Vector4
`x`

Vector4
`y`

Vector4
`z`

## Public constructors

### <init>

`Matrix4(    right: Vector3,     up: Vector3,     forward: Vector3,     position: Vector3 = Vector3())`

### <init>

`Matrix4(m: Matrix4)`

### <init>

`Matrix4(    x: Vector4 = Vector4(x = 1.0f),     y: Vector4 = Vector4(y = 1.0f),     z: Vector4 = Vector4(z = 1.0f),     w: Vector4 = Vector4(w = 1.0f))`

## Public methods

### assignColumns

`fun assignColumns(other: Matrix4): Unit`

### assignFromStorage

`fun assignFromStorage(storage: List<Float>): Unit`

### copyInverse

`fun copyInverse(arg: Matrix4): Float`

Set this matrix to be the inverse of arg

### dec

`operator fun dec(): Matrix4`

### div

`operator fun div(v: Float): Matrix4`

### get

`operator fun get(column: Int): Vector4`

### get

`operator fun get(    column: Int,     row: Int): Float`

### get

`operator fun get(column: MatrixColumn): Vector4`

### get

`operator fun get(    column: MatrixColumn,     row: Int): Float`

### getRow

`fun getRow(row: Int): Vector4`

### inc

`operator fun inc(): Matrix4`

### invert

`fun invert(): Float`

Invert this.

### minus

`operator fun minus(v: Float): Matrix4`

### perspectiveTransform

`fun perspectiveTransform(arg: Vector3): Vector3`

Transform arg of type Vector3 using the perspective transformation defined by this.

### plus

`operator fun plus(v: Float): Matrix4`

### rotateX

`fun rotateX(radians: Float): Unit`

### rotateY

`fun rotateY(radians: Float): Unit`

Sets the upper 3x3 to a rotation of radians around Y

### rotateZ

`fun rotateZ(radians: Float): Unit`

Sets the upper 3x3 to a rotation of radians around Z

### scale

`fun scale(    x: Any,     y: Float? = null,     z: Float? = null): Unit`

Scale this matrix by a Vector3, Vector4, or x,y,z

### set

`operator fun set(    column: Int,     v: Vector4): Unit`

### set

`operator fun set(    column: Int,     row: Int,     v: Float): Unit`

### setFrom

`fun setFrom(arg: Matrix4): Unit`

Sets the entire matrix to the matrix in arg.

### setTranslationRaw

`fun setTranslationRaw(    x: Float,     y: Float,     z: Float): Unit`

Sets the translation vector in this homogeneous transformation matrix.

### times

`operator fun times(v: Float): Matrix4`

### times

`operator fun times(m: Matrix4): Matrix4`

### times

`operator fun times(v: Vector4): Vector4`

### timesAssign

`operator fun timesAssign(m: Matrix4): Unit`

### toFloatArray

`fun toFloatArray(): FloatArray`

### toString

`fun toString(): String`

### translate

`fun translate(    x: Any,     y: Float = 0.0f,     z: Float = 0.0f): Unit`

Translate this matrix by a Vector3, Vector4, or x,y,z

### unaryMinus

`operator fun unaryMinus(): Matrix4`

## Properties

### determinant

`val determinant: Float`

Returns the determinant of this matrix.

### forward

`inline var forward: Vector3`

### m4storage

`inline val m4storage: List<Float>`

### position

`inline var position: Vector3`
`inline var right: Vector3`

### rotation

`val rotation: Vector3`

### scale

`inline val scale: Vector3`

### translation

`inline val translation: Vector3`

### up

`inline var up: Vector3`

### upperLeft

`inline val upperLeft: Matrix3`

### w

`var w: Vector4`

### x

`var x: Vector4`

### y

`var y: Vector4`

### z

`var z: Vector4`

## Companion functions

### diagonal3

`fun diagonal3(scale: Vector3): Matrix4`

### diagonal3Values

`fun diagonal3Values(    x: Float,     y: Float,     z: Float): Matrix4`

### identity

`fun identity(): Matrix4`

### of

`fun of(vararg a: Float): Matrix4`

### rotationX

`fun rotationX(radians: Float): Matrix4`

### rotationY

`fun rotationY(radians: Float): Matrix4`

### rotationZ

`fun rotationZ(radians: Float): Matrix4`

### translation

`fun translation(translation: Vector3): Matrix4`

### translationValues

`fun translationValues(    x: Float,     y: Float,     z: Float): Matrix4`

### zero

`fun zero(): Matrix4`