org.jbox2d.common
Class Mat22

java.lang.Object
  extended by org.jbox2d.common.Mat22

public class Mat22
extends java.lang.Object

A 2x2 matrix class.

Author:
ewjordan

Field Summary
 Vec2 col1
           
 Vec2 col2
           
 
Constructor Summary
Mat22()
          Construct zero matrix.
Mat22(float angle)
          Create a matrix representing a rotation.
Mat22(float col1x, float col2x, float col1y, 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.
 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.
 Mat22 invert()
          Returns the inverted Mat22 - does NOT invert the matrix locally!
 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 mulT(Mat22 B)
          Multiply another matrix by the transpose of this one (transpose of this one on left).
static Mat22 mulT(Mat22 A, Mat22 B)
           
static Vec2 mulT(Mat22 R, Vec2 v)
           
 Vec2 mulT(Vec2 v)
          Multiply a vector by the transpose of this matrix.
 void set(float angle)
          Set as a matrix representing a rotation.
 void set(Mat22 m)
          Set as a copy of another matrix.
 void set(Vec2 c1, Vec2 c2)
          Set by column vectors.
 void setAngle(float angle)
          Set as a matrix representing a rotation.
 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.
 java.lang.String toString()
          Convert the matrix to printable format.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

col1

public Vec2 col1

col2

public Vec2 col2
Constructor Detail

Mat22

public Mat22()
Construct zero matrix. Note: this is NOT an identity matrix!


Mat22

public Mat22(float angle)
Create a matrix representing a rotation.

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

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 col1x,
             float col2x,
             float col1y,
             float col2y)
Create a matrix from four floats.

Parameters:
col1x -
col2x -
col1y -
col2y -
Method Detail

toString

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

Overrides:
toString in class java.lang.Object

set

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

Parameters:
m - Matrix to copy

clone

public Mat22 clone()
Return a clone of this matrix.

Overrides:
clone in class java.lang.Object

set

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

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

setIdentity

public void setIdentity()
Set as the identity matrix.


setZero

public void setZero()
Set as the zero matrix.


setAngle

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

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

set

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

Parameters:
c1 - Column 1
c2 - Column 2

invert

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


abs

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

Returns:
Absolute value matrix

abs

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

Returns:
Absolute value matrix

mul

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

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

mul

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

Parameters:
R -
Returns:

mulT

public Mat22 mulT(Mat22 B)
Multiply another matrix by the transpose of this one (transpose of this one on left).

Parameters:
B -
Returns:

mulT

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

Parameters:
v -
Returns:

add

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

Parameters:
B -
Returns:

addLocal

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

Parameters:
B -
Returns:

solve

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

Returns:
The vector x that solves the above equation.

mul

public static Vec2 mul(Mat22 R,
                       Vec2 v)

mul

public static Mat22 mul(Mat22 A,
                        Mat22 B)

mulT

public static Vec2 mulT(Mat22 R,
                        Vec2 v)

mulT

public static Mat22 mulT(Mat22 A,
                         Mat22 B)