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 Januar 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die rotateFromVectorSelf()-Methode des DOMMatrix-Interfaces ist eine veränderliche Transformationsmethode, die eine Matrix modifiziert, indem sie die Matrix um den Winkel zwischen dem angegebenen Vektor und (1, 0) dreht. Der Rotationswinkel 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 spezifiziert, 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 Originalmatrix unverändert bleibt.
Syntax
rotateFromVectorSelf()
rotateFromVectorSelf(rotX)
rotateFromVectorSelf(rotX, rotY)
Parameter
rotXOptional-
Eine Zahl; die x-Koordinate des x,y-Vektors, der den Rotationswinkel bestimmt. Wenn nicht definiert, wird
0verwendet. rotYOptional-
Eine Zahl; die y-Koordinate des x,y-Vektors, der den Rotationswinkel 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-
transform-Attribut CanvasRenderingContext2D-Interface undrotate()-Methode