Matrix4f
public
class
Matrix4f
extends Object
java.lang.Object | |
↳ | android.renderscript.Matrix4f |
This class was deprecated
in API level 31.
Renderscript has been deprecated in API level 31. Please refer to the migration
guide for the proposed alternatives.
Class for exposing the native RenderScript rs_matrix4x4 type back to the Android system.
Summary
Public constructors | |
---|---|
Matrix4f()
Creates a new identity 4x4 matrix |
|
Matrix4f(float[] dataArray)
Creates a new matrix and sets its values from the given parameter |
Public methods | |
---|---|
float
|
get(int x, int y)
Returns the value for a given row and column |
float[]
|
getArray()
Return a reference to the internal array representing matrix values. |
boolean
|
inverse()
Sets the current matrix to its inverse |
boolean
|
inverseTranspose()
Sets the current matrix to its inverse transpose |
void
|
load(Matrix4f src)
Sets the values of the matrix to those of the parameter |
void
|
loadFrustum(float l, float r, float b, float t, float n, float f)
Sets current values to be a perspective projection matrix |
void
|
loadIdentity()
Sets the matrix values to identity |
void
|
loadMultiply(Matrix4f lhs, Matrix4f rhs)
Sets current values to be the result of multiplying two given matrices |
void
|
loadOrtho(float l, float r, float b, float t, float n, float f)
Set current values to be an orthographic projection matrix |
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. |
void
|
loadPerspective(float fovy, float aspect, float near, float far)
Sets current values to be a perspective projection matrix |
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 |
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 |
void
|
loadScale(float x, float y, float z)
Sets current values to be a scale matrix of given dimensions |
void
|
loadTranslate(float x, float y, float z)
Sets current values to be a translation matrix of given dimensions |
void
|
multiply(Matrix4f rhs)
Post-multiplies the current matrix by a given parameter |
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 |
void
|
scale(float x, float y, float z)
Modifies the current matrix by post-multiplying it with a scale matrix of given dimensions |
void
|
set(int x, int y, float v)
Sets the value for a given row and column |
void
|
translate(float x, float y, float z)
Modifies the current matrix by post-multiplying it with a translation matrix of given dimensions |
void
|
transpose()
Sets the current matrix to its transpose |
Inherited methods | |
---|---|
Public constructors
Matrix4f
public Matrix4f (float[] dataArray)
Creates a new matrix and sets its values from the given parameter
Parameters | |
---|---|
dataArray |
float : values to set the matrix to, must be 16
floats long |
Public methods
get
public float get (int x, int y)
Returns the value for a given row and column
Parameters | |
---|---|
x |
int : column of the value to return |
y |
int : row of the value to return |
Returns | |
---|---|
float |
value in the yth row and xth column |
getArray
public float[] getArray ()
Return a reference to the internal array representing matrix values. Modifying this array will also change the matrix
Returns | |
---|---|
float[] |
internal array representing the matrix |
inverse
public boolean inverse ()
Sets the current matrix to its inverse
Returns | |
---|---|
boolean |
inverseTranspose
public boolean inverseTranspose ()
Sets the current matrix to its inverse transpose
Returns | |
---|---|
boolean |
load
public void load (Matrix4f src)
Sets the values of the matrix to those of the parameter
Parameters | |
---|---|
src |
Matrix4f : matrix to load the values from |
loadFrustum
public void loadFrustum (float l, float r, float b, float t, float n, float f)
Sets current values to be a perspective projection matrix
Parameters | |
---|---|
l |
float : location of the left vertical clipping plane |
r |
float : location of the right vertical clipping plane |
b |
float : location of the bottom horizontal clipping plane |
t |
float : location of the top horizontal clipping plane |
n |
float : location of the near clipping plane, must be positive |
f |
float : location of the far clipping plane, must be positive |
loadMultiply
public void loadMultiply (Matrix4f lhs, Matrix4f rhs)
Sets current values to be the result of multiplying two given matrices
Parameters | |
---|---|
lhs |
Matrix4f : left hand side matrix |
rhs |
Matrix4f : right hand side matrix |
loadOrtho
public void loadOrtho (float l, float r, float b, float t, float n, float f)
Set current values to be an orthographic projection matrix
Parameters | |
---|---|
l |
float : location of the left vertical clipping plane |
r |
float : location of the right vertical clipping plane |
b |
float : location of the bottom horizontal clipping plane |
t |
float : location of the top horizontal clipping plane |
n |
float : location of the near clipping plane |
f |
float : location of the far clipping plane |
loadOrthoWindow
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
Parameters | |
---|---|
w |
int : location of the right vertical clipping plane |
h |
int : location of the bottom horizontal clipping plane |
loadPerspective
public void loadPerspective (float fovy, float aspect, float near, float far)
Sets current values to be a perspective projection matrix
Parameters | |
---|---|
fovy |
float : vertical field of view angle in degrees |
aspect |
float : aspect ratio of the screen |
near |
float : near cliping plane, must be positive |
far |
float : far clipping plane, must be positive |
loadProjectionNormalized
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
Parameters | |
---|---|
w |
int : screen width |
h |
int : screen height |
loadRotate
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
Parameters | |
---|---|
rot |
float : angle of rotation |
x |
float : rotation axis x |
y |
float : rotation axis y |
z |
float : rotation axis z |
loadScale
public void loadScale (float x, float y, float z)
Sets current values to be a scale matrix of given dimensions
Parameters | |
---|---|
x |
float : scale component x |
y |
float : scale component y |
z |
float : scale component z |
loadTranslate
public void loadTranslate (float x, float y, float z)
Sets current values to be a translation matrix of given dimensions
Parameters | |
---|---|
x |
float : translation component x |
y |
float : translation component y |
z |
float : translation component z |
multiply
public void multiply (Matrix4f rhs)
Post-multiplies the current matrix by a given parameter
Parameters | |
---|---|
rhs |
Matrix4f : right hand side to multiply by |
rotate
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
Parameters | |
---|---|
rot |
float : angle of rotation |
x |
float : rotation axis x |
y |
float : rotation axis y |
z |
float : rotation axis z |
scale
public void scale (float x, float y, float z)
Modifies the current matrix by post-multiplying it with a scale matrix of given dimensions
Parameters | |
---|---|
x |
float : scale component x |
y |
float : scale component y |
z |
float : scale component z |
set
public void set (int x, int y, float v)
Sets the value for a given row and column
Parameters | |
---|---|
x |
int : column of the value to set |
y |
int : row of the value to set |
v |
float |
translate
public void translate (float x, float y, float z)
Modifies the current matrix by post-multiplying it with a translation matrix of given dimensions
Parameters | |
---|---|
x |
float : translation component x |
y |
float : translation component y |
z |
float : translation component z |