org.jbox2d.common
Class Mat22

java.lang.Object
  extended by org.jbox2d.common.Mat22
All Implemented Interfaces:
Serializable

public class Mat22
extends Object
implements Serializable

A 2-by-2 matrix. Stored in column-major order.

See Also:
Serialized Form

Field Summary
 Vec2 ex
           
 Vec2 ey
           
 
Constructor Summary
Mat22()
          Construct zero matrix.
Mat22(float exx, float col2x, float exy, float col2y)
          Create a matrix from four floats.
Mat22(Vec2 c1, Vec2 c2)
          Create a matrix with given vectors as columns.
 
Method Summary
 Mat22 abs()
          Return the matrix composed of the absolute values of all elements.
static Mat22 abs(Mat22 R)
          Return the matrix composed of the absolute values of all elements.
 void absLocal()
           
static void absToOut(Mat22 R, Mat22 out)
           
 Mat22 add(Mat22 B)
          Add this matrix to B, return the result.
 Mat22 addLocal(Mat22 B)
          Add B to this matrix locally.
 Mat22 clone()
          Return a clone of this matrix.
static Mat22 createRotationalTransform(float angle)
           
static void createRotationalTransform(float angle, Mat22 out)
           
static Mat22 createScaleTransform(float scale)
           
static void createScaleTransform(float scale, Mat22 out)
           
 boolean equals(Object obj)
           
 float getAngle()
          Extract the angle from this matrix (assumed to be a rotation matrix).
 int hashCode()
           
 Mat22 invert()
          Returns the inverted Mat22 - does NOT invert the matrix locally!
 Mat22 invertLocal()
           
 void invertToOut(Mat22 out)
           
 Mat22 mul(Mat22 R)
          Multiply another matrix by this one (this one on left).
static Mat22 mul(Mat22 A, Mat22 B)
           
static Vec2 mul(Mat22 R, Vec2 v)
           
 Vec2 mul(Vec2 v)
          Multiply a vector by this matrix.
 Mat22 mulLocal(Mat22 R)
           
 void mulToOut(Mat22 R, Mat22 out)
           
static void mulToOut(Mat22 A, Mat22 B, Mat22 out)
           
static void mulToOut(Mat22 R, Vec2 v, Vec2 out)
           
 void mulToOut(Vec2 v, Vec2 out)
           
 void mulToOutUnsafe(Mat22 R, Mat22 out)
           
static void mulToOutUnsafe(Mat22 A, Mat22 B, Mat22 out)
           
static void mulToOutUnsafe(Mat22 R, Vec2 v, Vec2 out)
           
 void mulToOutUnsafe(Vec2 v, Vec2 out)
           
 Mat22 mulTrans(Mat22 B)
          Multiply another matrix by the transpose of this one (transpose of this one on left).
static Mat22 mulTrans(Mat22 A, Mat22 B)
           
static Vec2 mulTrans(Mat22 R, Vec2 v)
           
 Vec2 mulTrans(Vec2 v)
          Multiply a vector by the transpose of this matrix.
 Mat22 mulTransLocal(Mat22 B)
           
 void mulTransToOut(Mat22 B, Mat22 out)
           
static void mulTransToOut(Mat22 A, Mat22 B, Mat22 out)
           
static void mulTransToOut(Mat22 R, Vec2 v, Vec2 out)
           
 void mulTransToOut(Vec2 v, Vec2 out)
           
 void mulTransToOutUnsafe(Mat22 B, Mat22 out)
           
static void mulTransToOutUnsafe(Mat22 A, Mat22 B, Mat22 out)
           
static void mulTransToOutUnsafe(Mat22 R, Vec2 v, Vec2 out)
           
 void set(float angle)
          Set as a matrix representing a rotation.
 Mat22 set(float exx, float col2x, float exy, float col2y)
           
 Mat22 set(Mat22 m)
          Set as a copy of another matrix.
 void set(Vec2 c1, Vec2 c2)
          Set by column vectors.
 void setIdentity()
          Set as the identity matrix.
 void setZero()
          Set as the zero matrix.
 Vec2 solve(Vec2 b)
          Solve A * x = b where A = this matrix.
 void solveToOut(Vec2 b, Vec2 out)
           
 String toString()
          Convert the matrix to printable format.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ex

public final Vec2 ex

ey

public final Vec2 ey
Constructor Detail

Mat22

public Mat22()
Construct zero matrix. Note: this is NOT an identity matrix! djm fixed double allocation problem


Mat22

public Mat22(Vec2 c1,
             Vec2 c2)
Create a matrix with given vectors as columns.

Parameters:
c1 - Column 1 of matrix
c2 - Column 2 of matrix

Mat22

public Mat22(float exx,
             float col2x,
             float exy,
             float col2y)
Create a matrix from four floats.

Parameters:
exx -
col2x -
exy -
col2y -
Method Detail

toString

public String toString()
Convert the matrix to printable format.

Overrides:
toString in class Object

set

public final Mat22 set(Mat22 m)
Set as a copy of another matrix.

Parameters:
m - Matrix to copy

set

public final Mat22 set(float exx,
                       float col2x,
                       float exy,
                       float col2y)

clone

public final Mat22 clone()
Return a clone of this matrix. djm fixed double allocation

Overrides:
clone in class Object

set

public final void set(float angle)
Set as a matrix representing a rotation.

Parameters:
angle - Rotation (in radians) that matrix represents.

setIdentity

public final void setIdentity()
Set as the identity matrix.


setZero

public final void setZero()
Set as the zero matrix.


getAngle

public final float getAngle()
Extract the angle from this matrix (assumed to be a rotation matrix).

Returns:

set

public final void set(Vec2 c1,
                      Vec2 c2)
Set by column vectors.

Parameters:
c1 - Column 1
c2 - Column 2

invert

public final Mat22 invert()
Returns the inverted Mat22 - does NOT invert the matrix locally!


invertLocal

public final Mat22 invertLocal()

invertToOut

public final void invertToOut(Mat22 out)

abs

public final Mat22 abs()
Return the matrix composed of the absolute values of all elements. djm: fixed double allocation

Returns:
Absolute value matrix

absLocal

public final void absLocal()

abs

public static final Mat22 abs(Mat22 R)
Return the matrix composed of the absolute values of all elements.

Returns:
Absolute value matrix

absToOut

public static void absToOut(Mat22 R,
                            Mat22 out)

mul

public final Vec2 mul(Vec2 v)
Multiply a vector by this matrix.

Parameters:
v - Vector to multiply by matrix.
Returns:
Resulting vector

mulToOut

public final void mulToOut(Vec2 v,
                           Vec2 out)

mulToOutUnsafe

public final void mulToOutUnsafe(Vec2 v,
                                 Vec2 out)

mul

public final Mat22 mul(Mat22 R)
Multiply another matrix by this one (this one on left). djm optimized

Parameters:
R -
Returns:

mulLocal

public final Mat22 mulLocal(Mat22 R)

mulToOut

public final void mulToOut(Mat22 R,
                           Mat22 out)

mulToOutUnsafe

public final void mulToOutUnsafe(Mat22 R,
                                 Mat22 out)

mulTrans

public final Mat22 mulTrans(Mat22 B)
Multiply another matrix by the transpose of this one (transpose of this one on left). djm: optimized

Parameters:
B -
Returns:

mulTransLocal

public final Mat22 mulTransLocal(Mat22 B)

mulTransToOut

public final void mulTransToOut(Mat22 B,
                                Mat22 out)

mulTransToOutUnsafe

public final void mulTransToOutUnsafe(Mat22 B,
                                      Mat22 out)

mulTrans

public final Vec2 mulTrans(Vec2 v)
Multiply a vector by the transpose of this matrix.

Parameters:
v -
Returns:

mulTransToOut

public final void mulTransToOut(Vec2 v,
                                Vec2 out)

add

public final Mat22 add(Mat22 B)
Add this matrix to B, return the result.

Parameters:
B -
Returns:

addLocal

public final Mat22 addLocal(Mat22 B)
Add B to this matrix locally.

Parameters:
B -
Returns:

solve

public final Vec2 solve(Vec2 b)
Solve A * x = b where A = this matrix.

Returns:
The vector x that solves the above equation.

solveToOut

public final void solveToOut(Vec2 b,
                             Vec2 out)

mul

public static final Vec2 mul(Mat22 R,
                             Vec2 v)

mulToOut

public static final void mulToOut(Mat22 R,
                                  Vec2 v,
                                  Vec2 out)

mulToOutUnsafe

public static final void mulToOutUnsafe(Mat22 R,
                                        Vec2 v,
                                        Vec2 out)

mul

public static final Mat22 mul(Mat22 A,
                              Mat22 B)

mulToOut

public static final void mulToOut(Mat22 A,
                                  Mat22 B,
                                  Mat22 out)

mulToOutUnsafe

public static final void mulToOutUnsafe(Mat22 A,
                                        Mat22 B,
                                        Mat22 out)

mulTrans

public static final Vec2 mulTrans(Mat22 R,
                                  Vec2 v)

mulTransToOut

public static final void mulTransToOut(Mat22 R,
                                       Vec2 v,
                                       Vec2 out)

mulTransToOutUnsafe

public static final void mulTransToOutUnsafe(Mat22 R,
                                             Vec2 v,
                                             Vec2 out)

mulTrans

public static final Mat22 mulTrans(Mat22 A,
                                   Mat22 B)

mulTransToOut

public static final void mulTransToOut(Mat22 A,
                                       Mat22 B,
                                       Mat22 out)

mulTransToOutUnsafe

public static final void mulTransToOutUnsafe(Mat22 A,
                                             Mat22 B,
                                             Mat22 out)

createRotationalTransform

public static final Mat22 createRotationalTransform(float angle)

createRotationalTransform

public static final void createRotationalTransform(float angle,
                                                   Mat22 out)

createScaleTransform

public static final Mat22 createScaleTransform(float scale)

createScaleTransform

public static final void createScaleTransform(float scale,
                                              Mat22 out)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2013. All Rights Reserved.