public class Matrix3f extends Object implements Externalizable
m00 m10 m20
m01 m11 m21
m02 m12 m22
| Modifier and Type | Field and Description |
|---|---|
float |
m00 |
float |
m01 |
float |
m02 |
float |
m10 |
float |
m11 |
float |
m12 |
float |
m20 |
float |
m21 |
float |
m22 |
| Constructor and Description |
|---|
Matrix3f()
|
Matrix3f(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
Create a new 3x3 matrix using the supplied float values.
|
Matrix3f(Matrix3f mat)
Create a new
Matrix3f and make it a copy of the given matrix. |
| Modifier and Type | Method and Description |
|---|---|
float |
determinant()
Return the determinant of this matrix.
|
ByteBuffer |
get(ByteBuffer buffer)
Store this matrix in column-major order into the supplied
ByteBuffer at the current
buffer position. |
FloatBuffer |
get(FloatBuffer buffer)
Store this matrix in column-major order into the supplied
FloatBuffer at the current
buffer position. |
ByteBuffer |
get(int index,
ByteBuffer buffer)
Store this matrix in column-major order into the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
FloatBuffer |
get(int index,
FloatBuffer buffer)
Store this matrix in column-major order into the supplied
FloatBuffer starting at the specified
absolute buffer position/index. |
Matrix3f |
get(Matrix3f dest)
Get the current values of
this matrix and store them into
dest. |
Matrix3f |
identity()
Set this matrix to the identity.
|
Matrix3f |
invert()
Invert this matrix.
|
Matrix3f |
invert(Matrix3f dest)
Invert the
this matrix and store the result in dest. |
Matrix3f |
mul(Matrix3f right)
Multiply this matrix by the supplied
right matrix. |
Matrix3f |
mul(Matrix3f right,
Matrix3f dest)
Multiply this matrix by the supplied
right matrix and store the result in dest. |
void |
readExternal(ObjectInput in) |
Matrix3f |
rotate(float ang)
Apply a rotation transformation to this matrix by rotating the given amount of radians.
|
Matrix3f |
rotate(float ang,
Matrix3f dest)
Apply a rotation transformation to this matrix by rotating the given amount of radians and store the result in
dest. |
Matrix3f |
rotateAbout(float ang,
float x,
float y)
Apply a rotation transformation to this matrix by rotating the given amount of radians about
the specified rotation center (x, y).
|
Matrix3f |
rotateAbout(float ang,
float x,
float y,
Matrix3f dest)
Apply a rotation transformation to this matrix by rotating the given amount of radians about
the specified rotation center (x, y) and store the result in
dest. |
Matrix3f |
rotateTo(Vector2f fromDir,
Vector2f toDir)
Apply a rotation transformation to this matrix that rotates the given normalized
fromDir direction vector
to point along the normalized toDir. |
Matrix3f |
rotateTo(Vector2f fromDir,
Vector2f toDir,
Matrix3f dest)
Apply a rotation transformation to this matrix that rotates the given normalized
fromDir direction vector
to point along the normalized toDir, and store the result in dest. |
Matrix3f |
rotation(float angle)
Set this matrix to a rotation matrix which rotates the given radians.
|
Matrix3f |
scale(float xy)
Apply scaling to this matrix by uniformly scaling the two base axes by the given
xyz factor. |
Matrix3f |
scale(float x,
float y)
Apply scaling to this matrix by scaling the unit axes by the given x and y factors.
|
Matrix3f |
scale(float x,
float y,
Matrix3f dest)
Apply scaling to this matrix by scaling the unit axes by the given x and y and store the result in
dest. |
Matrix3f |
scale(float xy,
Matrix3f dest)
Apply scaling to this matrix by uniformly scaling the two base axes by the given
xy factor
and store the result in dest. |
Matrix3f |
scaling(float factor)
Set this matrix to be a simple scale matrix, which scales the two base axes uniformly by the given factor.
|
Matrix3f |
scaling(float x,
float y)
Set this matrix to be a simple scale matrix.
|
Matrix3f |
set(ByteBuffer buffer)
Set the values of this matrix by reading 9 float values from the given
ByteBuffer in column-major order,
starting at its current position. |
Matrix3f |
set(float[] m)
Set the values in this matrix based on the supplied float array.
|
Matrix3f |
set(FloatBuffer buffer)
Set the values of this matrix by reading 9 float values from the given
FloatBuffer in column-major order,
starting at its current position. |
Matrix3f |
set(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
Set the values within this matrix to the supplied float values.
|
Matrix3f |
set(Matrix3f m)
Set the elements of this matrix to the ones in
m. |
Matrix3f |
setTranslation(float x,
float y)
Set only the translation components of this matrix (m20, m21) to the given values (x, y).
|
Matrix3f |
setTranslation(Vector2f offset)
Set only the translation components of this matrix (m20, m21) to the given values (offset.x, offset.y).
|
Matrix3f |
setView(float left,
float right,
float bottom,
float top)
Set this matrix to define a "view" transformation that maps the given (left, bottom) and
(right, top) corners to (-1, -1) and (1, 1) respectively.
|
String |
toString()
Return a string representation of this matrix.
|
String |
toString(NumberFormat formatter)
Return a string representation of this matrix by formatting the matrix elements with the given
NumberFormat. |
Matrix3f |
transform(Vector2f v)
Transform the given vector by this matrix.
|
Vector2f |
transform(Vector2f v,
Vector2f dest)
Transform the given vector by this matrix and store the result in
dest. |
Matrix3f |
translate(float x,
float y)
Apply a translation to this matrix by translating by the given number of units in x and y.
|
Matrix3f |
translate(float x,
float y,
Matrix3f dest)
Apply a translation to this matrix by translating by the given number of units in x and y and store the result
in
dest. |
Matrix3f |
translate(Vector2f offset)
Apply a translation to this matrix by translating by the given number of units in x and y.
|
Matrix3f |
translate(Vector2f offset,
Matrix3f dest)
Apply a translation to this matrix by translating by the given number of units in x and y, and
store the result in
dest. |
Matrix3f |
translation(float x,
float y)
Set this matrix to be a simple translation matrix in a two-dimensional coordinate system.
|
Matrix3f |
translation(Vector2f offset)
Set this matrix to be a simple translation matrix in a two-dimensional coordinate system.
|
Matrix3f |
transpose()
Transpose this matrix.
|
Matrix3f |
transpose(Matrix3f dest)
Transpose
this matrix and store the result in dest. |
Matrix3f |
view(float left,
float right,
float bottom,
float top)
Apply a "view" transformation to this matrix that maps the given (left, bottom) and
(right, top) corners to (-1, -1) and (1, 1) respectively.
|
Matrix3f |
view(float left,
float right,
float bottom,
float top,
Matrix3f dest)
Apply a "view" transformation to this matrix that maps the given (left, bottom) and
(right, top) corners to (-1, -1) and (1, 1) respectively and store the result in
dest. |
void |
writeExternal(ObjectOutput out) |
Matrix3f |
zero()
Set all values within this matrix to zero.
|
public float m00
public float m10
public float m20
public float m01
public float m11
public float m21
public float m02
public float m12
public float m22
public Matrix3f()
public Matrix3f(Matrix3f mat)
Matrix3f and make it a copy of the given matrix.mat - the Matrix3f to copy the values frompublic Matrix3f(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
m00 - the value of m00m01 - the value of m01m02 - the value of m02m10 - the value of m10m11 - the value of m11m12 - the value of m12m20 - the value of m20m21 - the value of m21m22 - the value of m22public Matrix3f set(Matrix3f m)
m.m - the matrix to copy the elements frompublic Matrix3f mul(Matrix3f right)
right matrix.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
right - the right operand of the matrix multiplicationpublic Matrix3f mul(Matrix3f right, Matrix3f dest)
right matrix and store the result in dest.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
right - the right operand of the matrix multiplicationdest - will hold the resultpublic Matrix3f set(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
m00, m10, m20
m01, m11, m21
m02, m12, m22
m00 - the new value of m00m01 - the new value of m01m02 - the new value of m02m10 - the new value of m10m11 - the new value of m11m12 - the new value of m12m20 - the new value of m20m21 - the new value of m21m22 - the new value of m22public Matrix3f set(float[] m)
0, 3, 6
1, 4, 7
2, 5, 8
This method only uses the first 9 values, all others are ignored.
m - the array to read the matrix values frompublic float determinant()
public Matrix3f invert()
public Matrix3f invert(Matrix3f dest)
this matrix and store the result in dest.dest - will hold the resultpublic Matrix3f transpose()
public Matrix3f transpose(Matrix3f dest)
this matrix and store the result in dest.dest - will hold the resultpublic Matrix3f translation(float x, float y)
The resulting matrix can be multiplied against another transformation matrix to obtain an additional translation.
In order to apply a translation via to an already existing transformation
matrix, use translate() instead.
x - the units to translate in xy - the units to translate in ytranslate(float, float)public Matrix3f translation(Vector2f offset)
The resulting matrix can be multiplied against another transformation matrix to obtain an additional translation.
In order to apply a translation via to an already existing transformation
matrix, use translate() instead.
offset - the translationtranslate(Vector2f)public Matrix3f setTranslation(float x, float y)
To build a translation matrix instead, use translation(float, float).
To apply a translation to another matrix, use translate(float, float).
x - the offset to translate in xy - the offset to translate in ytranslation(float, float),
translate(float, float)public Matrix3f setTranslation(Vector2f offset)
To build a translation matrix instead, use translation(Vector2f).
To apply a translation to another matrix, use translate(Vector2f).
offset - the new translation to settranslation(Vector2f),
translate(Vector2f)public Matrix3f translate(float x, float y, Matrix3f dest)
dest.
If M is this matrix and T the translation
matrix, then the new matrix will be M * T. So when
transforming a vector v with the new matrix by using
M * T * v, the translation will be applied first!
In order to set the matrix to a translation transformation without post-multiplying
it, use translation(float, float).
x - the offset to translate in xy - the offset to translate in ydest - will hold the resulttranslation(float, float)public Matrix3f translate(float x, float y)
If M is this matrix and T the translation
matrix, then the new matrix will be M * T. So when
transforming a vector v with the new matrix by using
M * T * v, the translation will be applied first!
In order to set the matrix to a translation transformation without post-multiplying
it, use translation(float, float).
x - the offset to translate in xy - the offset to translate in ytranslation(float, float)public Matrix3f translate(Vector2f offset, Matrix3f dest)
dest.
If M is this matrix and T the translation
matrix, then the new matrix will be M * T. So when
transforming a vector v with the new matrix by using
M * T * v, the translation will be applied first!
In order to set the matrix to a translation transformation without post-multiplying
it, use translation(float, float).
offset - the offset to translatedest - will hold the resulttranslation(Vector2f)public Matrix3f translate(Vector2f offset)
If M is this matrix and T the translation
matrix, then the new matrix will be M * T. So when
transforming a vector v with the new matrix by using
M * T * v, the translation will be applied first!
In order to set the matrix to a translation transformation without post-multiplying
it, use translation(float, float).
offset - the offset to translatetranslation(Vector2f)public String toString()
This method creates a new DecimalFormat on every invocation with the format string " 0.000E0; -".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the matrix values withpublic Matrix3f get(Matrix3f dest)
this matrix and store them into
dest.
This is the reverse method of set(Matrix3f) and allows to obtain
intermediate calculation results when chaining multiple transformations.
dest - the destination matrixset(Matrix3f)public FloatBuffer get(FloatBuffer buffer)
FloatBuffer at the current
buffer position.
This method will not increment the position of the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which
the matrix is stored, use get(int, FloatBuffer), taking
the absolute position as parameter.
buffer - will receive the values of this matrix in column-major order at its current positionget(int, FloatBuffer)public FloatBuffer get(int index, FloatBuffer buffer)
FloatBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given FloatBuffer.
index - the absolute position into the FloatBufferbuffer - will receive the values of this matrix in column-major orderpublic ByteBuffer get(ByteBuffer buffer)
ByteBuffer at the current
buffer position.
This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which
the matrix is stored, use get(int, ByteBuffer), taking
the absolute position as parameter.
buffer - will receive the values of this matrix in column-major order at its current positionget(int, ByteBuffer)public ByteBuffer get(int index, ByteBuffer buffer)
ByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - will receive the values of this matrix in column-major orderpublic Matrix3f set(FloatBuffer buffer)
FloatBuffer in column-major order,
starting at its current position.
The FloatBuffer is expected to contain the values in column-major order.
The position of the FloatBuffer will not be changed by this method.
buffer - the FloatBuffer to read the matrix values from in column-major orderpublic Matrix3f set(ByteBuffer buffer)
ByteBuffer in column-major order,
starting at its current position.
The ByteBuffer is expected to contain the values in column-major order.
The position of the ByteBuffer will not be changed by this method.
buffer - the ByteBuffer to read the matrix values from in column-major orderpublic Matrix3f zero()
public Matrix3f identity()
public Matrix3f scale(float x, float y, Matrix3f dest)
dest.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v, the scaling will be applied first!
x - the factor of the x componenty - the factor of the y componentdest - will hold the resultpublic Matrix3f scale(float x, float y)
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v, the scaling will be applied first!
x - the factor of the x componenty - the factor of the y componentpublic Matrix3f scale(float xy, Matrix3f dest)
xy factor
and store the result in dest.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v, the scaling will be applied first!
xy - the factor for the two componentsdest - will hold the resultscale(float, float, Matrix3f)public Matrix3f scale(float xy)
xyz factor.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v, the scaling will be applied first!
xy - the factor for the two componentsscale(float, float)public Matrix3f scaling(float factor)
The resulting matrix can be multiplied against another transformation matrix to obtain an additional scaling.
In order to post-multiply a scaling transformation directly to a matrix, use scale() instead.
factor - the scale factor in x and yscale(float)public Matrix3f scaling(float x, float y)
x - the scale in xy - the scale in ypublic Matrix3f rotation(float angle)
The resulting matrix can be multiplied against another transformation matrix to obtain an additional rotation.
In order to apply the rotation transformation to an existing transformation,
use rotate() instead.
angle - the angle in radiansrotate(float)public Matrix3f transform(Vector2f v)
v - the vector to transformpublic Vector2f transform(Vector2f v, Vector2f dest)
dest.v - the vector to transformdest - will hold the resultpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic Matrix3f rotate(float ang)
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v
, the rotation will be applied first!
ang - the angle in radianspublic Matrix3f rotate(float ang, Matrix3f dest)
dest.
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the rotation will be applied first!
ang - the angle in radiansdest - will hold the resultpublic Matrix3f rotateAbout(float ang, float x, float y)
This method is equivalent to calling: translate(x, y).rotate(ang).translate(-x, -y)
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the rotation will be applied first!
ang - the angle in radiansx - the x component of the rotation centery - the y component of the rotation centertranslate(float, float),
rotate(float)public Matrix3f rotateAbout(float ang, float x, float y, Matrix3f dest)
dest.
This method is equivalent to calling: translate(x, y, dest).rotate(ang).translate(-x, -y)
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the rotation will be applied first!
ang - the angle in radiansx - the x component of the rotation centery - the y component of the rotation centerdest - will hold the resulttranslate(float, float, Matrix3f),
rotate(float, Matrix3f)public Matrix3f rotateTo(Vector2f fromDir, Vector2f toDir, Matrix3f dest)
fromDir direction vector
to point along the normalized toDir, and store the result in dest.
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the rotation will be applied first!
fromDir - the normalized direction which should be rotate to point along toDirtoDir - the normalized destination directiondest - will hold the resultpublic Matrix3f rotateTo(Vector2f fromDir, Vector2f toDir)
fromDir direction vector
to point along the normalized toDir.
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the rotation will be applied first!
fromDir - the normalized direction which should be rotate to point along toDirtoDir - the normalized destination directionpublic Matrix3f view(float left, float right, float bottom, float top, Matrix3f dest)
dest.
If M is this matrix and O the orthographic projection matrix,
then the new matrix will be M * O. So when transforming a
vector v with the new matrix by using M * O * v, the
orthographic projection transformation will be applied first!
left - the distance from the center to the left view edgeright - the distance from the center to the right view edgebottom - the distance from the center to the bottom view edgetop - the distance from the center to the top view edgedest - will hold the resultsetView(float, float, float, float)public Matrix3f view(float left, float right, float bottom, float top)
If M is this matrix and O the orthographic projection matrix,
then the new matrix will be M * O. So when transforming a
vector v with the new matrix by using M * O * v, the
orthographic projection transformation will be applied first!
left - the distance from the center to the left view edgeright - the distance from the center to the right view edgebottom - the distance from the center to the bottom view edgetop - the distance from the center to the top view edgesetView(float, float, float, float)public Matrix3f setView(float left, float right, float bottom, float top)
left - the distance from the center to the left view edgeright - the distance from the center to the right view edgebottom - the distance from the center to the bottom view edgetop - the distance from the center to the top view edgeview(float, float, float, float)Copyright © 2015 JOML. All rights reserved.