このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

DOMMatrixReadOnly: inverse() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.

メモ: この機能はウェブワーカー内で利用可能です。

inverse()DOMMatrixReadOnly インターフェイスのメソッドで、元の行列の逆行列となる新しい行列を作成します。行列が逆行列化できない場合、新しい行列の要素はすべて NaN に設定され、その is2D プロパティは false に設定されます。元の行列は変更されません。

行列を変更して逆行列を作成する場合は、DOMMatrix.invertSelf() を参照してください。

構文

js
inverse()

引数

なし。

返値

DOMMatrix です。

js
const matrix = new DOMMatrixReadOnly().rotate(30);
const invertedMatrix = matrix.inverse();
console.log(matrix.toString());
// 出力: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)
console.log(invertedMatrix.toString());
// 出力: matrix(0.866, -0.5, 0.5, 0.866, 0, 0)

仕様書

Specification
Geometry Interfaces Module Level 1
# dom-dommatrixreadonly-inverse

ブラウザーの互換性

関連情報