blob: fa7d912459b905c1f6c9fb926c12e8be498e9950 [file] [log] [blame]
<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/geometry-interfaces-test-helpers.js"></script>
<script>
test(function() {
var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
var inverse = matrix2d.inverse();
assert_2d_matrix_equals(inverse, [-2, 1, 1.5, -0.5, 1, -2]);
}, "DOMMatrix inverse() - invertible - 2D matrix");
test(function() {
var matrix2d = new DOMMatrixReadOnly([1, 1, 1, 1, 1, 1]);
var inverse =matrix2d.inverse();
//when non invertible matrix execute invert(), result matrix is not 2d.
assert_3d_matrix_equals(inverse, [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]);
}, "DOMMatrix inverse() - non-invertible - 2D matrix");
test(function() {
var matrix3d = new DOMMatrixReadOnly([10, 20, 30, 40, 40, 40, 30, 20, 10, 20, 40, 30, 20, 40, 50, 100]);
var inverse = matrix3d.inverse();
assert_matrix_almost_equals(inverse, new DOMMatrix([-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]));
}, "DOMMatrix inverse() - invertible - 3D matrix");
test(function() {
var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
var inverse = matrix3d.inverse();
assert_3d_matrix_equals(inverse, [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]);
}, "DOMMatrix inverse() - non-invertible - 3D matrix");
</script>