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.SerializableA 2-by-2 matrix. Stored in column-major order.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description Vec2exVec2eyprivate static longserialVersionUID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Mat22abs()Return the matrix composed of the absolute values of all elements.static Mat22abs(Mat22 R)Return the matrix composed of the absolute values of all elements.voidabsLocal()static voidabsToOut(Mat22 R, Mat22 out)Mat22add(Mat22 B)Add this matrix to B, return the result.Mat22addLocal(Mat22 B)Add B to this matrix locally.Mat22clone()Return a clone of this matrix.static Mat22createRotationalTransform(float angle)static voidcreateRotationalTransform(float angle, Mat22 out)static Mat22createScaleTransform(float scale)static voidcreateScaleTransform(float scale, Mat22 out)booleanequals(java.lang.Object obj)floatgetAngle()Extract the angle from this matrix (assumed to be a rotation matrix).inthashCode()Mat22invert()Returns the inverted Mat22 - does NOT invert the matrix locally!Mat22invertLocal()voidinvertToOut(Mat22 out)Mat22mul(Mat22 R)Multiply another matrix by this one (this one on left).static Mat22mul(Mat22 A, Mat22 B)static Vec2mul(Mat22 R, Vec2 v)Vec2mul(Vec2 v)Multiply a vector by this matrix.Mat22mulLocal(Mat22 R)voidmulToOut(Mat22 R, Mat22 out)static voidmulToOut(Mat22 A, Mat22 B, Mat22 out)static voidmulToOut(Mat22 R, Vec2 v, Vec2 out)voidmulToOut(Vec2 v, Vec2 out)voidmulToOutUnsafe(Mat22 R, Mat22 out)static voidmulToOutUnsafe(Mat22 A, Mat22 B, Mat22 out)static voidmulToOutUnsafe(Mat22 R, Vec2 v, Vec2 out)voidmulToOutUnsafe(Vec2 v, Vec2 out)Mat22mulTrans(Mat22 B)Multiply another matrix by the transpose of this one (transpose of this one on left).static Mat22mulTrans(Mat22 A, Mat22 B)static Vec2mulTrans(Mat22 R, Vec2 v)Vec2mulTrans(Vec2 v)Multiply a vector by the transpose of this matrix.Mat22mulTransLocal(Mat22 B)voidmulTransToOut(Mat22 B, Mat22 out)static voidmulTransToOut(Mat22 A, Mat22 B, Mat22 out)static voidmulTransToOut(Mat22 R, Vec2 v, Vec2 out)voidmulTransToOut(Vec2 v, Vec2 out)voidmulTransToOutUnsafe(Mat22 B, Mat22 out)static voidmulTransToOutUnsafe(Mat22 A, Mat22 B, Mat22 out)static voidmulTransToOutUnsafe(Mat22 R, Vec2 v, Vec2 out)voidset(float angle)Set as a matrix representing a rotation.Mat22set(float exx, float col2x, float exy, float col2y)Mat22set(Mat22 m)Set as a copy of another matrix.voidset(Vec2 c1, Vec2 c2)Set by column vectors.voidsetIdentity()Set as the identity matrix.voidsetZero()Set as the zero matrix.Vec2solve(Vec2 b)Solve A * x = b where A = this matrix.voidsolveToOut(Vec2 b, Vec2 out)java.lang.StringtoString()Convert the matrix to printable format.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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 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 Detail
-
toString
public java.lang.String toString()
Convert the matrix to printable format.- Overrides:
toStringin classjava.lang.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:
clonein 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
public final void set(Vec2 c1, Vec2 c2)
Set by column vectors.- Parameters:
c1- Column 1c2- 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
-
mul
public final Vec2 mul(Vec2 v)
Multiply a vector by this matrix.- Parameters:
v- Vector to multiply by matrix.- Returns:
- Resulting vector
-
mul
public final Mat22 mul(Mat22 R)
Multiply another matrix by this one (this one on left). djm optimized- Parameters:
R-- Returns:
-
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:
-
mulTrans
public final Vec2 mulTrans(Vec2 v)
Multiply a vector by the transpose of this matrix.- Parameters:
v-- Returns:
-
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.
-
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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-