DOMMatrix: Methode rotateFromVectorSelf()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Januar 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die rotateFromVectorSelf()-Methode des DOMMatrix-Interfaces ist eine veränderbare Transformationsmethode, die eine Matrix durch Drehen 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 oder (+/-)arctan(y/x) bestimmt. Wenn sowohl x als auch y 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, während die ursprüngliche unverändert bleibt.
Syntax
rotateFromVectorSelf()
rotateFromVectorSelf(rotX)
rotateFromVectorSelf(rotX, rotY)
Parameter
rotXOptional-
Eine Zahl; Die x-Koordinate des x,y-Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0verwendet. rotYOptional-
Eine Zahl; Die y-Koordinate des x,y-Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0verwendet.
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
transformAttribut CanvasRenderingContext2DInterface undrotate()Methode