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 Rotation 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 bleibt unverändert.

Um eine Matrix aus 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

js
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

js
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

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
rotateFromVectorSelf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch