Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/graphics/Matrix44#pubctors) \| [Methods](https://developer.android.com/reference/android/graphics/Matrix44#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/Matrix44#inhmethods)

# Matrix44

*** ** * ** ***

` public class Matrix44 `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.Matrix44 |

<br />

*** ** * ** ***

The Matrix44 class holds a 4x4 matrix for transforming coordinates. It is similar to `https://developer.android.com/reference/android/graphics/Matrix`, and should be used when you want to manipulate the canvas in 3D. Values are kept in row-major order. The values and operations are treated as column vectors.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/Matrix44#Matrix44()() ` The default Matrix44 constructor will instantiate an identity matrix. |
| ` https://developer.android.com/reference/android/graphics/Matrix44#Matrix44(android.graphics.Matrix)(https://developer.android.com/reference/android/graphics/Matrix mat) ` Creates and returns a Matrix44 by taking the 3x3 Matrix and placing it on the 0 of the z-axis by setting row `2` and column `2` to the identity as seen in the following operation: ``` [ a b c ]      [ a b 0 c ] [ d e f ]  ->  [ d e 0 f ] [ g h i ]      [ 0 0 1 0 ] [ g h 0 i ] ``` <br /> |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/Matrix44` | ` https://developer.android.com/reference/android/graphics/Matrix44#concat(android.graphics.Matrix44)(https://developer.android.com/reference/android/graphics/Matrix44 b) ` Multiplies \`this\` matrix (A) and provided Matrix (B) in the order of A \* B. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Matrix44#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. |
| ` float` | ` https://developer.android.com/reference/android/graphics/Matrix44#get(int,%20int)(int row, int col) ` Gets the value at the matrix's row and column. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Matrix44#getValues(float[])(float[] dst) ` Copies matrix values into the provided array in row-major order. |
| ` int` | ` https://developer.android.com/reference/android/graphics/Matrix44#hashCode()() ` Returns a hash code value for the object. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Matrix44#invert()() ` Inverts the Matrix44, then return true if successful, false if unable to invert. |
| ` boolean` | ` https://developer.android.com/reference/android/graphics/Matrix44#isIdentity()() ` Returns true if Matrix44 is equal to identity matrix. |
| ` float[]` | ` https://developer.android.com/reference/android/graphics/Matrix44#map(float,%20float,%20float,%20float)(float x, float y, float z, float w) ` Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). |
| ` void` | ` https://developer.android.com/reference/android/graphics/Matrix44#map(float,%20float,%20float,%20float,%20float[])(float x, float y, float z, float w, float[] dst) ` Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). |
| ` void` | ` https://developer.android.com/reference/android/graphics/Matrix44#reset()() ` Sets the Matrix44 to the identity matrix. |
| ` https://developer.android.com/reference/android/graphics/Matrix44` | ` https://developer.android.com/reference/android/graphics/Matrix44#rotate(float,%20float,%20float,%20float)(float deg, float xComp, float yComp, float zComp) ` Applies a rotation around a given axis, then returns self. |
| ` https://developer.android.com/reference/android/graphics/Matrix44` | ` https://developer.android.com/reference/android/graphics/Matrix44#scale(float,%20float,%20float)(float x, float y, float z) ` Applies scaling factors to \`this\` Matrix44, then returns self. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Matrix44#set(int,%20int,%20float)(int row, int col, float val) ` Sets the value at the matrix's row and column to the provided value. |
| ` void` | ` https://developer.android.com/reference/android/graphics/Matrix44#setValues(float[])(float[] src) ` Replaces the Matrix's values with the values in the provided array. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/graphics/Matrix44#toString()() ` Returns a string representation of the object. |
| ` https://developer.android.com/reference/android/graphics/Matrix44` | ` https://developer.android.com/reference/android/graphics/Matrix44#translate(float,%20float,%20float)(float x, float y, float z) ` Applies a translation to \`this\` Matrix44, then returns self. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Matrix44

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 ()
```

The default Matrix44 constructor will instantiate an identity matrix.

<br />

### Matrix44

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 (Matrix mat)
```

Creates and returns a Matrix44 by taking the 3x3 Matrix and placing it on the 0 of the z-axis by setting row `2` and column `2` to the identity as seen in the following operation:

```
[ a b c ]      [ a b 0 c ]
[ d e f ]  ->  [ d e 0 f ]
[ g h i ]      [ 0 0 1 0 ]
               [ g h 0 i ]
```

<br />

<br />

| Parameters ||
|---|---|
| `mat` | `Matrix`: A 3x3 Matrix to be converted (original Matrix will not be changed). This value cannot be `null`. <br /> |

## Public methods

### concat

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 concat (Matrix44 b)
```

Multiplies \`this\` matrix (A) and provided Matrix (B) in the order of A \* B. The result is saved in \`this\` Matrix.

<br />

| Parameters ||
|---|---|
| `b` | `Matrix44`: The second Matrix in the concatenation operation. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Matrix44` | A reference to this Matrix, which can be used to chain Matrix operations. This value cannot be `null`. <br /> |

### equals

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object obj)
```

Indicates whether some other object is "equal to" this one.

The `equals` method implements an equivalence relation on non-null object references:

- It is *reflexive*: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric*: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive*: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent*: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.

An equivalence relation partitions the elements it operates on into *equivalence classes*; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### get

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float get (int row, 
                int col)
```

Gets the value at the matrix's row and column.

<br />

| Parameters ||
|---|---|
| `row` | `int`: An integer from 0 to 3 indicating the row of the value to get. Value is between 0 and 3 inclusive <br /> |
| `col` | `int`: An integer from 0 to 3 indicating the column of the value to get. Value is between 0 and 3 inclusive <br /> |

| Returns ||
|---|---|
| `float` | <br /> |

### getValues

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void getValues (float[] dst)
```

Copies matrix values into the provided array in row-major order.

<br />

| Parameters ||
|---|---|
| `dst` | `float`: The float array where values will be copied, must be of length 16. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the destination float array is not of length 16 |

### hashCode

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by `https://developer.android.com/reference/java/util/HashMap`.

The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is *not* required that if two objects are unequal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### invert

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean invert ()
```

Inverts the Matrix44, then return true if successful, false if unable to invert.

<br />

| Returns ||
|---|---|
| `boolean` | `true` on success, `false` otherwise <br /> |

### isIdentity

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isIdentity ()
```

Returns true if Matrix44 is equal to identity matrix.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### map

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float[] map (float x, 
                float y, 
                float z, 
                float w)
```

Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). Users should set `w` to 1 to indicate the coordinates are normalized.

<br />

| Parameters ||
|---|---|
| `x` | `float` <br /> |
| `y` | `float` <br /> |
| `z` | `float` <br /> |
| `w` | `float` <br /> |

| Returns ||
|---|---|
| `float[]` | An array of length 4 that represents the x, y, z, w (where w is perspective) value after multiplying x, y, z, 1 by the matrix. This value cannot be `null`. <br /> |

### map

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void map (float x, 
                float y, 
                float z, 
                float w, 
                float[] dst)
```

Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). Users should set `w` to 1 to indicate the coordinates are normalized.

<br />

| Parameters ||
|---|---|
| `x` | `float` <br /> |
| `y` | `float` <br /> |
| `z` | `float` <br /> |
| `w` | `float` <br /> |
| `dst` | `float`: This value cannot be `null`. <br /> |

### reset

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void reset ()
```

Sets the Matrix44 to the identity matrix.

<br />

### rotate

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 rotate (float deg, 
                float xComp, 
                float yComp, 
                float zComp)
```

Applies a rotation around a given axis, then returns self. `x`, `y`, `z` represent the axis by which to rotate around. For example, pass in `1, 0, 0` to rotate around the x-axis. The axis provided will be normalized.

<br />

| Parameters ||
|---|---|
| `deg` | `float`: Amount in degrees to rotate the matrix about the x-axis <br /> |
| `xComp` | `float`: X component of the rotation axis <br /> |
| `yComp` | `float`: Y component of the rotation axis <br /> |
| `zComp` | `float`: Z component of the rotation axis <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Matrix44` | A reference to this Matrix, which can be used to chain Matrix operations. This value cannot be `null`. <br /> |

### scale

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 scale (float x, 
                float y, 
                float z)
```

Applies scaling factors to \`this\` Matrix44, then returns self. Pass 1s for no change.

<br />

| Parameters ||
|---|---|
| `x` | `float`: Scaling factor for the x-axis <br /> |
| `y` | `float`: Scaling factor for the y-axis <br /> |
| `z` | `float`: Scaling factor for the z-axis <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Matrix44` | A reference to this Matrix, which can be used to chain Matrix operations. This value cannot be `null`. <br /> |

### set

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void set (int row, 
                int col, 
                float val)
```

Sets the value at the matrix's row and column to the provided value.

<br />

| Parameters ||
|---|---|
| `row` | `int`: An integer from 0 to 3 indicating the row of the value to change. Value is between 0 and 3 inclusive <br /> |
| `col` | `int`: An integer from 0 to 3 indicating the column of the value to change. Value is between 0 and 3 inclusive <br /> |
| `val` | `float`: The value the element at the specified index will be set to <br /> |

### setValues

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setValues (float[] src)
```

Replaces the Matrix's values with the values in the provided array.

<br />

| Parameters ||
|---|---|
| `src` | `float`: A float array of length 16. Floats are treated in row-major order. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the destination float array is not of length 16 |

### toString

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### translate

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Matrix44 translate (float x, 
                float y, 
                float z)
```

Applies a translation to \`this\` Matrix44, then returns self.

<br />

| Parameters ||
|---|---|
| `x` | `float`: Translation for the x-axis <br /> |
| `y` | `float`: Translation for the y-axis <br /> |
| `z` | `float`: Translation for the z-axis <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Matrix44` | A reference to this Matrix, which can be used to chain Matrix operations. This value cannot be `null`. <br /> |