Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html

Issue 2444733002: [GeometryInterface] Add rotate*(), rotateFromVector*() function. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html
index 40b29a7fb92b530819eca1959fb75feecce5edc0..f7fc1ed17b72d5632ee61b0568ffe0cdf0c26e6f 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-rotate.html
@@ -8,6 +8,10 @@ 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;
@@ -47,6 +51,92 @@ function getRotationMatrix(x, y, z, alpha_in_degrees) {
}
test(() => {
+ var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ var result = matrix.rotate(60);
+ matrix.rotateSelf(60);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 60));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
meade_UTC10 2016/10/24 05:37:11 I had to think for a moment to figure out what the
Hwanseung Lee 2016/10/24 14:33:43 Done.
+}, "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 result = matrix.rotate(77);
+ matrix.rotateSelf(77);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 77));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
+}, "DOMMatrix 3d - rotate(rotX) and rotateSelf(rotX)");
+
+test(() => {
+ var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ var result = matrix.rotate(10, 20);
+ matrix.rotateSelf(10, 20);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 20));
+ expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 10));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
+}, "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 result = matrix.rotate(23, 50);
+ matrix.rotateSelf(23, 50);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 50));
+ expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 23));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
+}, "DOMMatrix 3d - rotate(rotX, rotY) and rotateSelf(rotX, rotY)");
+
+test(() => {
+ var matrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ var result = matrix.rotate(39, 10, 50);
+ matrix.rotateSelf(39, 10, 50);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 50));
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 10));
+ expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 39));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
+}, "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 result = matrix.rotate(55, 66, 88);
+ matrix.rotateSelf(55, 66, 88);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 0, 1, 88));
+ expectedMatrix.multiplySelf(getRotationMatrix(0, 1, 0, 66));
+ expectedMatrix.multiplySelf(getRotationMatrix(1, 0, 0, 55));
+ assert_matrix_almost_equals(result, expectedMatrix);
+ assert_matrix_almost_equals(matrix, expectedMatrix);
+}, "DOMMatrix 3d - rotate(rotX, rotY, rotX) and rotateSelf(rotX, rotY, rotX)");
+
+test(function() {
+ var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ var result = 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(result, 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 result = 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(result, 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 expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
@@ -341,26 +431,26 @@ 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 expectedMatrix1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix1.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix1);
matrix3d = matrix3d.rotateAxisAngle(1, 0, 0, -90);
var expectedMatrix2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix2.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix2);
matrix3d = matrix3d.rotateAxisAngle(0, 1, 0, -90);
var expectedMatrix3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix3.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix3);
}, "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 expectedMatrix1 = new DOMMatrix([0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix1.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix1);
matrix3d.rotateAxisAngleSelf(1, 0, 0, -90);
var expectedMatrix2 = new DOMMatrix([0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix2.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix2);
matrix3d.rotateAxisAngleSelf(0, 1, 0, -90);
var expectedMatrix3 = new DOMMatrix([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
- assert_array_almost_equals(matrix3d.toFloat64Array(), expectedMatrix3.toFloat64Array());
+ assert_matrix_almost_equals(matrix3d, expectedMatrix3);
}, "DOMMatrix 3d - rotateAxisAngleSelf()");
</script>

Powered by Google App Engine
This is Rietveld 408576698