/** * Sets this matrix to the identity matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToIdentity () { return set(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f); }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTransform (IVector translation, float rotation, float scale) { return setToRotation(rotation).set(m00 * scale, m10 * scale, translation.x(), m01 * scale, m11 * scale, translation.y(), 0f, 0f, 1f); }
/** * Creates a matrix from its components. */ public Matrix3 (float m00, float m10, float m20, float m01, float m11, float m21, float m02, float m12, float m22) { set(m00, m10, m20, m01, m11, m21, m02, m12, m22); }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTransform (IVector translation, float rotation, float scale) { return setToRotation(rotation).set(m00 * scale, m10 * scale, translation.x(), m01 * scale, m11 * scale, translation.y(), 0f, 0f, 1f); }
/** * Copy constructor. */ public Matrix3 (Matrix3 other) { set(other); }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTransform (IVector translation, float rotation, IVector scale) { float sx = scale.x(), sy = scale.y(); return setToRotation(rotation).set(m00 * sx, m10 * sy, translation.x(), m01 * sx, m11 * sy, translation.y(), 0f, 0f, 1f); }
/** * Copies the elements of an array. * * @return a reference to this matrix, for chaining. */ public Matrix3 set (float[] values) { return set(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8]); }
@Override // from IMatrix3 public Matrix3 transpose (Matrix3 result) { return result.set(m00, m01, m02, m10, m11, m12, m20, m21, m22); }
/** * Sets this to a scale matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToScale (float x, float y, float z) { return set(x, 0f, 0f, 0f, y, 0f, 0f, 0f, z); }
/** * Sets this to a translation matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTranslation (float x, float y) { return set(1f, 0f, x, 0f, 1f, y, 0f, 0f, 1f); }
@Override // from IMatrix4 public Matrix3 extractRotationScale (Matrix3 result) { return result.set(m00, m01, m02, m10, m11, m12, m20, m21, m22); }
/** * Creates a matrix from an array of values. */ public Matrix3 (float[] values) { set(values); }
/** * Sets this matrix to all zeroes. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToZero () { return set(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f); }
/** * Sets this to a reflection across a plane intersecting the origin with the supplied normal. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToReflection (float x, float y, float z) { float x2 = -2f*x, y2 = -2f*y, z2 = -2f*z; float xy2 = x2*y, xz2 = x2*z, yz2 = y2*z; return set(1f + x2*x, xy2, xz2, xy2, 1f + y2*y, yz2, xz2, yz2, 1f + z2*z); }
@Override // from IMatrix4 public Matrix3 extractRotationScale (Matrix3 result) { return result.set(m00, m01, m02, m10, m11, m12, m20, m21, m22); }
/** * Creates a matrix from an array of values. */ public Matrix3 (float[] values) { set(values); }
/** * Sets this to a rotation matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToRotation (float angle) { float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return set(cosa, -sina, 0f, sina, cosa, 0f, 0f, 0f, 1f); }
@Override // from IMatrix3 public Matrix3 add (IMatrix3 other, Matrix3 result) { return result.set(m00 + other.m00(), m01 + other.m01(), m02 + other.m02(), m10 + other.m10(), m11 + other.m11(), m12 + other.m12(), m20 + other.m20(), m21 + other.m21(), m22 + other.m22()); }
/** * Copies the contents of another matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 set (IMatrix3 other) { return set(other.m00(), other.m10(), other.m20(), other.m01(), other.m11(), other.m21(), other.m02(), other.m12(), other.m22()); }
/** * Copies the contents of another matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 set (IMatrix3 other) { return set(other.m00(), other.m10(), other.m20(), other.m01(), other.m11(), other.m21(), other.m02(), other.m12(), other.m22()); }