chromium/third_party/blink/web_tests/fast/dom/geometry-interfaces-dom-matrix-rotate.html

<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/geometry-interfaces-test-helpers.js"></script>
<script>

function deg2rad(degrees) {
  return degrees * Math.PI / 180;
}

function rad2deg(radians) {
  return radians * 180 / Math.PI;
}

function getRotationMatrix(x, y, z, alpha_in_degrees) {
  // Vector normalizing
  var nx = x;
  var ny = y;
  var nz = z;
  var length = Math.sqrt(x * x + y * y + z * z);
  if (length) {
    nx = x / length;
    ny = y / length;
    nz = z / length;
  }

  // The 3D rotation matrix is described in CSS Transforms with alpha.
  // Please see: https://drafts.csswg.org/css-transforms-1/#Rotate3dDefined
  var alpha_in_radians = deg2rad(alpha_in_degrees / 2);
  var sc = Math.sin(alpha_in_radians) * Math.cos(alpha_in_radians);
  var sq = Math.sin(alpha_in_radians) * Math.sin(alpha_in_radians);

  var m11 = 1 - 2 * (ny * ny + nz * nz) * sq;
  var m12 = 2 * (nx * ny * sq + nz * sc);
  var m13 = 2 * (nx * nz * sq - ny * sc);
  var m14 = 0;
  var m21 = 2 * (nx * ny * sq - nz * sc);
  var m22 = 1 - 2 * (nx * nx + nz * nz) * sq;
  var m23 = 2 * (ny * nz * sq + nx * sc);
  var m24 = 0;
  var m31 = 2 * (nx * nz * sq + ny * sc);
  var m32 = 2 * (ny * nz * sq - nx * sc);
  var m33 = 1 - 2 * (nx * nx + ny * ny) * sq;
  var m34 = 0;
  var m41 = 0;
  var m42 = 0;
  var m43 = 0;
  var m44 = 1;

  return new DOMMatrix([m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44]);
}

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  var rotateResult = matrix.rotate(60);
  matrix.rotateSelf(60);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 60));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 2d - rotate(rotX) and rotateSelf(rotX)");

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  var rotateResult = matrix.rotate(77);
  matrix.rotateSelf(77);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 77));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 3d - rotate(rotX) and rotateSelf(rotX)");

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  var rotateResult = matrix.rotate(10, 20);
  matrix.rotateSelf(10, 20);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 20));
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 10));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 2d - rotate(rotX, rotY) and rotateSelf(rotX, rotY)");

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  var rotateResult = matrix.rotate(23, 50);
  matrix.rotateSelf(23, 50);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 50));
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 23));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 3d - rotate(rotX, rotY) and rotateSelf(rotX, rotY)");

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  var rotateResult = matrix.rotate(39, 10, 50);
  matrix.rotateSelf(39, 10, 50);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 50));
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 10));
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 39));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 2d - rotate(rotX, rotY, rotX) and rotateSelf(rotX, rotY, rotX)");

test(() => {
  var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  var rotateResult = matrix.rotate(55, 66, 88);
  matrix.rotateSelf(55, 66, 88);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 88));
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 66));
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 55));
  assert_matrix_almost_equals(rotateResult, expectedResult);
  assert_matrix_almost_equals(matrix, expectedResult);
}, "DOMMatrix 3d - rotate(rotX, rotY, rotX) and rotateSelf(rotX, rotY, rotX)");

test(function() {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  var rotateResult = matrix2d.rotateFromVector(4, 7);
  var expected = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expected.rotateSelf(rad2deg(Math.atan2(7, 4)));
  assert_matrix_almost_equals(rotateResult, expected);
  matrix2d.rotateFromVectorSelf(4, 7);
  assert_matrix_almost_equals(matrix2d, expected);
}, "DOMMatrix 2d - rotateFromVector(x, y) and rotateFromVectorSelf(x, y)");

test(function() {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  var rotateResult = matrix3d.rotateFromVector(4, 7);
  var expected = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expected.rotateSelf(rad2deg(Math.atan2(7, 4)));
  assert_matrix_almost_equals(rotateResult, expected);
  matrix3d.rotateFromVectorSelf(4, 7);
  assert_matrix_almost_equals(matrix3d, expected);
}, "DOMMatrix 3d - rotateFromVector(x, y) rotateFromVectorSelf(x, y)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf();
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 0, 0));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf()");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(0, 0, 1);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 0));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(0, 0, 1)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(1, 1, 1);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(1, 1, 1, 0));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(1, 1, 1, 0)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(1, 0, 0, 10);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 10));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(1, 0, 0, 10)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(0, 1, 0, 27);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 27));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(0, 1, 0, 27)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(0, 0, 1, 38);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 38));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(0, 0, 1, 38)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(1, 1, 1, 45);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  expectedResult.multiplySelf(getRotationMatrix(1, 1, 1, 45));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf(1, 1, 1, 45)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf();
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 0, 0));
    assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf()");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(0, 0, 1);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(0, 0, 1, 0);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1, 0)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(1, 0, 0, 19);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(1, 0, 0, 19));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(1, 0, 0, 19)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(0, 1, 0, 46);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 1, 0, 46));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(0, 1, 0, 46)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(0, 0, 1, 65);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(0, 0, 1, 65));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1, 65)");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(1, 1, 1, 67);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult.multiplySelf(getRotationMatrix(1, 1, 1, 67));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf(1, 1, 1, 67)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle();
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 0, 0));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle()");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(0, 0, 1);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 1, 0));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 0, 1)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(1, 1, 1);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 1, 1, 0));
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 1, 1, 0)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(1, 0, 0, 21);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 0, 0, 21));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 0, 0, 21)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, 35);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 1, 0, 35));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 1, 0, 35)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(0, 0, 1, 55);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 1, 55));
  assert_true(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 0, 1, 55)");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(1, 1, 1, 75);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 1, 1, 75));
  assert_false(matrix2d.is2D);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 1, 1, 75)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle();
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 0, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle()");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(0, 0, 1);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 1, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, 0);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 1, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1, 0)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, 0);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 1, 1, 0));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 1, 1, 0)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(1, 0, 0, 105);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 0, 0, 105));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 0, 0, 105)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(0, 1, 0, 45);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 1, 0, 45));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 1, 0, 45)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, 65);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(0, 0, 1, 65));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1, 65)");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, 78);
  var expectedResult = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  expectedResult = expectedResult.multiply(getRotationMatrix(1, 1, 1, 78));
  assert_false(matrix3d.is2D);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 1, 1, 78)");

test(() => {
  var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  matrix2d.rotateAxisAngleSelf(1, 0, 0, 90);
  matrix2d.rotateAxisAngleSelf(1, 0, 0, -90);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngleSelf() - do rotate +90,-90");

test(() => {
  var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
  matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, -180);
  matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, +180);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6]);
  assert_matrix_almost_equals(matrix2d, expectedResult);
}, "DOMMatrix 2d - rotateAxisAngle() - do rotate -180,+180" );

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d.rotateAxisAngleSelf(1, 1, 0, 90);
  matrix3d.rotateAxisAngleSelf(1, 1, 0, -90);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngleSelf() - do rotate +90,-90");

test(() => {
  var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, -180);
  matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, +180);
  var expectedResult = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
  assert_matrix_almost_equals(matrix3d, expectedResult);
}, "DOMMatrix 3d - rotateAxisAngle() - do rotate -180,+180");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, -90);
  var expectedResult1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult1);
  matrix3d = matrix3d.rotateAxisAngle(1, 0, 0, -90);
  var expectedResult2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult2);
  matrix3d = matrix3d.rotateAxisAngle(0, 1, 0, -90);
  var expectedResult3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult3);
}, "DOMMatrix 3d - rotateAxisAngle()");

test(() => {
  var matrix3d = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  matrix3d.rotateAxisAngleSelf(0, 0, 1, -90);
  var expectedResult1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult1);
  matrix3d.rotateAxisAngleSelf(1, 0, 0, -90);
  var expectedResult2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult2);
  matrix3d.rotateAxisAngleSelf(0, 1, 0, -90);
  var expectedResult3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  assert_matrix_almost_equals(matrix3d, expectedResult3);
}, "DOMMatrix 3d - rotateAxisAngleSelf() - do rotate -90,-90,-90");

</script>