aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-09-11 11:19:34 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-09-11 11:19:34 +0000
commite5c50afed6f0d7af099ea4a87a160451a706a186 (patch)
tree8b7319c1ae77f05c4dd832c87c7853d72bc1dddd /test
parent5e9ee8863e0ffe38551dcffb195a894129019a71 (diff)
* Quaternion: added dot product and angularDistance functions. The latter is
based on the former. * opengl_demo: makes IcoSphere better (vertices are instanciated only once) and removed the generation of a big geometry for the fancy spheres...
Diffstat (limited to 'test')
-rw-r--r--test/geometry.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/geometry.cpp b/test/geometry.cpp
index cb9726346..a87c8a2ad 100644
--- a/test/geometry.cpp
+++ b/test/geometry.cpp
@@ -48,6 +48,10 @@ template<typename Scalar> void geometry(void)
typedef Translation<Scalar,2> Translation2;
typedef Translation<Scalar,3> Translation3;
+ Scalar largeEps = test_precision<Scalar>();
+ if (ei_is_same_type<Scalar,float>::ret)
+ largeEps = 1e-3f;
+
Quaternion q1, q2;
Vector3 v0 = Vector3::Random(),
v1 = Vector3::Random(),
@@ -82,6 +86,12 @@ template<typename Scalar> void geometry(void)
q1 = AngleAxis(a, v0.normalized());
q2 = AngleAxis(a, v1.normalized());
+ // angular distance
+ Scalar refangle = ei_abs(AngleAxis(q1.inverse()*q2).angle());
+ if (refangle>M_PI)
+ refangle = 2.*M_PI - refangle;
+ VERIFY(ei_isApprox(q1.angularDistance(q2), refangle, largeEps));
+
// rotation matrix conversion
VERIFY_IS_APPROX(q1 * v2, q1.toRotationMatrix() * v2);
VERIFY_IS_APPROX(q1 * q2 * v2,