libgdx API

com.badlogic.gdx.math
Class Matrix3

java.lang.Object
  extended by com.badlogic.gdx.math.Matrix3
All Implemented Interfaces:
java.io.Serializable

public class Matrix3
extends java.lang.Object
implements java.io.Serializable

A 3x3 column major matrix for 2D transforms.

Author:
mzechner
See Also:
Serialized Form

Field Summary
 float[] vals
           
 
Constructor Summary
Matrix3()
           
 
Method Summary
 float det()
           
 float[] getValues()
           
 Matrix3 idt()
          Sets this matrix to the identity matrix
 Matrix3 inv()
          Inverts this matrix given that the determinant is != 0
 Matrix3 mul(Matrix3 m)
          Multiplies this matrix with the other matrix in the order this * m.
 Matrix3 rotate(float angle)
          Postmultiplies this matrix with a (counter-clockwise) rotation matrix.
 Matrix3 scale(float scaleX, float scaleY)
          Postmultiplies this matrix with a scale matrix.
 Matrix3 set(Matrix3 mat)
           
 Matrix3 setToRotation(float angle)
          Sets this matrix to a rotation matrix that will rotate any vector in counter clockwise order around the z-axis.
 Matrix3 setToScaling(float scaleX, float scaleY)
          Sets this matrix to a scaling matrix
 Matrix3 setToTranslation(float x, float y)
          Sets this matrix to a translation matrix.
 java.lang.String toString()
           
 Matrix3 translate(float x, float y)
          Postmultiplies this matrix by a translation matrix.
 Matrix3 trn(float x, float y)
          Adds a translational component to the matrix in the 3rd column.
 Matrix3 trn(Vector3 vector)
          Adds a translational component to the matrix in the 3rd column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vals

public float[] vals
Constructor Detail

Matrix3

public Matrix3()
Method Detail

idt

public Matrix3 idt()
Sets this matrix to the identity matrix

Returns:
this matrix

mul

public Matrix3 mul(Matrix3 m)
Multiplies this matrix with the other matrix in the order this * m.

Returns:
this matrix

setToRotation

public Matrix3 setToRotation(float angle)
Sets this matrix to a rotation matrix that will rotate any vector in counter clockwise order around the z-axis.

Parameters:
angle - the angle in degrees.
Returns:
this matrix

setToTranslation

public Matrix3 setToTranslation(float x,
                                float y)
Sets this matrix to a translation matrix.

Parameters:
x - the translation in x
y - the translation in y
Returns:
this matrix

setToScaling

public Matrix3 setToScaling(float scaleX,
                            float scaleY)
Sets this matrix to a scaling matrix

Parameters:
scaleX - the scale in x
scaleY - the scale in y
Returns:
this matrix

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

det

public float det()
Returns:
the determinant of this matrix

inv

public Matrix3 inv()
Inverts this matrix given that the determinant is != 0

Returns:
this matrix

set

public Matrix3 set(Matrix3 mat)

trn

public Matrix3 trn(Vector3 vector)
Adds a translational component to the matrix in the 3rd column. The other columns are untouched.

Parameters:
vector - The translation vector
Returns:
This matrix for chaining

trn

public Matrix3 trn(float x,
                   float y)
Adds a translational component to the matrix in the 3rd column. The other columns are untouched.

Parameters:
x - The x-component of the translation vector
y - The y-component of the translation vector
Returns:
This matrix for chaining

translate

public Matrix3 translate(float x,
                         float y)
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale

Parameters:
x -
y -
Returns:
this matrix for chaining

rotate

public Matrix3 rotate(float angle)
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale

Parameters:
angle - the angle in degrees
Returns:
this matrix for chaining

scale

public Matrix3 scale(float scaleX,
                     float scaleY)
Postmultiplies this matrix with a scale matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale.

Parameters:
scaleX -
scaleY -
Returns:
this matrix for chaining

getValues

public float[] getValues()

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)