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

# Matrix4f

*** ** * ** ***

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

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

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   

Renderscript has been deprecated in API level 31. Please refer to the [migration guide](https://developer.android.com/guide/topics/renderscript/migration-guide) for the proposed alternatives.

Class for exposing the native RenderScript rs_matrix4x4 type back to the Android system.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/renderscript/Matrix4f#Matrix4f()() ` Creates a new identity 4x4 matrix |
| ` https://developer.android.com/reference/android/renderscript/Matrix4f#Matrix4f(float[])(float[] dataArray) ` Creates a new matrix and sets its values from the given parameter |

| ### Public methods ||
|---|---|
| ` float` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#get(int,%20int)(int x, int y) ` Returns the value for a given row and column |
| ` float[]` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#getArray()() ` Return a reference to the internal array representing matrix values. |
| ` boolean` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#inverse()() ` Sets the current matrix to its inverse |
| ` boolean` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#inverseTranspose()() ` Sets the current matrix to its inverse transpose |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#load(android.renderscript.Matrix4f)(https://developer.android.com/reference/android/renderscript/Matrix4f src) ` Sets the values of the matrix to those of the parameter |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadFrustum(float,%20float,%20float,%20float,%20float,%20float)(float l, float r, float b, float t, float n, float f) ` Sets current values to be a perspective projection matrix |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadIdentity()() ` Sets the matrix values to identity |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadMultiply(android.renderscript.Matrix4f,%20android.renderscript.Matrix4f)(https://developer.android.com/reference/android/renderscript/Matrix4f lhs, https://developer.android.com/reference/android/renderscript/Matrix4f rhs) ` Sets current values to be the result of multiplying two given matrices |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadOrtho(float,%20float,%20float,%20float,%20float,%20float)(float l, float r, float b, float t, float n, float f) ` Set current values to be an orthographic projection matrix |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadOrthoWindow(int,%20int)(int w, int h) ` Set current values to be an orthographic projection matrix with the right and bottom clipping planes set to the given values. |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadPerspective(float,%20float,%20float,%20float)(float fovy, float aspect, float near, float far) ` Sets current values to be a perspective projection matrix |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadProjectionNormalized(int,%20int)(int w, int h) ` Helper function to set the current values to a perspective projection matrix with aspect ratio defined by the parameters and (near, far), (bottom, top) mapping to (-1, 1) at z = 0 |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadRotate(float,%20float,%20float,%20float)(float rot, float x, float y, float z) ` Sets current values to be a rotation matrix of certain angle about a given axis |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadScale(float,%20float,%20float)(float x, float y, float z) ` Sets current values to be a scale matrix of given dimensions |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#loadTranslate(float,%20float,%20float)(float x, float y, float z) ` Sets current values to be a translation matrix of given dimensions |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#multiply(android.renderscript.Matrix4f)(https://developer.android.com/reference/android/renderscript/Matrix4f rhs) ` Post-multiplies the current matrix by a given parameter |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#rotate(float,%20float,%20float,%20float)(float rot, float x, float y, float z) ` Modifies the current matrix by post-multiplying it with a rotation matrix of certain angle about a given axis |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#scale(float,%20float,%20float)(float x, float y, float z) ` Modifies the current matrix by post-multiplying it with a scale matrix of given dimensions |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#set(int,%20int,%20float)(int x, int y, float v) ` Sets the value for a given row and column |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#translate(float,%20float,%20float)(float x, float y, float z) ` Modifies the current matrix by post-multiplying it with a translation matrix of given dimensions |
| ` void` | ` https://developer.android.com/reference/android/renderscript/Matrix4f#transpose()() ` Sets the current matrix to its transpose |

### 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

### Matrix4f

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

```
public Matrix4f ()
```

Creates a new identity 4x4 matrix

<br />

### Matrix4f

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

```
public Matrix4f (float[] dataArray)
```

Creates a new matrix and sets its values from the given parameter

<br />

| Parameters ||
|---|---|
| `dataArray` | `float`: values to set the matrix to, must be 16 floats long <br /> |

## Public methods

### get

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

```
public float get (int x, 
                int y)
```

Returns the value for a given row and column

<br />

| Parameters ||
|---|---|
| `x` | `int`: column of the value to return <br /> |
| `y` | `int`: row of the value to return <br /> |

| Returns ||
|---|---|
| `float` | value in the yth row and xth column <br /> |

### getArray

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

```
public float[] getArray ()
```

Return a reference to the internal array representing matrix values. Modifying this array will also change the matrix

<br />

| Returns ||
|---|---|
| `float[]` | internal array representing the matrix <br /> |

### inverse

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

```
public boolean inverse ()
```

Sets the current matrix to its inverse

<br />

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

### inverseTranspose

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

```
public boolean inverseTranspose ()
```

Sets the current matrix to its inverse transpose

<br />

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

### load

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

```
public void load (Matrix4f src)
```

Sets the values of the matrix to those of the parameter

<br />

| Parameters ||
|---|---|
| `src` | `Matrix4f`: matrix to load the values from <br /> |

### loadFrustum

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

```
public void loadFrustum (float l, 
                float r, 
                float b, 
                float t, 
                float n, 
                float f)
```

Sets current values to be a perspective projection matrix

<br />

| Parameters ||
|---|---|
| `l` | `float`: location of the left vertical clipping plane <br /> |
| `r` | `float`: location of the right vertical clipping plane <br /> |
| `b` | `float`: location of the bottom horizontal clipping plane <br /> |
| `t` | `float`: location of the top horizontal clipping plane <br /> |
| `n` | `float`: location of the near clipping plane, must be positive <br /> |
| `f` | `float`: location of the far clipping plane, must be positive <br /> |

### loadIdentity

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

```
public void loadIdentity ()
```

Sets the matrix values to identity

<br />

### loadMultiply

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

```
public void loadMultiply (Matrix4f lhs, 
                Matrix4f rhs)
```

Sets current values to be the result of multiplying two given matrices

<br />

| Parameters ||
|---|---|
| `lhs` | `Matrix4f`: left hand side matrix <br /> |
| `rhs` | `Matrix4f`: right hand side matrix <br /> |

### loadOrtho

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

```
public void loadOrtho (float l, 
                float r, 
                float b, 
                float t, 
                float n, 
                float f)
```

Set current values to be an orthographic projection matrix

<br />

| Parameters ||
|---|---|
| `l` | `float`: location of the left vertical clipping plane <br /> |
| `r` | `float`: location of the right vertical clipping plane <br /> |
| `b` | `float`: location of the bottom horizontal clipping plane <br /> |
| `t` | `float`: location of the top horizontal clipping plane <br /> |
| `n` | `float`: location of the near clipping plane <br /> |
| `f` | `float`: location of the far clipping plane <br /> |

### loadOrthoWindow

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

```
public void loadOrthoWindow (int w, 
                int h)
```

Set current values to be an orthographic projection matrix with the right and bottom clipping planes set to the given values. Left and top clipping planes are set to 0. Near and far are set to -1, 1 respectively

<br />

| Parameters ||
|---|---|
| `w` | `int`: location of the right vertical clipping plane <br /> |
| `h` | `int`: location of the bottom horizontal clipping plane <br /> |

### loadPerspective

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

```
public void loadPerspective (float fovy, 
                float aspect, 
                float near, 
                float far)
```

Sets current values to be a perspective projection matrix

<br />

| Parameters ||
|---|---|
| `fovy` | `float`: vertical field of view angle in degrees <br /> |
| `aspect` | `float`: aspect ratio of the screen <br /> |
| `near` | `float`: near cliping plane, must be positive <br /> |
| `far` | `float`: far clipping plane, must be positive <br /> |

### loadProjectionNormalized

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

```
public void loadProjectionNormalized (int w, 
                int h)
```

Helper function to set the current values to a perspective projection matrix with aspect ratio defined by the parameters and (near, far), (bottom, top) mapping to (-1, 1) at z = 0

<br />

| Parameters ||
|---|---|
| `w` | `int`: screen width <br /> |
| `h` | `int`: screen height <br /> |

### loadRotate

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

```
public void loadRotate (float rot, 
                float x, 
                float y, 
                float z)
```

Sets current values to be a rotation matrix of certain angle about a given axis

<br />

| Parameters ||
|---|---|
| `rot` | `float`: angle of rotation <br /> |
| `x` | `float`: rotation axis x <br /> |
| `y` | `float`: rotation axis y <br /> |
| `z` | `float`: rotation axis z <br /> |

### loadScale

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

```
public void loadScale (float x, 
                float y, 
                float z)
```

Sets current values to be a scale matrix of given dimensions

<br />

| Parameters ||
|---|---|
| `x` | `float`: scale component x <br /> |
| `y` | `float`: scale component y <br /> |
| `z` | `float`: scale component z <br /> |

### loadTranslate

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

```
public void loadTranslate (float x, 
                float y, 
                float z)
```

Sets current values to be a translation matrix of given dimensions

<br />

| Parameters ||
|---|---|
| `x` | `float`: translation component x <br /> |
| `y` | `float`: translation component y <br /> |
| `z` | `float`: translation component z <br /> |

### multiply

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

```
public void multiply (Matrix4f rhs)
```

Post-multiplies the current matrix by a given parameter

<br />

| Parameters ||
|---|---|
| `rhs` | `Matrix4f`: right hand side to multiply by <br /> |

### rotate

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

```
public void rotate (float rot, 
                float x, 
                float y, 
                float z)
```

Modifies the current matrix by post-multiplying it with a rotation matrix of certain angle about a given axis

<br />

| Parameters ||
|---|---|
| `rot` | `float`: angle of rotation <br /> |
| `x` | `float`: rotation axis x <br /> |
| `y` | `float`: rotation axis y <br /> |
| `z` | `float`: rotation axis z <br /> |

### scale

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

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

Modifies the current matrix by post-multiplying it with a scale matrix of given dimensions

<br />

| Parameters ||
|---|---|
| `x` | `float`: scale component x <br /> |
| `y` | `float`: scale component y <br /> |
| `z` | `float`: scale component z <br /> |

### set

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

```
public void set (int x, 
                int y, 
                float v)
```

Sets the value for a given row and column

<br />

| Parameters ||
|---|---|
| `x` | `int`: column of the value to set <br /> |
| `y` | `int`: row of the value to set <br /> |
| `v` | `float` <br /> |

### translate

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

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

Modifies the current matrix by post-multiplying it with a translation matrix of given dimensions

<br />

| Parameters ||
|---|---|
| `x` | `float`: translation component x <br /> |
| `y` | `float`: translation component y <br /> |
| `z` | `float`: translation component z <br /> |

### transpose

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

```
public void transpose ()
```

Sets the current matrix to its transpose

<br />