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