browser/devtools/tilt/test/browser_tilt_math06.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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 }

mercurial