Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | let q1 = quat4.create(); |
michael@0 | 7 | |
michael@0 | 8 | ok(q1, "Should have created a quaternion with quat4.create()."); |
michael@0 | 9 | is(q1.length, 4, "A quat4 should have 4 elements."); |
michael@0 | 10 | |
michael@0 | 11 | ok(isApproxVec(q1, [0, 0, 0, 1]), |
michael@0 | 12 | "When created, a vec3 should have the values default to identity."); |
michael@0 | 13 | |
michael@0 | 14 | quat4.set([1, 2, 3, 4], q1); |
michael@0 | 15 | ok(isApproxVec(q1, [1, 2, 3, 4]), |
michael@0 | 16 | "The quat4.set() function didn't set the values correctly."); |
michael@0 | 17 | |
michael@0 | 18 | quat4.identity(q1); |
michael@0 | 19 | ok(isApproxVec(q1, [0, 0, 0, 1]), |
michael@0 | 20 | "The quat4.identity() function didn't set the values correctly."); |
michael@0 | 21 | |
michael@0 | 22 | quat4.set([5, 6, 7, 8], q1); |
michael@0 | 23 | ok(isApproxVec(q1, [5, 6, 7, 8]), |
michael@0 | 24 | "The quat4.set() function didn't set the values correctly."); |
michael@0 | 25 | |
michael@0 | 26 | quat4.calculateW(q1); |
michael@0 | 27 | ok(isApproxVec(q1, [5, 6, 7, -10.440306663513184]), |
michael@0 | 28 | "The quat4.calculateW() function didn't compute the values correctly."); |
michael@0 | 29 | |
michael@0 | 30 | quat4.inverse(q1); |
michael@0 | 31 | ok(isApproxVec(q1, [-5, -6, -7, -10.440306663513184]), |
michael@0 | 32 | "The quat4.inverse() function didn't compute the values correctly."); |
michael@0 | 33 | |
michael@0 | 34 | quat4.normalize(q1); |
michael@0 | 35 | ok(isApproxVec(q1, [ |
michael@0 | 36 | -0.33786869049072266, -0.40544241666793823, |
michael@0 | 37 | -0.4730161726474762, -0.7054905295372009 |
michael@0 | 38 | ]), "The quat4.normalize() function didn't compute the values correctly."); |
michael@0 | 39 | |
michael@0 | 40 | ok(isApprox(quat4.length(q1), 1), |
michael@0 | 41 | "The mat4.length() function didn't calculate the value correctly."); |
michael@0 | 42 | } |