public final static Mat22 mulTrans(final Mat22 A, final Mat22 B) { final Mat22 C = new Mat22(); C.ex.x = A.ex.x * B.ex.x + A.ex.y * B.ex.y; C.ex.y = A.ey.x * B.ex.x + A.ey.y * B.ex.y; C.ey.x = A.ex.x * B.ey.x + A.ex.y * B.ey.y; C.ey.y = A.ey.x * B.ey.x + A.ey.y * B.ey.y; return C; }
/** * Return a clone of this matrix. djm fixed double allocation */ // @Override // annotation omitted for GWT-compatibility public final Mat22 clone() { return new Mat22(ex, ey); }
public final static Mat22 createScaleTransform(float scale) { Mat22 mat = new Mat22(); mat.ex.x = scale; mat.ey.y = scale; return mat; }
public final static Mat22 mul(final Mat22 A, final Mat22 B) { // return A.mul(B); final Mat22 C = new Mat22(); C.ex.x = A.ex.x * B.ex.x + A.ey.x * B.ex.y; C.ex.y = A.ex.y * B.ex.x + A.ey.y * B.ex.y; C.ey.x = A.ex.x * B.ey.x + A.ey.x * B.ey.y; C.ey.y = A.ex.y * B.ey.x + A.ey.y * B.ey.y; return C; }
/** Returns the inverted Mat22 - does NOT invert the matrix locally! */ public final Mat22 invert() { final float a = ex.x, b = ey.x, c = ex.y, d = ey.y; final Mat22 B = new Mat22(); float det = a * d - b * c; if (det != 0) { det = 1.0f / det; } B.ex.x = det * d; B.ey.x = -det * b; B.ex.y = -det * c; B.ey.y = det * a; return B; }
/** * Add this matrix to B, return the result. * * @param B * @return */ public final Mat22 add(final Mat22 B) { // return new Mat22(ex.add(B.ex), col2.add(B.ey)); Mat22 m = new Mat22(); m.ex.x = ex.x + B.ex.x; m.ex.y = ex.y + B.ex.y; m.ey.x = ey.x + B.ey.x; m.ey.y = ey.y + B.ey.y; return m; }
protected Mat22 newInstance() { return new Mat22(); } };
/** * Multiply another matrix by this one (this one on left). djm optimized * * @param R * @return */ public final Mat22 mul(final Mat22 R) { /* * Mat22 C = new Mat22();C.set(this.mul(R.ex), this.mul(R.ey));return C; */ final Mat22 C = new Mat22(); C.ex.x = ex.x * R.ex.x + ey.x * R.ex.y; C.ex.y = ex.y * R.ex.x + ey.y * R.ex.y; C.ey.x = ex.x * R.ey.x + ey.x * R.ey.y; C.ey.y = ex.y * R.ey.x + ey.y * R.ey.y; // C.set(ex,col2); return C; }
public final static Mat22 createRotationalTransform(float angle) { Mat22 mat = new Mat22(); final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); mat.ex.x = c; mat.ey.x = -s; mat.ex.y = s; mat.ey.y = c; return mat; }
/** * Return the matrix composed of the absolute values of all elements. djm: fixed double allocation * * @return Absolute value matrix */ public final Mat22 abs() { return new Mat22(MathUtils.abs(ex.x), MathUtils.abs(ey.x), MathUtils.abs(ex.y), MathUtils.abs(ey.y)); }
/** * Multiply another matrix by the transpose of this one (transpose of this one on left). djm: * optimized * * @param B * @return */ public final Mat22 mulTrans(final Mat22 B) { /* * Vec2 c1 = new Vec2(Vec2.dot(this.ex, B.ex), Vec2.dot(this.ey, B.ex)); Vec2 c2 = new * Vec2(Vec2.dot(this.ex, B.ey), Vec2.dot(this.ey, B.ey)); Mat22 C = new Mat22(); C.set(c1, c2); * return C; */ final Mat22 C = new Mat22(); C.ex.x = Vec2.dot(this.ex, B.ex); C.ex.y = Vec2.dot(this.ey, B.ex); C.ey.x = Vec2.dot(this.ex, B.ey); C.ey.y = Vec2.dot(this.ey, B.ey); return C; }
public final static Mat22 mulTrans(final Mat22 A, final Mat22 B) { final Mat22 C = new Mat22(); C.ex.x = A.ex.x * B.ex.x + A.ex.y * B.ex.y; C.ex.y = A.ey.x * B.ex.x + A.ey.y * B.ex.y; C.ey.x = A.ex.x * B.ey.x + A.ex.y * B.ey.y; C.ey.y = A.ey.x * B.ey.x + A.ey.y * B.ey.y; return C; }
public final static Mat22 createScaleTransform(float scale) { Mat22 mat = new Mat22(); mat.ex.x = scale; mat.ey.y = scale; return mat; }
public final static Mat22 mul(final Mat22 A, final Mat22 B) { // return A.mul(B); final Mat22 C = new Mat22(); C.ex.x = A.ex.x * B.ex.x + A.ey.x * B.ex.y; C.ex.y = A.ex.y * B.ex.x + A.ey.y * B.ex.y; C.ey.x = A.ex.x * B.ey.x + A.ey.x * B.ey.y; C.ey.y = A.ex.y * B.ey.x + A.ey.y * B.ey.y; return C; }
/** * Return a clone of this matrix. djm fixed double allocation */ // @Override // annotation omitted for GWT-compatibility public final Mat22 clone() { return new Mat22(ex, ey); }
/** Returns the inverted Mat22 - does NOT invert the matrix locally! */ public final Mat22 invert() { final float a = ex.x, b = ey.x, c = ex.y, d = ey.y; final Mat22 B = new Mat22(); float det = a * d - b * c; if (det != 0) { det = 1.0f / det; } B.ex.x = det * d; B.ey.x = -det * b; B.ex.y = -det * c; B.ey.y = det * a; return B; }
/** * Add this matrix to B, return the result. * * @param B * @return */ public final Mat22 add(final Mat22 B) { // return new Mat22(ex.add(B.ex), col2.add(B.ey)); Mat22 m = new Mat22(); m.ex.x = ex.x + B.ex.x; m.ex.y = ex.y + B.ex.y; m.ey.x = ey.x + B.ey.x; m.ey.y = ey.y + B.ey.y; return m; }
protected Mat22 newInstance() { return new Mat22(); } };
public final static Mat22 createRotationalTransform(float angle) { Mat22 mat = new Mat22(); final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); mat.ex.x = c; mat.ey.x = -s; mat.ex.y = s; mat.ey.y = c; return mat; }
/** * Return the matrix composed of the absolute values of all elements. djm: fixed double allocation * * @return Absolute value matrix */ public final Mat22 abs() { return new Mat22(MathUtils.abs(ex.x), MathUtils.abs(ey.x), MathUtils.abs(ex.y), MathUtils.abs(ey.y)); }