DOMMatrix: rotateFromVectorSelf()-Methode
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die rotateFromVectorSelf()
-Methode des DOMMatrix
-Interfaces ist eine veränderliche Transformationsmethode, die eine Matrix durch Drehung der Matrix um den Winkel zwischen dem angegebenen Vektor und (1, 0)
modifiziert. Der Drehwinkel wird durch den Winkel zwischen dem Vektor (1,0)T
und (x,y)T
im Uhrzeigersinn bestimmt oder (+/-)arctan(y/x)
. Wenn x
und y
beide 0
sind, wird der Winkel als 0
angegeben und die Matrix wird nicht verändert.
Um eine Matrix von einem Vektor zu drehen, ohne sie zu verändern, siehe DOMMatrixReadOnly.rotateFromVector()
, die eine neue gedrehte Matrix erstellt und die ursprüngliche unverändert lässt.
Syntax
rotateFromVectorSelf()
rotateFromVectorSelf(rotX)
rotateFromVectorSelf(rotX, rotY)
Parameter
rotX
Optional-
Eine Zahl; Die x-Koordinate des x,y Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0
verwendet. rotY
Optional-
Eine Zahl; Die y-Koordinate des x,y Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0
verwendet.
Rückgabewert
Gibt sich selbst zurück; die aktualisierte DOMMatrix
.
Beispiele
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.rotateFromVectorSelf().toString());
// output: matrix(1, 0, 0, 1, 0, 0) (no rotation applied)
console.log(matrix.rotateFromVectorSelf(10, 20).toString());
// output: matrix(0.447, 0.894, -0.894, 0.447, 0, 0)
console.log(matrix.toString());
// output: matrix(0.447, 0.894, -0.894, 0.447, 0, 0) (same as above)
Spezifikationen
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dommatrix-rotatefromvectorself |
Browser-Kompatibilität
Siehe auch
DOMMatrixReadOnly.rotateFromVector()
DOMMatrix.rotateSelf()
DOMMatrix.rotateAxisAngleSelf()
- CSS
transform
Eigenschaft undrotate3d()
Funktion - CSS
rotate
Eigenschaft - CSS-Transformationen Modul
- SVG
transform
Attribut CanvasRenderingContext2D
Interface undrotate()
Methode