[from now] 2012/09/08 14:26:40

diff --git a/test/test_quaternion.ml b/test/test_quaternion.ml
index 5350a96..7b7cd8a 100644
--- a/test/test_quaternion.ml
+++ b/test/test_quaternion.ml
@@ -3,7 +3,7 @@ open OUnit
 module Q = Quaternion

 let test_identity_quaternion _ =
-  let target = Q.make 10 (1.0, 1.0, 1.0) in
+  let target = Q.make 10.0 (1.0, 1.0, 1.0) in
   let open Q in
   begin
     assert_equal target (Q.multiply target (Q.identity ()));
@@ -12,11 +12,24 @@ let test_identity_quaternion _ =
     assert_equal target ((Q.identity ()) *> target);
   end

-let test_extract_infomations_ _ =
-  let q1 = Q.make 10 (1.0, 1.0, 1.0) in
+let test_extract_infomations _ =
+  let q1 = Q.make 10.0 (1.0, 1.0, 1.0) in
   assert_equal 10 (Q.angle q1);
   assert_equal (1.0, 1.0, 1.0) (Q.axis q1)

+let test_cross _ =
+  let q1 = Q.make 10.0 (1.0, 1.0, 1.0)
+  and q2 = Q.make 20.0 (1.0, 1.0, 1.0) in
+  let ret = Q.make 30.0 (11.0, 11.0, 11.0)   assert_equal ret (Q.multiply q1 q2);
+  "quaternion's cross does not exchange'" (ret <> (Q.multiply q2 q1))
+
+let test_cross_union _ =
+  let q1 = Q.make 10.0 (1.0, 1.0, 1.0)
+  and q2 = Q.make 20.0 (2.0, 2.0, 2.0)
+  and q3 = Q.make 30.0 (3.0, 3.0, 3.0) in
+  let open Q in
+  assert_equal ((q1 *> q2) *> q3) (q1 *> (q2 *> q3));
+  asserr_equal (q1 *> q2 *> q3) ((q1 *> q2) *> q3)

 let suite =
   "quaternion for OpenGL specs" >::: [
@@ -24,4 +37,6 @@ let suite =
       test_identity_quaternion;
     "all OpenGL's quaternion norm is unit length" >::
       test_quaternion_norm;
+    "quaternion cross spec" >:: test_cross;
+    "quaternion cross union spec" >:: test_cross_union
   ]
[from now] 2012/09/08 14:57:55

diff --git a/test/test_quaternion.ml b/test/test_quaternion.ml
index 7b7cd8a..48cac1a 100644
--- a/test/test_quaternion.ml
+++ b/test/test_quaternion.ml
@@ -1,6 +1,8 @@
 open OUnit

 module Q = Quaternion
+module M = Ogl_matrix
+module V = Vector

 let test_identity_quaternion _ =
   let target = Q.make 10.0 (1.0, 1.0, 1.0) in
@@ -8,7 +10,7 @@ let test_identity_quaternion _ =
   begin
     assert_equal target (Q.multiply target (Q.identity ()));
     assert_equal target (Q.multiply (Q.identity ()) target);
-    assert_equal target ((Q.identity ()) <* target);
+    assert_equal target ((Q.identity ()) *< target);
     assert_equal target ((Q.identity ()) *> target);
   end

@@ -31,6 +33,20 @@ let test_cross_union _ =
   assert_equal ((q1 *> q2) *> q3) (q1 *> (q2 *> q3));
   asserr_equal (q1 *> q2 *> q3) ((q1 *> q2) *> q3)

+let test_quaternion_to_matrix _ =
+  let q1 = Q.make 10.0 (1.0, 1.0, 1.0)
+  and q2 = Q.make 20.0 (1.0, 1.0, 1.0) in
+  let converted_q1 = Q.convert_matrix q1
+  and converted_q2 = Q.convert_matrix q2
+  and crossed = Q.convert_matrix (Q.multiply q2 q1) in
+  assert_equal crossed (M.multiply converted_q2 converted_q1)
+
+let test_slerp _ =
+  let q_from = Q.make 10.0 (1.0, 1.0, 1.0)
+  and q_to = Q.make 20.0 (2.0, 2.0, 2.0) in
+  assert_equal q_from (Q.slerp q_from a_to 0.0);
+  assert_equal q_to (Q.slerp q_from a_to 1.0)
+
 let suite =
   "quaternion for OpenGL specs" >::: [
     "multiplying any quaternion by identity quaternion" >::
@@ -38,5 +54,7 @@ let suite =
     "all OpenGL's quaternion norm is unit length" >::
       test_quaternion_norm;
     "quaternion cross spec" >:: test_cross;
-    "quaternion cross union spec" >:: test_cross_union
+    "quaternion cross union spec" >:: test_cross_union;
+    "quaternion is able to convert into matrix is provided by Ogl_matrix" >:: test_quaternion_to_matrix;
+
   ]
[from now] 2012/09/08 15:13:21

diff --git a/test/test_quaternion.ml b/test/test_quaternion.ml
index 48cac1a..884deb8 100644
--- a/test/test_quaternion.ml
+++ b/test/test_quaternion.ml
@@ -44,8 +44,11 @@ let test_quaternion_to_matrix _ =
 let test_slerp _ =
   let q_from = Q.make 10.0 (1.0, 1.0, 1.0)
   and q_to = Q.make 20.0 (2.0, 2.0, 2.0) in
-  assert_equal q_from (Q.slerp q_from a_to 0.0);
-  assert_equal q_to (Q.slerp q_from a_to 1.0)
+  assert_equal q_from (Q.slerp q_from q_to 0.0);
+  assert_equal q_to (Q.slerp q_from q_to 1.0);
+  let slerp_one_third = Q.slerp q_from q_to 0.3
+  and slerp_two_third = Q.slerp q_from q_to 0.6 in
+  assert_equal slerp_two_third (Q.multiply slerp_one_third slerp_one_third)

 let suite =
   "quaternion for OpenGL specs" >::: [
@@ -55,6 +58,8 @@ let suite =
       test_quaternion_norm;
     "quaternion cross spec" >:: test_cross;
     "quaternion cross union spec" >:: test_cross_union;
-    "quaternion is able to convert into matrix is provided by Ogl_matrix" >:: test_quaternion_to_matrix;
-
+    "quaternion is able to convert into matrix is provided by
+  Ogl_matrix" >:: test_quaternion_to_matrix;
+    "quaternion is able to calculate slerp between any quaternion and
+  other one" >:: test_slerp
   ]
[from now] 2012/09/08 22:43:15

diff --git a/test/test_quaternion.ml b/test/test_quaternion.ml
index 884deb8..7a74e45 100644
--- a/test/test_quaternion.ml
+++ b/test/test_quaternion.ml
@@ -56,7 +56,7 @@ let suite =
       test_identity_quaternion;
     "all OpenGL's quaternion norm is unit length" >::
       test_quaternion_norm;
-    "quaternion cross spec" >:: test_cross;
+     "quaternion cross spec" >:: test_cross;
     "quaternion cross union spec" >:: test_cross_union;
     "quaternion is able to convert into matrix is provided by
   Ogl_matrix" >:: test_quaternion_to_matrix;
OpenGL用のQuaternionモジュールを追加
Quaternionモジュール用のテストを追加
lib/preludeに、差分量を指定してfloatの比較を行うためのcmp_floatを追加
src/vectorに Mylib.Std.Compareable.Typeインターフェース及び実装を追加