Package org.jbox2d.common
Class Mat22
java.lang.Object
org.jbox2d.common.Mat22
- All Implemented Interfaces:
java.io.Serializable
public class Mat22
extends java.lang.Object
implements java.io.Serializable
A 2-by-2 matrix. Stored in column-major order.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Mat22
abs()
Return the matrix composed of the absolute values of all elements.static final Mat22
Return the matrix composed of the absolute values of all elements.final void
absLocal()
static void
final Mat22
Add this matrix to B, return the result.final Mat22
Add B to this matrix locally.final Mat22
clone()
Return a clone of this matrix.static final Mat22
createRotationalTransform
(float angle) static final void
createRotationalTransform
(float angle, Mat22 out) static final Mat22
createScaleTransform
(float scale) static final void
createScaleTransform
(float scale, Mat22 out) boolean
equals
(java.lang.Object obj) final float
getAngle()
Extract the angle from this matrix (assumed to be a rotation matrix).int
hashCode()
final Mat22
invert()
Returns the inverted Mat22 - does NOT invert the matrix locally!final Mat22
final void
invertToOut
(Mat22 out) final Mat22
Multiply another matrix by this one (this one on left).static final Mat22
static final Vec2
final Vec2
Multiply a vector by this matrix.final Mat22
final void
static final void
static final void
final void
final void
mulToOutUnsafe
(Mat22 R, Mat22 out) static final void
mulToOutUnsafe
(Mat22 A, Mat22 B, Mat22 out) static final void
mulToOutUnsafe
(Mat22 R, Vec2 v, Vec2 out) final void
mulToOutUnsafe
(Vec2 v, Vec2 out) final Mat22
Multiply another matrix by the transpose of this one (transpose of this one on left).static final Mat22
static final Vec2
final Vec2
Multiply a vector by the transpose of this matrix.final Mat22
final void
mulTransToOut
(Mat22 B, Mat22 out) static final void
mulTransToOut
(Mat22 A, Mat22 B, Mat22 out) static final void
mulTransToOut
(Mat22 R, Vec2 v, Vec2 out) final void
mulTransToOut
(Vec2 v, Vec2 out) final void
mulTransToOutUnsafe
(Mat22 B, Mat22 out) static final void
mulTransToOutUnsafe
(Mat22 A, Mat22 B, Mat22 out) static final void
mulTransToOutUnsafe
(Mat22 R, Vec2 v, Vec2 out) final void
set
(float angle) Set as a matrix representing a rotation.final Mat22
set
(float exx, float col2x, float exy, float col2y) final Mat22
Set as a copy of another matrix.final void
Set by column vectors.final void
Set as the identity matrix.final void
setZero()
Set as the zero matrix.final Vec2
Solve A * x = b where A = this matrix.final void
solveToOut
(Vec2 b, Vec2 out) java.lang.String
toString()
Convert the matrix to printable format.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ex
-
ey
-
-
Constructor Details
-
Mat22
public Mat22()Construct zero matrix. Note: this is NOT an identity matrix! djm fixed double allocation problem -
Mat22
Create a matrix with given vectors as columns.- Parameters:
c1
- Column 1 of matrixc2
- 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 Details
-
toString
public java.lang.String toString()Convert the matrix to printable format.- Overrides:
toString
in classjava.lang.Object
-
set
Set as a copy of another matrix.- Parameters:
m
- Matrix to copy
-
set
-
clone
Return a clone of this matrix. djm fixed double allocation- Overrides:
clone
in classjava.lang.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
Set by column vectors.- Parameters:
c1
- Column 1c2
- Column 2
-
invert
Returns the inverted Mat22 - does NOT invert the matrix locally! -
invertLocal
-
invertToOut
-
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
Return the matrix composed of the absolute values of all elements.- Returns:
- Absolute value matrix
-
absToOut
-
mul
Multiply a vector by this matrix.- Parameters:
v
- Vector to multiply by matrix.- Returns:
- Resulting vector
-
mulToOut
-
mulToOutUnsafe
-
mul
Multiply another matrix by this one (this one on left). djm optimized- Parameters:
R
-- Returns:
-
mulLocal
-
mulToOut
-
mulToOutUnsafe
-
mulTrans
Multiply another matrix by the transpose of this one (transpose of this one on left). djm: optimized- Parameters:
B
-- Returns:
-
mulTransLocal
-
mulTransToOut
-
mulTransToOutUnsafe
-
mulTrans
Multiply a vector by the transpose of this matrix.- Parameters:
v
-- Returns:
-
mulTransToOut
-
add
Add this matrix to B, return the result.- Parameters:
B
-- Returns:
-
addLocal
Add B to this matrix locally.- Parameters:
B
-- Returns:
-
solve
Solve A * x = b where A = this matrix.- Returns:
- The vector x that solves the above equation.
-
solveToOut
-
mul
-
mulToOut
-
mulToOutUnsafe
-
mul
-
mulToOut
-
mulToOutUnsafe
-
mulTrans
-
mulTransToOut
-
mulTransToOutUnsafe
-
mulTrans
-
mulTransToOut
-
mulTransToOutUnsafe
-
createRotationalTransform
-
createRotationalTransform
-
createScaleTransform
-
createScaleTransform
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj) - Overrides:
equals
in classjava.lang.Object
-