Skip to content

Commit

Permalink
#628 Completes Quaternion testing.
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Woolston <jwoolston@tenkiv.com>
  • Loading branch information
jwoolston committed Aug 27, 2016
1 parent ae8ead1 commit a6d1ee8
Show file tree
Hide file tree
Showing 8 changed files with 761 additions and 338 deletions.
19 changes: 5 additions & 14 deletions rajawali/src/main/java/org/rajawali3d/math/Matrix4.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ public Matrix4 rotate(final Quaternion quat) {
* @return A reference to this {@link Matrix4} to facilitate chaining.
*/
public Matrix4 rotate(final Vector3 axis, double angle) {
// TODO: Verify
return angle == 0 ? this : rotate(mQuat.fromAngleAxis(axis, angle));
}

Expand Down Expand Up @@ -627,12 +626,9 @@ public void rotateVector(final Vector3 vec) {
* @return {@link Vector3} The resulting vector.
*/
public Vector3 projectVector(final Vector3 vec) {
// TODO: Verify
double inv = 1.0 / (m[M03] * vec.x + m[M13] * vec.y + m[M23] * vec.z + m[M33]);
double x = (m[M00] * vec.x + m[M01] * vec.y + m[M02] * vec.z + m[M03]) * inv;
double y = (m[M10] * vec.x + m[M11] * vec.y + m[M12] * vec.z + m[M13]) * inv;
double z = (m[M20] * vec.x + m[M21] * vec.y + m[M22] * vec.z + m[M23]) * inv;
return vec.setAll(x, y, z);
double inv = 1.0 / (m[M30] * vec.x + m[M31] * vec.y + m[M32] * vec.z + m[M33]);
vec.multiply(m);
return vec.multiply(inv);
}

/**
Expand All @@ -644,13 +640,8 @@ public Vector3 projectVector(final Vector3 vec) {
* @return {@link Vector3} The resulting vector.
*/
public Vector3 projectAndCreateVector(final Vector3 vec) {
// TODO: Verify
Vector3 r = new Vector3();
double inv = 1.0 / (m[M03] * vec.x + m[M13] * vec.y + m[M23] * vec.z + m[M33]);
r.x = (m[M00] * vec.x + m[M01] * vec.y + m[M02] * vec.z + m[M03]) * inv;
r.y = (m[M10] * vec.x + m[M11] * vec.y + m[M12] * vec.z + m[M13]) * inv;
r.z = (m[M20] * vec.x + m[M21] * vec.y + m[M22] * vec.z + m[M23]) * inv;
return r;
Vector3 r = new Vector3(vec);
return projectVector(r);
}

/**
Expand Down
Loading

0 comments on commit a6d1ee8

Please sign in to comment.