java.lang.Object | |
↳ | android.opengl.Matrix |
Matrix math utilities. These methods operate on OpenGL ES format matrices and vectors stored in float arrays. Matrices are 4 x 4 column-vector matrices stored in column-major order:
m[offset + 0] m[offset + 4] m[offset + 8] m[offset + 12] m[offset + 1] m[offset + 5] m[offset + 9] m[offset + 13] m[offset + 2] m[offset + 6] m[offset + 10] m[offset + 14] m[offset + 3] m[offset + 7] m[offset + 11] m[offset + 15]Vectors are 4 row x 1 column column-vectors stored in order:
v[offset + 0] v[offset + 1] v[offset + 2] v[offset + 3]
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Define a projection matrix in terms of six clip planes
| |||||||||||
Inverts a 4 x 4 matrix.
| |||||||||||
Computes the length of a vector
| |||||||||||
Multiply two 4x4 matrices together and store the result in a third 4x4
matrix.
| |||||||||||
Multiply a 4 element vector by a 4x4 matrix and store the result in a 4
element column vector.
| |||||||||||
Computes an orthographic projection matrix.
| |||||||||||
Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
| |||||||||||
Rotates matrix m in place by angle a (in degrees)
around the axis (x, y, z)
| |||||||||||
Scales matrix m in place by sx, sy, and sz
| |||||||||||
Scales matrix m by x, y, and z, putting the result in sm
| |||||||||||
Sets matrix m to the identity matrix.
| |||||||||||
Converts Euler angles to a rotation matrix
| |||||||||||
Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
| |||||||||||
Translates matrix m by x, y, and z, putting the result in tm
| |||||||||||
Translates matrix m by x, y, and z in place.
| |||||||||||
Transposes a 4 x 4 matrix.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Define a projection matrix in terms of six clip planes
m | the float array that holds the perspective matrix |
---|---|
offset | the offset into float array m where the perspective matrix data is written |
Inverts a 4 x 4 matrix.
mInv | the array that holds the output inverted matrix |
---|---|
mInvOffset | an offset into mInv where the inverted matrix is stored. |
m | the input array |
mOffset | an offset into m where the matrix is stored. |
Computes the length of a vector
x | x coordinate of a vector |
---|---|
y | y coordinate of a vector |
z | z coordinate of a vector |
Multiply two 4x4 matrices together and store the result in a third 4x4 matrix. In matrix notation: result = lhs x rhs. Due to the way matrix multiplication works, the result matrix will have the same effect as first multiplying by the rhs matrix, then multiplying by the lhs matrix. This is the opposite of what you might expect. The same float array may be passed for result, lhs, and/or rhs. However, the result element values are undefined if the result elements overlap either the lhs or rhs elements.
result | The float array that holds the result. |
---|---|
resultOffset | The offset into the result array where the result is stored. |
lhs | The float array that holds the left-hand-side matrix. |
lhsOffset | The offset into the lhs array where the lhs is stored |
rhs | The float array that holds the right-hand-side matrix. |
rhsOffset | The offset into the rhs array where the rhs is stored. |
IllegalArgumentException | if result, lhs, or rhs are null, or if resultOffset + 16 > result.length or lhsOffset + 16 > lhs.length or rhsOffset + 16 > rhs.length. |
---|
Multiply a 4 element vector by a 4x4 matrix and store the result in a 4 element column vector. In matrix notation: result = lhs x rhs The same float array may be passed for resultVec, lhsMat, and/or rhsVec. However, the resultVec element values are undefined if the resultVec elements overlap either the lhsMat or rhsVec elements.
resultVec | The float array that holds the result vector. |
---|---|
resultVecOffset | The offset into the result array where the result vector is stored. |
lhsMat | The float array that holds the left-hand-side matrix. |
lhsMatOffset | The offset into the lhs array where the lhs is stored |
rhsVec | The float array that holds the right-hand-side vector. |
rhsVecOffset | The offset into the rhs vector where the rhs vector is stored. |
IllegalArgumentException | if resultVec, lhsMat, or rhsVec are null, or if resultVecOffset + 4 > resultVec.length or lhsMatOffset + 16 > lhsMat.length or rhsVecOffset + 4 > rhsVec.length. |
---|
Computes an orthographic projection matrix.
m | returns the result |
---|
Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
rm | returns the result |
---|---|
rmOffset | index into rm where the result matrix starts |
m | source matrix |
mOffset | index into m where the source matrix starts |
a | angle to rotate in degrees |
x | scale factor x |
y | scale factor y |
z | scale factor z |
Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z)
m | source matrix |
---|---|
mOffset | index into m where the matrix starts |
a | angle to rotate in degrees |
x | scale factor x |
y | scale factor y |
z | scale factor z |
Scales matrix m in place by sx, sy, and sz
m | matrix to scale |
---|---|
mOffset | index into m where the matrix starts |
x | scale factor x |
y | scale factor y |
z | scale factor z |
Scales matrix m by x, y, and z, putting the result in sm
sm | returns the result |
---|---|
smOffset | index into sm where the result matrix starts |
m | source matrix |
mOffset | index into m where the source matrix starts |
x | scale factor x |
y | scale factor y |
z | scale factor z |
Sets matrix m to the identity matrix.
sm | returns the result |
---|---|
smOffset | index into sm where the result matrix starts |
Converts Euler angles to a rotation matrix
rm | returns the result |
---|---|
rmOffset | index into rm where the result matrix starts |
x | angle of rotation, in degrees |
y | angle of rotation, in degrees |
z | angle of rotation, in degrees |
Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
rm | returns the result |
---|---|
rmOffset | index into rm where the result matrix starts |
a | angle to rotate in degrees |
x | scale factor x |
y | scale factor y |
z | scale factor z |
Translates matrix m by x, y, and z, putting the result in tm
tm | returns the result |
---|---|
tmOffset | index into sm where the result matrix starts |
m | source matrix |
mOffset | index into m where the source matrix starts |
x | translation factor x |
y | translation factor y |
z | translation factor z |
Translates matrix m by x, y, and z in place.
m | matrix |
---|---|
mOffset | index into m where the matrix starts |
x | translation factor x |
y | translation factor y |
z | translation factor z |
Transposes a 4 x 4 matrix.
mTrans | the array that holds the output inverted matrix |
---|---|
mTransOffset | an offset into mInv where the inverted matrix is stored. |
m | the input array |
mOffset | an offset into m where the matrix is stored. |