OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> |
| 5 <script> |
| 6 |
| 7 function deg2rad(degrees) { |
| 8 return degrees * Math.PI / 180; |
| 9 } |
| 10 |
| 11 function getRotationMatrix(x, y, z, alpha_in_degrees) { |
| 12 // Vector normalizing |
| 13 var nx = x; |
| 14 var ny = y; |
| 15 var nz = z; |
| 16 var length = Math.sqrt(x * x + y * y + z * z); |
| 17 if (length) { |
| 18 nx = x / length; |
| 19 ny = y / length; |
| 20 nz = z / length; |
| 21 } |
| 22 |
| 23 // The 3D rotation matrix is described in CSS Transforms with alpha. |
| 24 // Please see: https://drafts.csswg.org/css-transforms-1/#Rotate3dDefined |
| 25 var alpha_in_radians = deg2rad(alpha_in_degrees / 2); |
| 26 var sc = Math.sin(alpha_in_radians) * Math.cos(alpha_in_radians); |
| 27 var sq = Math.sin(alpha_in_radians) * Math.sin(alpha_in_radians); |
| 28 |
| 29 var m11 = 1 - 2 * (ny * ny + nz * nz) * sq; |
| 30 var m12 = 2 * (nx * ny * sq + nz * sc); |
| 31 var m13 = 2 * (nx * nz * sq - ny * sc); |
| 32 var m14 = 0; |
| 33 var m21 = 2 * (nx * ny * sq - nz * sc); |
| 34 var m22 = 1 - 2 * (nx * nx + nz * nz) * sq; |
| 35 var m23 = 2 * (ny * nz * sq + nx * sc); |
| 36 var m24 = 0; |
| 37 var m31 = 2 * (nx * nz * sq + ny * sc); |
| 38 var m32 = 2 * (ny * nz * sq - nx * sc); |
| 39 var m33 = 1 - 2 * (nx * nx + ny * ny) * sq; |
| 40 var m34 = 0; |
| 41 var m41 = 0; |
| 42 var m42 = 0; |
| 43 var m43 = 0; |
| 44 var m44 = 1; |
| 45 |
| 46 return new DOMMatrix([m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m
34, m41, m42, m43, m44]); |
| 47 } |
| 48 |
| 49 test(() => { |
| 50 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 51 matrix2d.rotateAxisAngleSelf(); |
| 52 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 53 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 0, 0)); |
| 54 assert_true(matrix2d.is2D); |
| 55 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 56 }, "DOMMatrix 2d - rotateAxisAngleSelf()"); |
| 57 |
| 58 test(() => { |
| 59 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 60 matrix2d.rotateAxisAngleSelf(0, 0, 1); |
| 61 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 62 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 0)); |
| 63 assert_true(matrix2d.is2D); |
| 64 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 65 }, "DOMMatrix 2d - rotateAxisAngleSelf(0, 0, 1)"); |
| 66 |
| 67 test(() => { |
| 68 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 69 matrix2d.rotateAxisAngleSelf(1, 1, 1); |
| 70 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 71 expectedMatrix.multiplySelf(getRotationMatrix(1, 1, 1, 0)); |
| 72 assert_false(matrix2d.is2D); |
| 73 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 74 }, "DOMMatrix 2d - rotateAxisAngleSelf(1, 1, 1, 0)"); |
| 75 |
| 76 test(() => { |
| 77 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 78 matrix2d.rotateAxisAngleSelf(1, 0, 0, 10); |
| 79 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 80 expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 10)); |
| 81 assert_false(matrix2d.is2D); |
| 82 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 83 }, "DOMMatrix 2d - rotateAxisAngleSelf(1, 0, 0, 10)"); |
| 84 |
| 85 test(() => { |
| 86 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 87 matrix2d.rotateAxisAngleSelf(0, 1, 0, 27); |
| 88 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 89 expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 27)); |
| 90 assert_false(matrix2d.is2D); |
| 91 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 92 }, "DOMMatrix 2d - rotateAxisAngleSelf(0, 1, 0, 27)"); |
| 93 |
| 94 test(() => { |
| 95 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 96 matrix2d.rotateAxisAngleSelf(0, 0, 1, 38); |
| 97 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 98 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 38)); |
| 99 assert_true(matrix2d.is2D); |
| 100 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 101 }, "DOMMatrix 2d - rotateAxisAngleSelf(0, 0, 1, 38)"); |
| 102 |
| 103 test(() => { |
| 104 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 105 matrix2d.rotateAxisAngleSelf(1, 1, 1, 45); |
| 106 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 107 expectedMatrix.multiplySelf(getRotationMatrix(1, 1, 1, 45)); |
| 108 assert_false(matrix2d.is2D); |
| 109 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 110 }, "DOMMatrix 2d - rotateAxisAngleSelf(1, 1, 1, 45)"); |
| 111 |
| 112 test(() => { |
| 113 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 114 matrix3d.rotateAxisAngleSelf(); |
| 115 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 116 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 0, 0)); |
| 117 assert_false(matrix3d.is2D); |
| 118 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 119 }, "DOMMatrix 3d - rotateAxisAngleSelf()"); |
| 120 |
| 121 test(() => { |
| 122 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 123 matrix3d.rotateAxisAngleSelf(0, 0, 1); |
| 124 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 125 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 0)); |
| 126 assert_false(matrix3d.is2D); |
| 127 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 128 }, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1)"); |
| 129 |
| 130 test(() => { |
| 131 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 132 matrix3d.rotateAxisAngleSelf(0, 0, 1, 0); |
| 133 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 134 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 0)); |
| 135 assert_false(matrix3d.is2D); |
| 136 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 137 }, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1, 0)"); |
| 138 |
| 139 test(() => { |
| 140 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 141 matrix3d.rotateAxisAngleSelf(1, 0, 0, 19); |
| 142 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 143 expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 19)); |
| 144 assert_false(matrix3d.is2D); |
| 145 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 146 }, "DOMMatrix 3d - rotateAxisAngleSelf(1, 0, 0, 19)"); |
| 147 |
| 148 test(() => { |
| 149 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 150 matrix3d.rotateAxisAngleSelf(0, 1, 0, 46); |
| 151 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 152 expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 46)); |
| 153 assert_false(matrix3d.is2D); |
| 154 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 155 }, "DOMMatrix 3d - rotateAxisAngleSelf(0, 1, 0, 46)"); |
| 156 |
| 157 test(() => { |
| 158 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 159 matrix3d.rotateAxisAngleSelf(0, 0, 1, 65); |
| 160 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 161 expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 65)); |
| 162 assert_false(matrix3d.is2D); |
| 163 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 164 }, "DOMMatrix 3d - rotateAxisAngleSelf(0, 0, 1, 65)"); |
| 165 |
| 166 test(() => { |
| 167 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 168 matrix3d.rotateAxisAngleSelf(1, 1, 1, 67); |
| 169 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 170 expectedMatrix.multiplySelf(getRotationMatrix(1, 1, 1, 67)); |
| 171 assert_false(matrix3d.is2D); |
| 172 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 173 }, "DOMMatrix 3d - rotateAxisAngleSelf(1, 1, 1, 67)"); |
| 174 |
| 175 test(() => { |
| 176 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 177 matrix2d = matrix2d.rotateAxisAngle(); |
| 178 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 179 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 0, 0)); |
| 180 assert_true(matrix2d.is2D); |
| 181 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 182 }, "DOMMatrixReadOnly 2d - rotateAxisAngle()"); |
| 183 |
| 184 test(() => { |
| 185 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 186 matrix2d = matrix2d.rotateAxisAngle(0, 0, 1); |
| 187 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 188 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 1, 0)); |
| 189 assert_true(matrix2d.is2D); |
| 190 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 191 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 0, 1)"); |
| 192 |
| 193 test(() => { |
| 194 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 195 matrix2d = matrix2d.rotateAxisAngle(1, 1, 1); |
| 196 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 197 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 1, 1, 0)); |
| 198 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 1, 1, 0)"); |
| 199 |
| 200 test(() => { |
| 201 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 202 matrix2d = matrix2d.rotateAxisAngle(1, 0, 0, 21); |
| 203 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 204 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 0, 0, 21)); |
| 205 assert_false(matrix2d.is2D); |
| 206 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 207 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 0, 0, 21)"); |
| 208 |
| 209 test(() => { |
| 210 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 211 matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, 35); |
| 212 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 213 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 1, 0, 35)); |
| 214 assert_false(matrix2d.is2D); |
| 215 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 216 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 1, 0, 35)"); |
| 217 |
| 218 test(() => { |
| 219 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 220 matrix2d = matrix2d.rotateAxisAngle(0, 0, 1, 55); |
| 221 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 222 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 1, 55)); |
| 223 assert_true(matrix2d.is2D); |
| 224 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 225 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(0, 0, 1, 55)"); |
| 226 |
| 227 test(() => { |
| 228 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 229 matrix2d = matrix2d.rotateAxisAngle(1, 1, 1, 75); |
| 230 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 231 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 1, 1, 75)); |
| 232 assert_false(matrix2d.is2D); |
| 233 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 234 }, "DOMMatrixReadOnly 2d - rotateAxisAngle(1, 1, 1, 75)"); |
| 235 |
| 236 test(() => { |
| 237 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 238 matrix3d = matrix3d.rotateAxisAngle(); |
| 239 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 240 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 0, 0)); |
| 241 assert_false(matrix3d.is2D); |
| 242 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 243 }, "DOMMatrixReadOnly 3d - rotateAxisAngle()"); |
| 244 |
| 245 test(() => { |
| 246 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 247 matrix3d = matrix3d.rotateAxisAngle(0, 0, 1); |
| 248 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 249 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 1, 0)); |
| 250 assert_false(matrix3d.is2D); |
| 251 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 252 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1)"); |
| 253 |
| 254 test(() => { |
| 255 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 256 matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, 0); |
| 257 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 258 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 1, 0)); |
| 259 assert_false(matrix3d.is2D); |
| 260 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 261 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1, 0)"); |
| 262 |
| 263 test(() => { |
| 264 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 265 matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, 0); |
| 266 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 267 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 1, 1, 0)); |
| 268 assert_false(matrix3d.is2D); |
| 269 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 270 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 1, 1, 0)"); |
| 271 |
| 272 test(() => { |
| 273 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 274 matrix3d = matrix3d.rotateAxisAngle(1, 0, 0, 105); |
| 275 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 276 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 0, 0, 105)); |
| 277 assert_false(matrix3d.is2D); |
| 278 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 279 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 0, 0, 105)"); |
| 280 |
| 281 test(() => { |
| 282 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 283 matrix3d = matrix3d.rotateAxisAngle(0, 1, 0, 45); |
| 284 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 285 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 1, 0, 45)); |
| 286 assert_false(matrix3d.is2D); |
| 287 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 288 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 1, 0, 45)"); |
| 289 |
| 290 test(() => { |
| 291 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 292 matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, 65); |
| 293 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 294 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(0, 0, 1, 65)); |
| 295 assert_false(matrix3d.is2D); |
| 296 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 297 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(0, 0, 1, 65)"); |
| 298 |
| 299 test(() => { |
| 300 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 301 matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, 78); |
| 302 var expectedMatrix = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16]); |
| 303 expectedMatrix = expectedMatrix.multiply(getRotationMatrix(1, 1, 1, 78)); |
| 304 assert_false(matrix3d.is2D); |
| 305 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 306 }, "DOMMatrixReadOnly 3d - rotateAxisAngle(1, 1, 1, 78)"); |
| 307 |
| 308 test(() => { |
| 309 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 310 matrix2d.rotateAxisAngleSelf(1, 0, 0, 90); |
| 311 matrix2d.rotateAxisAngleSelf(1, 0, 0, -90); |
| 312 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 313 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 314 }, "DOMMatrix 2d - rotateAxisAngleSelf() - do rotate +90,-90"); |
| 315 |
| 316 test(() => { |
| 317 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]); |
| 318 matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, -180); |
| 319 matrix2d = matrix2d.rotateAxisAngle(0, 1, 0, +180); |
| 320 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); |
| 321 assert_matrix_almost_equals(matrix2d, expectedMatrix); |
| 322 }, "DOMMatrix 2d - rotateAxisAngle() - do rotate -180,+180" ); |
| 323 |
| 324 test(() => { |
| 325 var matrix3d = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
5, 16]); |
| 326 matrix3d.rotateAxisAngleSelf(1, 1, 0, 90); |
| 327 matrix3d.rotateAxisAngleSelf(1, 1, 0, -90); |
| 328 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 329 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 330 }, "DOMMatrix 3d - rotateAxisAngleSelf() - do rotate +90,-90"); |
| 331 |
| 332 test(() => { |
| 333 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1
3, 14, 15, 16]); |
| 334 matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, -180); |
| 335 matrix3d = matrix3d.rotateAxisAngle(1, 1, 1, +180); |
| 336 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16]); |
| 337 assert_matrix_almost_equals(matrix3d, expectedMatrix); |
| 338 }, "DOMMatrix 3d - rotateAxisAngle() - do rotate -180,+180"); |
| 339 |
| 340 test(() => { |
| 341 var matrix3d = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
; |
| 342 matrix3d = matrix3d.rotateAxisAngle(0, 0, 1, -90); |
| 343 var expectedMatrix1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0,
0, 0]); |
| 344 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix1.toFloat6
4Array()); |
| 345 matrix3d = matrix3d.rotateAxisAngle(1, 0, 0, -90); |
| 346 var expectedMatrix2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0,
0, 0]); |
| 347 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix2.toFloat6
4Array()); |
| 348 matrix3d = matrix3d.rotateAxisAngle(0, 1, 0, -90); |
| 349 var expectedMatrix3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0]); |
| 350 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix3.toFloat6
4Array()); |
| 351 }, "DOMMatrix 3d - rotateAxisAngle()"); |
| 352 |
| 353 test(() => { |
| 354 var matrix3d = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
; |
| 355 matrix3d.rotateAxisAngleSelf(0, 0, 1, -90); |
| 356 var expectedMatrix1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0,
0, 0]); |
| 357 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix1.toFloat6
4Array()); |
| 358 matrix3d.rotateAxisAngleSelf(1, 0, 0, -90); |
| 359 var expectedMatrix2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0,
0, 0]); |
| 360 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix2.toFloat6
4Array()); |
| 361 matrix3d.rotateAxisAngleSelf(0, 1, 0, -90); |
| 362 var expectedMatrix3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0]); |
| 363 assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix3.toFloat6
4Array()); |
| 364 }, "DOMMatrix 3d - rotateAxisAngleSelf()"); |
| 365 |
| 366 </script> |
OLD | NEW |