From 9b16c69efcca2942f1149ffb0373c89ecb5d280a Mon Sep 17 00:00:00 2001 From: Florian Enner Date: Sun, 5 Jan 2014 10:46:46 -0500 Subject: [PATCH] matched axis angle convention (deg) --- jzy3d-api/src/api/org/jzy3d/maths/Coord3d.java | 9 +++++---- jzy3d-api/src/tests/org/jzy3d/tests/Coord3dTest.java | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/jzy3d-api/src/api/org/jzy3d/maths/Coord3d.java b/jzy3d-api/src/api/org/jzy3d/maths/Coord3d.java index 46121d0e..8bc8c9f1 100644 --- a/jzy3d-api/src/api/org/jzy3d/maths/Coord3d.java +++ b/jzy3d-api/src/api/org/jzy3d/maths/Coord3d.java @@ -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); diff --git a/jzy3d-api/src/tests/org/jzy3d/tests/Coord3dTest.java b/jzy3d-api/src/tests/org/jzy3d/tests/Coord3dTest.java index c4b060b9..92abb07c 100644 --- a/jzy3d-api/src/tests/org/jzy3d/tests/Coord3dTest.java +++ b/jzy3d-api/src/tests/org/jzy3d/tests/Coord3dTest.java @@ -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)); }