browser/devtools/tilt/test/browser_tilt_math07.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     3 "use strict";
     5 function test() {
     6   let q1 = quat4.create([1, 2, 3, 4]);
     7   let q2 = quat4.create([5, 6, 7, 8]);
     9   quat4.multiply(q1, q2);
    10   ok(isApproxVec(q1, [24, 48, 48, -6]),
    11     "The quat4.multiply() function didn't set the values correctly.");
    13   let v1 = quat4.multiplyVec3(q1, [9, 9, 9]);
    14   ok(isApproxVec(v1, [5508, 54756, 59940]),
    15     "The quat4.multiplyVec3() function didn't set the values correctly.");
    17   let m1 = quat4.toMat3(q1);
    18   ok(isApproxVec(m1, [
    19     -9215, 2880, 1728, 1728, -5759, 4896, 2880, 4320, -5759
    20   ]), "The quat4.toMat3() function didn't set the values correctly.");
    22   let m2 = quat4.toMat4(q1);
    23   ok(isApproxVec(m2, [
    24     -9215, 2880, 1728, 0, 1728, -5759, 4896, 0,
    25     2880, 4320, -5759, 0, 0, 0, 0, 1
    26   ]), "The quat4.toMat4() function didn't set the values correctly.");
    28   quat4.calculateW(q1);
    29   quat4.calculateW(q2);
    30   quat4.slerp(q1, q2, 0.5);
    31   ok(isApproxVec(q1, [24, 48, 48, -71.99305725097656]),
    32     "The quat4.slerp() function didn't set the values correctly.");
    34   let q3 = quat4.fromAxis([1, 1, 1], 0.5);
    35   ok(isApproxVec(q3, [
    36     0.24740396440029144, 0.24740396440029144, 0.24740396440029144,
    37     0.9689124226570129
    38   ]), "The quat4.fromAxis() function didn't compute the values correctly.");
    40   let q4 = quat4.fromEuler(0.5, 0.75, 1.25);
    41   ok(isApproxVec(q4, [
    42     0.15310347080230713, 0.39433568716049194,
    43     0.4540249705314636, 0.7841683626174927
    44   ]), "The quat4.fromEuler() function didn't compute the values correctly.");
    47   is(quat4.str([1, 2, 3, 4]), "[1, 2, 3, 4]",
    48     "The quat4.str() function didn't work properly.");
    49 }

mercurial