Skip to content

Commit

Permalink
Fix Matrix4 rotation between
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Henrique committed Nov 7, 2016
1 parent c02e98c commit 8fd2708
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tracer/data/base/Matrix4.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public static Matrix4 mul(Matrix4 m1, Matrix4 m2) {
*/
public static Matrix4 compose(Matrix4... ms) {
if (ms.length == 0) {
throw new IllegalArgumentException();
throw new IllegalArgumentException("The compose method should receive at least one matrix.");
}
Matrix4 result = ms[0].copy();
for (int i = 1; i < ms.length; i++) {
Expand Down Expand Up @@ -746,16 +746,17 @@ public static Matrix4 rotationAround(Vector3 axis, float angle) {

/**
* Returns the rotation between two vectors.
*
* @param from the from direction vector
* @param to the to direction vector
* @param to the to direction vector
* @return the rotation matrix
*/
public static Matrix4 rotationBetween(Vector3 from, Vector3 to) {
if (from.dot(to) == 0) {
return identity();
}
Vector3 axis = Vector3.cross(from, to);
float angle = from.cos(to);
float angle = from.angle(to);
return rotationAround(axis, angle);
}

Expand Down

0 comments on commit 8fd2708

Please sign in to comment.