Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
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([1, 2, 3, 4]); |
michael@0 | 7 | let q2 = quat4.create([5, 6, 7, 8]); |
michael@0 | 8 | |
michael@0 | 9 | quat4.multiply(q1, q2); |
michael@0 | 10 | ok(isApproxVec(q1, [24, 48, 48, -6]), |
michael@0 | 11 | "The quat4.multiply() function didn't set the values correctly."); |
michael@0 | 12 | |
michael@0 | 13 | let v1 = quat4.multiplyVec3(q1, [9, 9, 9]); |
michael@0 | 14 | ok(isApproxVec(v1, [5508, 54756, 59940]), |
michael@0 | 15 | "The quat4.multiplyVec3() function didn't set the values correctly."); |
michael@0 | 16 | |
michael@0 | 17 | let m1 = quat4.toMat3(q1); |
michael@0 | 18 | ok(isApproxVec(m1, [ |
michael@0 | 19 | -9215, 2880, 1728, 1728, -5759, 4896, 2880, 4320, -5759 |
michael@0 | 20 | ]), "The quat4.toMat3() function didn't set the values correctly."); |
michael@0 | 21 | |
michael@0 | 22 | let m2 = quat4.toMat4(q1); |
michael@0 | 23 | ok(isApproxVec(m2, [ |
michael@0 | 24 | -9215, 2880, 1728, 0, 1728, -5759, 4896, 0, |
michael@0 | 25 | 2880, 4320, -5759, 0, 0, 0, 0, 1 |
michael@0 | 26 | ]), "The quat4.toMat4() function didn't set the values correctly."); |
michael@0 | 27 | |
michael@0 | 28 | quat4.calculateW(q1); |
michael@0 | 29 | quat4.calculateW(q2); |
michael@0 | 30 | quat4.slerp(q1, q2, 0.5); |
michael@0 | 31 | ok(isApproxVec(q1, [24, 48, 48, -71.99305725097656]), |
michael@0 | 32 | "The quat4.slerp() function didn't set the values correctly."); |
michael@0 | 33 | |
michael@0 | 34 | let q3 = quat4.fromAxis([1, 1, 1], 0.5); |
michael@0 | 35 | ok(isApproxVec(q3, [ |
michael@0 | 36 | 0.24740396440029144, 0.24740396440029144, 0.24740396440029144, |
michael@0 | 37 | 0.9689124226570129 |
michael@0 | 38 | ]), "The quat4.fromAxis() function didn't compute the values correctly."); |
michael@0 | 39 | |
michael@0 | 40 | let q4 = quat4.fromEuler(0.5, 0.75, 1.25); |
michael@0 | 41 | ok(isApproxVec(q4, [ |
michael@0 | 42 | 0.15310347080230713, 0.39433568716049194, |
michael@0 | 43 | 0.4540249705314636, 0.7841683626174927 |
michael@0 | 44 | ]), "The quat4.fromEuler() function didn't compute the values correctly."); |
michael@0 | 45 | |
michael@0 | 46 | |
michael@0 | 47 | is(quat4.str([1, 2, 3, 4]), "[1, 2, 3, 4]", |
michael@0 | 48 | "The quat4.str() function didn't work properly."); |
michael@0 | 49 | } |