michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: let q1 = quat4.create([1, 2, 3, 4]); michael@0: let q2 = quat4.create([5, 6, 7, 8]); michael@0: michael@0: quat4.multiply(q1, q2); michael@0: ok(isApproxVec(q1, [24, 48, 48, -6]), michael@0: "The quat4.multiply() function didn't set the values correctly."); michael@0: michael@0: let v1 = quat4.multiplyVec3(q1, [9, 9, 9]); michael@0: ok(isApproxVec(v1, [5508, 54756, 59940]), michael@0: "The quat4.multiplyVec3() function didn't set the values correctly."); michael@0: michael@0: let m1 = quat4.toMat3(q1); michael@0: ok(isApproxVec(m1, [ michael@0: -9215, 2880, 1728, 1728, -5759, 4896, 2880, 4320, -5759 michael@0: ]), "The quat4.toMat3() function didn't set the values correctly."); michael@0: michael@0: let m2 = quat4.toMat4(q1); michael@0: ok(isApproxVec(m2, [ michael@0: -9215, 2880, 1728, 0, 1728, -5759, 4896, 0, michael@0: 2880, 4320, -5759, 0, 0, 0, 0, 1 michael@0: ]), "The quat4.toMat4() function didn't set the values correctly."); michael@0: michael@0: quat4.calculateW(q1); michael@0: quat4.calculateW(q2); michael@0: quat4.slerp(q1, q2, 0.5); michael@0: ok(isApproxVec(q1, [24, 48, 48, -71.99305725097656]), michael@0: "The quat4.slerp() function didn't set the values correctly."); michael@0: michael@0: let q3 = quat4.fromAxis([1, 1, 1], 0.5); michael@0: ok(isApproxVec(q3, [ michael@0: 0.24740396440029144, 0.24740396440029144, 0.24740396440029144, michael@0: 0.9689124226570129 michael@0: ]), "The quat4.fromAxis() function didn't compute the values correctly."); michael@0: michael@0: let q4 = quat4.fromEuler(0.5, 0.75, 1.25); michael@0: ok(isApproxVec(q4, [ michael@0: 0.15310347080230713, 0.39433568716049194, michael@0: 0.4540249705314636, 0.7841683626174927 michael@0: ]), "The quat4.fromEuler() function didn't compute the values correctly."); michael@0: michael@0: michael@0: is(quat4.str([1, 2, 3, 4]), "[1, 2, 3, 4]", michael@0: "The quat4.str() function didn't work properly."); michael@0: }