OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | |
3 <head> | |
4 <title>Geometry Interfaces: DOMMatrixReadOnly inverse</title> | |
5 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
7 </head> | 4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> |
8 <body> | |
9 <script> | 5 <script> |
10 test(function() { | 6 test(function() { |
11 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); | 7 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
12 var inverse = matrix2d.inverse(); | 8 var inverse = matrix2d.inverse(); |
13 assert_true(inverse.is2D); | 9 assert_2d_matrix_equals(inverse, [-2, 1, 1.5, -0.5, 1, -2]); |
14 assert_equals(inverse.a, -2); | |
15 assert_equals(inverse.b, 1); | |
16 assert_equals(inverse.c, 1.5); | |
17 assert_equals(inverse.d, -0.5); | |
18 assert_equals(inverse.e, 1); | |
19 assert_equals(inverse.f, -2); | |
20 }, "DOMMatrix inverse() - invertible - 2D matrix"); | 10 }, "DOMMatrix inverse() - invertible - 2D matrix"); |
21 | 11 |
22 test(function() { | 12 test(function() { |
23 var matrix2d = new DOMMatrixReadOnly([1, 1, 1, 1, 1, 1]); | 13 var matrix2d = new DOMMatrixReadOnly([1, 1, 1, 1, 1, 1]); |
24 var inverse =matrix2d.inverse(); | 14 var inverse =matrix2d.inverse(); |
25 assert_false(inverse.is2D); | 15 //when non invertible matrix execute invert(), result matrix is not 2d. |
26 assert_equals(inverse.a, NaN); | 16 assert_3d_matrix_equals(inverse, [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
NaN, NaN, NaN, NaN, NaN, NaN, NaN]); |
27 assert_equals(inverse.b, NaN); | 17 }, "DOMMatrix inverse() - non-invertible - 2D matrix"); |
28 assert_equals(inverse.c, NaN); | |
29 assert_equals(inverse.d, NaN); | |
30 assert_equals(inverse.e, NaN); | |
31 assert_equals(inverse.f, NaN); | |
32 }, "DOMMatrix inverse() - uninvertible - 2D matrix"); | |
33 | 18 |
34 test(function() { | 19 test(function() { |
35 var matrix3d = new DOMMatrixReadOnly([10, 20, 30, 40, 40, 40, 30, 20, 10, 20
, 40, 30, 20, 40, 50, 100]); | 20 var matrix3d = new DOMMatrixReadOnly([10, 20, 30, 40, 40, 40, 30, 20, 10, 20,
40, 30, 20, 40, 50, 100]); |
36 var inverse = matrix3d.inverse(); | 21 var inverse = matrix3d.inverse(); |
37 assert_false(inverse.is2D); | 22 assert_3d_matrix_equals(inverse, [-1.6, 0.05, 0.6, 0.45, 2.05, -0.025, -0.8, -
0.575, -0.4, 0, 0.2, 0.1, -0.3, 0, 0.1, 0.1]); |
38 assert_equals(inverse.m11, -1.6); | |
39 assert_equals(inverse.m12, 0.05); | |
40 assert_equals(inverse.m13, 0.6); | |
41 assert_equals(inverse.m14, 0.45); | |
42 assert_equals(inverse.m21, 2.05); | |
43 assert_equals(inverse.m22, -0.025); | |
44 assert_equals(inverse.m23, -0.8); | |
45 assert_equals(inverse.m24, -0.575); | |
46 assert_equals(inverse.m31, -0.4); | |
47 assert_equals(inverse.m32, 0); | |
48 assert_equals(inverse.m33, 0.2); | |
49 assert_equals(inverse.m34, 0.1); | |
50 assert_equals(inverse.m41, -0.3); | |
51 assert_equals(inverse.m42, -0); | |
52 assert_equals(inverse.m43, 0.1); | |
53 assert_equals(inverse.m44, 0.1); | |
54 }, "DOMMatrix inverse() - invertible - 3D matrix"); | 23 }, "DOMMatrix inverse() - invertible - 3D matrix"); |
55 | 24 |
56 test(function() { | 25 test(function() { |
57 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16]); | 26 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
58 var inverse = matrix3d.inverse(); | 27 var inverse = matrix3d.inverse(); |
59 assert_false(inverse.is2D); | 28 assert_3d_matrix_equals(inverse, [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
NaN, NaN, NaN, NaN, NaN, NaN, NaN]); |
60 assert_equals(inverse.m11, NaN); | 29 }, "DOMMatrix inverse() - non-invertible - 3D matrix"); |
61 assert_equals(inverse.m12, NaN); | |
62 assert_equals(inverse.m13, NaN); | |
63 assert_equals(inverse.m14, NaN); | |
64 assert_equals(inverse.m21, NaN); | |
65 assert_equals(inverse.m22, NaN); | |
66 assert_equals(inverse.m23, NaN); | |
67 assert_equals(inverse.m24, NaN); | |
68 assert_equals(inverse.m31, NaN); | |
69 assert_equals(inverse.m32, NaN); | |
70 assert_equals(inverse.m33, NaN); | |
71 assert_equals(inverse.m34, NaN); | |
72 assert_equals(inverse.m41, NaN); | |
73 assert_equals(inverse.m42, NaN); | |
74 assert_equals(inverse.m43, NaN); | |
75 assert_equals(inverse.m44, NaN); | |
76 }, "DOMMatrix inverse() - uninvertible - 3D matrix"); | |
77 </script> | 30 </script> |
78 </body> | |
79 </html> | |
OLD | NEW |