DOMMatrixReadOnly: rotateAxisAngle() 方法
注意:此功能在 Web Workers 中可用。
DOMMatrixReadOnly
接口的 rotateAxisAngle()
方法会返回一个新的 DOMMatrix
对象,该对象通过将源矩阵绕给定向量和角度进行旋转而创建。原始矩阵不会被修改。
要旋转矩阵并直接修改它,请参阅 DOMMatrix.rotateAxisAngleSelf()
。
语法
js
rotateAxisAngle()
rotateAxisAngle(rotX)
rotateAxisAngle(rotX, rotY)
rotateAxisAngle(rotX, rotY, rotZ)
rotateAxisAngle(rotX, rotY, rotZ, angle)
参数
返回值
一个 DOMMatrix
。
示例
js
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.rotateAxisAngle().toString()); // matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.rotateAxisAngle(10, 20, 30).toString()); // matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.rotateAxisAngle(10, 20, 30, 45).toString());
/* matrix3d(
0.728, 0.609, -0.315, 0,
-0.525, 0.791, 0.315, 0,
0.441, -0.063, 0.895,
0, 0, 0, 0, 1) */
console.log(matrix.rotateAxisAngle(5, 5, 5, -45).toString());
/* matrix3d(
0.805, -0.311, 0.506, 0,
0.506, 0.805, -0.311, 0,
-0.311, 0.506, 0.805, 0,
0, 0, 0, 1) */
console.log(matrix.toString()); // output: "matrix(1, 0, 0, 1, 0, 0)" (unchanged)
规范
规范 |
---|
Geometry Interfaces Module Level 1 # dom-dommatrixreadonly-rotateaxisangle |
浏览器兼容性
加载中…
另见
DOMMatrix.rotateAxisAngleSelf()
DOMMatrixReadOnly.rotate()
DOMMatrixReadOnly.rotateFromVector()
- CSS
transform
属性和rotate3d()
函数 - CSS
rotate
属性 - CSS 变换模块
- SVG
transform
属性 CanvasRenderingContext2D
接口和rotate()
方法