Commit 66e25541 authored by hs1217.lee's avatar hs1217.lee Committed by Commit bot

[GeometryInterface] Add rotate*(), rotateFromVector*() function.

rotate() and rotateSelf() function
1. If rotY and rotZ are both missing,
 set rotZ to the value of rotX and set rotX and rotY to zero.
2. If rotY is still missing, set rotY to zero.
3. If rotZ is still missing, set rotZ to zero.
4. If rotX or rotY are non-zero,
 set is2D of the current matrix to false.
5. Post-multiply a rotation transformation on the current matrix around the vector 0, 0, 1
 by the specified rotation rotZ in degrees.
6. Post-multiply a rotation transformation on the current matrix around the vector 0, 1, 0
 by the specified rotation rotY in degrees.
7. Post-multiply a rotation transformation on the current matrix around the vector 1, 0, 0
 by the specified rotation rotX in degrees.
8. Return the current matrix.

rotateFromVertor() and rotateFromVertorSelf() function
1. Post-multiply a rotation transformation on the current matrix.
 The rotation angle is determined by the angle between the vector (1,0)T and (x,y)T
 in the clockwise direction.
2. Return the current matrix.

spec list:
- https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateself
- https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-rotate
- https://drafts.fxtf.org/geometry/#dom-dommatrix-rotatefromvectorself
- https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-rotatefromvector

BUG=388780, 645878, 645882

Review-Url: https://codereview.chromium.org/2444733002
Cr-Commit-Position: refs/heads/master@{#427289}
parent a9c75fd2
...@@ -990,6 +990,8 @@ interface DOMMatrix : DOMMatrixReadOnly ...@@ -990,6 +990,8 @@ interface DOMMatrix : DOMMatrixReadOnly
method multiplySelf method multiplySelf
method preMultiplySelf method preMultiplySelf
method rotateAxisAngleSelf method rotateAxisAngleSelf
method rotateFromVectorSelf
method rotateSelf
method scale3dSelf method scale3dSelf
method scaleSelf method scaleSelf
method skewXSelf method skewXSelf
...@@ -1051,7 +1053,9 @@ interface DOMMatrixReadOnly ...@@ -1051,7 +1053,9 @@ interface DOMMatrixReadOnly
method flipY method flipY
method inverse method inverse
method multiply method multiply
method rotate
method rotateAxisAngle method rotateAxisAngle
method rotateFromVector
method scale method scale
method scale3d method scale3d
method skewX method skewX
......
...@@ -183,6 +183,36 @@ DOMMatrix* DOMMatrix::scale3dSelf(double scale, ...@@ -183,6 +183,36 @@ DOMMatrix* DOMMatrix::scale3dSelf(double scale,
return scaleSelf(scale, scale, scale, ox, oy, oz); return scaleSelf(scale, scale, scale, ox, oy, oz);
} }
DOMMatrix* DOMMatrix::rotateSelf(double rotX) {
return rotateSelf(0, 0, rotX);
}
DOMMatrix* DOMMatrix::rotateSelf(double rotX, double rotY) {
return rotateSelf(rotX, rotY, 0);
}
DOMMatrix* DOMMatrix::rotateSelf(double rotX, double rotY, double rotZ) {
if (rotZ)
m_matrix->rotate3d(0, 0, 1, rotZ);
if (rotY) {
m_matrix->rotate3d(0, 1, 0, rotY);
m_is2D = false;
}
if (rotX) {
m_matrix->rotate3d(1, 0, 0, rotX);
m_is2D = false;
}
return this;
}
DOMMatrix* DOMMatrix::rotateFromVectorSelf(double x, double y) {
m_matrix->rotate(rad2deg(atan2(y, x)));
return this;
}
DOMMatrix* DOMMatrix::rotateAxisAngleSelf(double x, DOMMatrix* DOMMatrix::rotateAxisAngleSelf(double x,
double y, double y,
double z, double z,
......
...@@ -92,6 +92,10 @@ class CORE_EXPORT DOMMatrix : public DOMMatrixReadOnly { ...@@ -92,6 +92,10 @@ class CORE_EXPORT DOMMatrix : public DOMMatrixReadOnly {
double ox = 0, double ox = 0,
double oy = 0, double oy = 0,
double oz = 0); double oz = 0);
DOMMatrix* rotateSelf(double rotX);
DOMMatrix* rotateSelf(double rotX, double rotY);
DOMMatrix* rotateSelf(double rotX, double rotY, double rotZ);
DOMMatrix* rotateFromVectorSelf(double x, double y);
DOMMatrix* rotateAxisAngleSelf(double x = 0, DOMMatrix* rotateAxisAngleSelf(double x = 0,
double y = 0, double y = 0,
double z = 0, double z = 0,
......
...@@ -63,6 +63,11 @@ ...@@ -63,6 +63,11 @@
optional unrestricted double originX = 0, optional unrestricted double originX = 0,
optional unrestricted double originY = 0, optional unrestricted double originY = 0,
optional unrestricted double originZ = 0); optional unrestricted double originZ = 0);
DOMMatrix rotateSelf(optional unrestricted double rotX = 0,
optional unrestricted double rotY,
optional unrestricted double rotZ);
DOMMatrix rotateFromVectorSelf(optional unrestricted double x = 0,
optional unrestricted double y = 0);
DOMMatrix rotateAxisAngleSelf(optional unrestricted double x = 0, DOMMatrix rotateAxisAngleSelf(optional unrestricted double x = 0,
optional unrestricted double y = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double z = 0,
......
...@@ -173,6 +173,22 @@ DOMMatrix* DOMMatrixReadOnly::scale3d(double scale, ...@@ -173,6 +173,22 @@ DOMMatrix* DOMMatrixReadOnly::scale3d(double scale,
return DOMMatrix::create(this)->scale3dSelf(scale, ox, oy, oz); return DOMMatrix::create(this)->scale3dSelf(scale, ox, oy, oz);
} }
DOMMatrix* DOMMatrixReadOnly::rotate(double rotX) {
return DOMMatrix::create(this)->rotateSelf(rotX);
}
DOMMatrix* DOMMatrixReadOnly::rotate(double rotX, double rotY) {
return DOMMatrix::create(this)->rotateSelf(rotX, rotY);
}
DOMMatrix* DOMMatrixReadOnly::rotate(double rotX, double rotY, double rotZ) {
return DOMMatrix::create(this)->rotateSelf(rotX, rotY, rotZ);
}
DOMMatrix* DOMMatrixReadOnly::rotateFromVector(double x, double y) {
return DOMMatrix::create(this)->rotateFromVectorSelf(x, y);
}
DOMMatrix* DOMMatrixReadOnly::rotateAxisAngle(double x, DOMMatrix* DOMMatrixReadOnly::rotateAxisAngle(double x,
double y, double y,
double z, double z,
......
...@@ -66,6 +66,10 @@ class CORE_EXPORT DOMMatrixReadOnly ...@@ -66,6 +66,10 @@ class CORE_EXPORT DOMMatrixReadOnly
double oy = 0, double oy = 0,
double oz = 0); double oz = 0);
DOMMatrix* scale3d(double scale, double ox = 0, double oy = 0, double oz = 0); DOMMatrix* scale3d(double scale, double ox = 0, double oy = 0, double oz = 0);
DOMMatrix* rotate(double rotX);
DOMMatrix* rotate(double rotX, double rotY);
DOMMatrix* rotate(double rotX, double rotY, double rotZ);
DOMMatrix* rotateFromVector(double x, double y);
DOMMatrix* rotateAxisAngle(double x = 0, DOMMatrix* rotateAxisAngle(double x = 0,
double y = 0, double y = 0,
double z = 0, double z = 0,
......
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
optional unrestricted double originX = 0, optional unrestricted double originX = 0,
optional unrestricted double originY = 0, optional unrestricted double originY = 0,
optional unrestricted double originZ = 0); optional unrestricted double originZ = 0);
DOMMatrix rotate(optional unrestricted double rotX = 0,
optional unrestricted double rotY,
optional unrestricted double rotZ);
DOMMatrix rotateFromVector(optional unrestricted double x = 0,
optional unrestricted double y = 0);
DOMMatrix rotateAxisAngle(optional unrestricted double x = 0, DOMMatrix rotateAxisAngle(optional unrestricted double x = 0,
optional unrestricted double y = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double z = 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment