/** * Linearly interpolates between this {@link Matrix4} and the given {@link Matrix4} by the given * factor. * * @param matrix {@link Matrix4} The other matrix. * @param t {@code double} The interpolation ratio. The result is weighted to this value on the * {@link Matrix4}. * @return A reference to this {@link Matrix4} to facilitate chaining. */ @NonNull public Matrix4 lerp(@NonNull Matrix4 matrix, double t) { matrix.toArray(mTmp); for (int i = 0; i < 16; ++i) { m[i] = m[i] * (1.0 - t) + t * mTmp[i]; } return this; }
/** * Adds the given {@link Matrix4} to this one. * * @param matrix {@link Matrix4} The matrix to add. * @return A reference to this {@link Matrix4} to facilitate chaining. */ @NonNull public Matrix4 add(@NonNull Matrix4 matrix) { // @formatter:off matrix.toArray(mTmp); m[0] += mTmp[0]; m[1] += mTmp[1]; m[2] += mTmp[2]; m[3] += mTmp[3]; m[4] += mTmp[4]; m[5] += mTmp[5]; m[6] += mTmp[6]; m[7] += mTmp[7]; m[8] += mTmp[8]; m[9] += mTmp[9]; m[10] += mTmp[10]; m[11] += mTmp[11]; m[12] += mTmp[12]; m[13] += mTmp[13]; m[14] += mTmp[14]; m[15] += mTmp[15]; return this; // @formatter:on }
/** * Subtracts the given {@link Matrix4} to this one. * * @param matrix {@link Matrix4} The matrix to subtract. * @return A reference to this {@link Matrix4} to facilitate chaining. */ @NonNull public Matrix4 subtract(@NonNull Matrix4 matrix) { // @formatter:off matrix.toArray(mTmp); m[0] -= mTmp[0]; m[1] -= mTmp[1]; m[2] -= mTmp[2]; m[3] -= mTmp[3]; m[4] -= mTmp[4]; m[5] -= mTmp[5]; m[6] -= mTmp[6]; m[7] -= mTmp[7]; m[8] -= mTmp[8]; m[9] -= mTmp[9]; m[10] -= mTmp[10]; m[11] -= mTmp[11]; m[12] -= mTmp[12]; m[13] -= mTmp[13]; m[14] -= mTmp[14]; m[15] -= mTmp[15]; return this; // @formatter:on }
/** * Sets the elements of this {@link Matrix4} based on the elements of the provided {@link * Matrix4}. * * @param matrix {@link Matrix4} to copy. * @return A reference to this {@link Matrix4} to facilitate chaining. */ @NonNull public Matrix4 setAll(@NonNull Matrix4 matrix) { matrix.toArray(m); return this; }