1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_math06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +"use strict"; 1.7 + 1.8 +function test() { 1.9 + let q1 = quat4.create(); 1.10 + 1.11 + ok(q1, "Should have created a quaternion with quat4.create()."); 1.12 + is(q1.length, 4, "A quat4 should have 4 elements."); 1.13 + 1.14 + ok(isApproxVec(q1, [0, 0, 0, 1]), 1.15 + "When created, a vec3 should have the values default to identity."); 1.16 + 1.17 + quat4.set([1, 2, 3, 4], q1); 1.18 + ok(isApproxVec(q1, [1, 2, 3, 4]), 1.19 + "The quat4.set() function didn't set the values correctly."); 1.20 + 1.21 + quat4.identity(q1); 1.22 + ok(isApproxVec(q1, [0, 0, 0, 1]), 1.23 + "The quat4.identity() function didn't set the values correctly."); 1.24 + 1.25 + quat4.set([5, 6, 7, 8], q1); 1.26 + ok(isApproxVec(q1, [5, 6, 7, 8]), 1.27 + "The quat4.set() function didn't set the values correctly."); 1.28 + 1.29 + quat4.calculateW(q1); 1.30 + ok(isApproxVec(q1, [5, 6, 7, -10.440306663513184]), 1.31 + "The quat4.calculateW() function didn't compute the values correctly."); 1.32 + 1.33 + quat4.inverse(q1); 1.34 + ok(isApproxVec(q1, [-5, -6, -7, -10.440306663513184]), 1.35 + "The quat4.inverse() function didn't compute the values correctly."); 1.36 + 1.37 + quat4.normalize(q1); 1.38 + ok(isApproxVec(q1, [ 1.39 + -0.33786869049072266, -0.40544241666793823, 1.40 + -0.4730161726474762, -0.7054905295372009 1.41 + ]), "The quat4.normalize() function didn't compute the values correctly."); 1.42 + 1.43 + ok(isApprox(quat4.length(q1), 1), 1.44 + "The mat4.length() function didn't calculate the value correctly."); 1.45 +}