matched axis angle convention (deg)

This commit is contained in:
Florian Enner 2014-01-05 10:46:46 -05:00
parent fea710c386
commit 9b16c69efc
2 changed files with 8 additions and 7 deletions

View File

@ -331,13 +331,14 @@ public class Coord3d {
* math implemented using
* http://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
*
* @param angle angle of rotation about the given axis [rad]
* @param angleDeg angle of rotation about the given axis [deg]
* @param axis unit vector describing an axis of rotation
* @return rotated copy of the original vector
*/
public final Coord3d rotate(float angle, Coord3d axis) {
float s = (float) Math.sin(angle);
float c = (float) Math.cos(angle);
public final Coord3d rotate(float angleDeg, Coord3d axis) {
float angleRad = (float) Math.toRadians(angleDeg);
float s = (float) Math.sin(angleRad);
float c = (float) Math.cos(angleRad);
Coord3d v = this;
Coord3d k = axis.normalizeTo(1f);

View File

@ -29,7 +29,7 @@ public class Coord3dTest extends TestCase {
public void testRotateX() throws Exception {
Coord3d input = new Coord3d(0, 1, 0);
Coord3d axis = new Coord3d(1, 0, 0);
float angle = (float) Math.PI / 2;
float angle = 90f;
Coord3d expected = new Coord3d(0, 0, 1);
assertEqualCoord(expected, input.rotate(angle, axis));
}
@ -37,7 +37,7 @@ public class Coord3dTest extends TestCase {
public void testRotateY() throws Exception {
Coord3d input = new Coord3d(1, 0, 0);
Coord3d axis = new Coord3d(0, 1, 0);
float angle = (float) Math.PI / 2;
float angle = 90f;
Coord3d expected = new Coord3d(0, 0, -1);
assertEqualCoord(expected, input.rotate(angle, axis));
}
@ -45,7 +45,7 @@ public class Coord3dTest extends TestCase {
public void testRotateZ() throws Exception {
Coord3d input = new Coord3d(0, 1, 0);
Coord3d axis = new Coord3d(0, 0, 1);
float angle = (float) Math.PI / 2;
float angle = 90f;
Coord3d expected = new Coord3d(-1, 0, 0);
assertEqualCoord(expected, input.rotate(angle, axis));
}