![]() |
Lumino
|
4x4 の行列を定義します。 More...
#include <Matrix.hpp>
Public Member Functions | |
Matrix () | |
単位行列を設定してインスタンスを初期化します。 | |
Matrix (float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) | |
各要素を指定してインスタンスを初期化します。 | |
Matrix (const Vector4 &row1, const Vector4 &row2, const Vector4 &row3, const Vector4 &row4) | |
各列を指定してインスタンスを初期化します。 | |
Matrix (const AttitudeTransform &transform) | |
AttitudeTransform から Matrix へ変換します。 | |
void | set (float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) |
各要素を設定します。 | |
bool | isIdentity () const |
この行列が単位行列であるかを判定します。 | |
const Vector3 & | right () const |
この行列の右方向を示すベクトルを取得します。 | |
const Vector3 & | up () const |
この行列の上方向を示すベクトルを取得します。 | |
const Vector3 & | front () const |
この行列の正面方向を示すベクトルを取得します。 | |
const Vector3 & | position () const |
この行列の平行移動量を示すベクトルを取得します。 | |
void | setRow (int index, const Vector4 &row) |
この行列の行要素を設定します。 | |
const Vector4 & | row (int index) const |
この行列の行要素を取得します。 | |
float * | data () noexcept |
Returns pointer to the first element. More... | |
const float * | data () const noexcept |
Returns pointer to the first element. More... | |
void | translate (float x, float y, float z) |
この行列を平行移動します。 More... | |
void | translate (const Vector3 &vec) |
この行列を平行移動します。 More... | |
void | rotateX (float r) |
この行列を X 軸で回転します。 More... | |
void | rotateY (float r) |
この行列を Y 軸で回転します。 More... | |
void | rotateZ (float r) |
この行列を Z 軸で回転します。 More... | |
void | rotateEulerAngles (float x, float y, float z, RotationOrder order=RotationOrder::ZXY) |
この行列を XYZ 各軸のオイラー角を指定して回転します。 More... | |
void | rotateEulerAngles (const Vector3 &angles, RotationOrder order=RotationOrder::ZXY) |
この行列を XYZ 各軸のオイラー角を指定して回転します。 More... | |
void | rotateAxis (const Vector3 &axis, float r) |
この行列を任意軸で回転します。 More... | |
void | rotateQuaternion (const Quaternion &qua) |
この行列を指定したクォータニオンで回転します。 More... | |
void | scale (float x, float y, float z) |
この行列を各軸にそってスケーリングします。 More... | |
void | scale (const Vector3 &vec) |
この行列を各軸にそってスケーリングします。 More... | |
void | scale (float xyz) |
この行列を各軸にそってスケーリングします。 More... | |
void | inverse () |
この行列を逆行列化します。 | |
void | transpose () |
この行列を転置します。 | |
void | decompose (Vector3 *scale, Quaternion *rotation, Vector3 *translation) const |
この行列をスケーリング、回転、移動要素に分解します。 More... | |
void | decomposeMatrices (Matrix *scale, Matrix *rotation, Matrix *translation) const |
この行列をスケーリング、回転、移動行列に分解します。 More... | |
Vector3 | toEulerAngles (RotationOrder order=RotationOrder::ZXY, bool *locked=nullptr) const |
この回転行列を XYZ 各軸のオイラー角度に変換します。 More... | |
Matrix | getRotationMatrix () const |
この行列の行要から回転行列を取り出します。 More... | |
bool | isNaNOrInf () const |
要素のいずれかが NaN または Inf かを判別します。 | |
const float & | operator() (int row, int column) const |
行列の要素にアクセスします。 | |
float & | operator() (int row, int column) |
行列の要素にアクセスします。 | |
Static Public Member Functions | |
static Matrix | multiply (const Matrix &mat1, const Matrix &mat2) |
2つの行列の積を計算します。 More... | |
static Matrix | makeTranslation (float x, float y, float z) |
平行移動行列を作成します。 More... | |
static Matrix | makeTranslation (const Vector3 &vec) |
平行移動行列を作成します。 More... | |
static Matrix | makeRotationX (float r) |
X 軸を回転軸にして回転する行列を作成します。 More... | |
static Matrix | makeRotationY (float r) |
Y 軸を回転軸にして回転する行列を作成します。 More... | |
static Matrix | makeRotationZ (float r) |
Z 軸を回転軸にして回転する行列を作成します。 More... | |
static Matrix | makeRotationAxis (const Vector3 &axis, float r) |
回転軸と角度を指定して行列を作成します。 More... | |
static Matrix | makeRotationQuaternion (const Quaternion &qua) |
クォータニオンから回転行列を作成します。 More... | |
static Matrix | makeRotationEulerAngles (float x, float y, float z, RotationOrder order=RotationOrder::ZXY) |
XYZ 各軸のオイラー角から回転行列を作成します。 More... | |
static Matrix | makeRotationEulerAngles (const Vector3 &angles, RotationOrder order=RotationOrder::ZXY) |
XYZ 各軸のオイラー角から回転行列を作成します。 More... | |
static Matrix | makeRotationYawPitchRoll (float yaw, float pitch, float roll) |
ヨー、ピッチ、ロールを指定して行列を作成します。 More... | |
static Matrix | makeScaling (float x, float y, float z) |
各軸にそってスケーリングする行列を作成します。 More... | |
static Matrix | makeScaling (const Vector3 &vec) |
各軸にそってスケーリングする行列を作成します。 More... | |
static Matrix | makeScaling (float xyz) |
各軸にそってスケーリングする行列を作成します。 More... | |
static Matrix | makeInverse (const Matrix &mat) |
指定された行列の逆行列を作成します。 More... | |
static Matrix | makeTranspose (const Matrix &mat) |
指定された行列の転置行列を作成します。 More... | |
static Matrix | makeReflection (const Plane &plane) |
平面に対して座標系を反転するための行列を作成します。 More... | |
static Matrix | makeLookAtLH (const Vector3 &position, const Vector3 &lookAt, const Vector3 &up) |
左手座標系ビュー行列を作成します。 More... | |
static Matrix | makeLookAtRH (const Vector3 &position, const Vector3 &lookAt, const Vector3 &up) |
右手座標系ビュー行列を作成します。 More... | |
static Matrix | makePerspectiveFovLH (float fovY, float aspect, float near, float far) |
左手座標系パースペクティブ射影行列を作成します。 More... | |
static Matrix | makePerspectiveFovRH (float fovY, float aspect, float near, float far) |
右手座標系パースペクティブ射影行列を作成します。 More... | |
static Matrix | makeOrthoLH (float width, float height, float near, float far) |
左手座標系正射影行列を作成します。 More... | |
static Matrix | makeOrthoRH (float width, float height, float near, float far) |
右手座標系正射影行列を作成します。 More... | |
static Matrix | makePerspective2DLH (float width, float height, float near, float far) |
2D 座標系用の左手座標系正射影行列を作成します。 More... | |
static Matrix | makePerspective2DRH (float width, float height, float near, float far) |
2D 座標系用の右手座標系正射影行列を作成します。 More... | |
static Matrix | makeAffineTransformation (const Vector3 &scaling, const Vector3 &rotationCenter, const Quaternion &rotation, const Vector3 &translation) |
アフィン変換行列を作成します。 More... | |
static Matrix | extractRotation (const Matrix &mat) |
アフィン変換行列 から回転成分を抽出します。 | |
Static Public Attributes | |
static const Matrix | Identity |
単位行列 | |
4x4 の行列を定義します。
行列は数学的な定義とメモリレイアウト共に行優先 (column-major) です。
このクラスは似た機能の static 関数とインスタンス関数があります。 例えば makeRotationX(static 関数) と rotateX(インスタンス関数) です。 前者は新しい行列を作成して返すのに対し、後者は現在の行列を変更します。 例えば、以下の m1 と m2 は同じ結果になります。
なお、後者は行列の生成と乗算をまとめて行うように最適化されており、高速に動作します。
|
inlinenoexcept |
Returns pointer to the first element.
|
inlinenoexcept |
Returns pointer to the first element.
void ln::Matrix::decompose | ( | Vector3 * | scale, |
Quaternion * | rotation, | ||
Vector3 * | translation | ||
) | const |
この行列をスケーリング、回転、移動要素に分解します。
[in] | scale | : スケーリング要素を格納するベクトルのポインタ |
[in] | rotation | : 回転要素を格納するクォータニオンのポインタ |
[in] | translation | : 平行移動要素を格納するベクトルのポインタ |
各引数は必要が無ければ NULL を指定できます。
void ln::Matrix::decomposeMatrices | ( | Matrix * | scale, |
Matrix * | rotation, | ||
Matrix * | translation | ||
) | const |
この行列をスケーリング、回転、移動行列に分解します。
[in] | scale | : スケーリング行列を格納する変数のポインタ |
[in] | rotation | : 回転行列を格納する変数のポインタ |
[in] | translation | : 平行移動行列を格納する変数のポインタ |
各引数は必要が無ければ NULL を指定できます。
Matrix ln::Matrix::getRotationMatrix | ( | ) | const |
この行列の行要から回転行列を取り出します。
分解ではなく、単純に3x3の部分をコピーします。 それ以外の要素は単位行列の値で初期化されます。
|
static |
アフィン変換行列を作成します。
[in] | scaling | : スケーリング係数 |
[in] | rotationCenter | : 回転の中心位置 |
[in] | rotation | : 回転 |
[in] | translation | : 平行移動 |
指定された行列の逆行列を作成します。
[in] | mat | : 処理の基になる行列 |
|
static |
左手座標系ビュー行列を作成します。
[in] | position | : 視点の位置 |
[in] | lookAt | : 注視点 |
[in] | up | : 上方向 |
|
static |
右手座標系ビュー行列を作成します。
[in] | position | : 視点の位置 |
[in] | lookAt | : 注視点 |
[in] | up | : 上方向 |
|
static |
左手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
|
static |
右手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
|
static |
2D 座標系用の左手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
ビューの左上を原点とし、右方向を X+、下方向を Y+、手前方向を Z+ とします。
|
static |
2D 座標系用の右手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
ビューの左上を原点とし、右方向を X+、下方向を Y+、奥方向を Z+ とします。
|
static |
左手座標系パースペクティブ射影行列を作成します。
[in] | fovY | : Y 方向への視野角 (ラジアン単位) |
[in] | aspect | : アスペクト比 (横幅/高さ) |
[in] | near | : 近いビュー平面の Z 値 |
[in] | far | : 遠いビュー平面の Z 値 |
|
static |
右手座標系パースペクティブ射影行列を作成します。
[in] | fovY | : Y 方向への視野角 (ラジアン単位) |
[in] | aspect | : アスペクト比 (横幅/高さ) |
[in] | near | : 近いビュー平面の Z 値 |
[in] | far | : 遠いビュー平面の Z 値 |
平面に対して座標系を反転するための行列を作成します。
[in] | plane | : 処理の基になる平面 |
plane は正規化してから計算を行います。
回転軸と角度を指定して行列を作成します。
[in] | axis | : 回転軸 |
[in] | r | : 回転角度 (ラジアン単位) |
axis が単位ベクトルでない場合は正規化してから計算を行います。
|
static |
XYZ 各軸のオイラー角から回転行列を作成します。
[in] | x | : X 軸の回転角度 (ラジアン単位) |
[in] | y | : Y 軸の回転角度 (ラジアン単位) |
[in] | z | : Z 軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
|
static |
XYZ 各軸のオイラー角から回転行列を作成します。
[in] | angles | : XYZ 各軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
|
static |
クォータニオンから回転行列を作成します。
[in] | qua | : 処理の基になるクォータニオン |
|
static |
X 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
|
static |
Y 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
|
static |
ヨー、ピッチ、ロールを指定して行列を作成します。
[in] | yaw | : y 軸を中心とするヨー (ラジアン単位) |
[in] | pitch | : x 軸を中心とするピッチ (ラジアン単位) |
[in] | roll | : z 軸を中心とするロール (ラジアン単位) |
回転順序は Z → X → Y です。引数の並びとは逆順であることに注意してください。 これは D3DXMatrixRotationYawPitchRoll の回転順序と同じで、 RotationEulerAngles に RotationOrder_ZXY を指定して計算した結果とも同じです。
|
static |
Z 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
|
static |
各軸にそってスケーリングする行列を作成します。
[in] | x | : X 軸の拡縮率 |
[in] | y | : Y 軸の拡縮率 |
[in] | z | : Z 軸の拡縮率 |
各軸にそってスケーリングする行列を作成します。
[in] | vec | : 各軸の拡縮率 |
|
static |
各軸にそってスケーリングする行列を作成します。
[in] | xyz | : 全ての軸の拡縮率 |
|
static |
平行移動行列を作成します。
[in] | x | : X 軸の移動量 |
[in] | y | : Y 軸の移動量 |
[in] | z | : Z 軸の移動量 |
平行移動行列を作成します。
[in] | vec | : 移動量 |
指定された行列の転置行列を作成します。
[in] | mat | : 処理の基になる行列 |
2つの行列の積を計算します。
[in] | mat1 | : 処理の基になる行列 |
[in] | mat2 | : 処理の基になる行列 |
void ln::Matrix::rotateAxis | ( | const Vector3 & | axis, |
float | r | ||
) |
この行列を任意軸で回転します。
[in] | axis | : 回転軸 |
[in] | r | : 回転角度 (ラジアン単位) |
axis が単位ベクトルでない場合は正規化してから計算を行います。
void ln::Matrix::rotateEulerAngles | ( | float | x, |
float | y, | ||
float | z, | ||
RotationOrder | order = RotationOrder::ZXY |
||
) |
この行列を XYZ 各軸のオイラー角を指定して回転します。
[in] | x | : X 軸の回転角度 (ラジアン単位) |
[in] | y | : Y 軸の回転角度 (ラジアン単位) |
[in] | z | : Z 軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
void ln::Matrix::rotateEulerAngles | ( | const Vector3 & | angles, |
RotationOrder | order = RotationOrder::ZXY |
||
) |
この行列を XYZ 各軸のオイラー角を指定して回転します。
[in] | angles | : XYZ 各軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
void ln::Matrix::rotateQuaternion | ( | const Quaternion & | qua | ) |
この行列を指定したクォータニオンで回転します。
[in] | qua | : 処理の基になるクォータニオン |
void ln::Matrix::rotateX | ( | float | r | ) |
この行列を X 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
void ln::Matrix::rotateY | ( | float | r | ) |
この行列を Y 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
void ln::Matrix::rotateZ | ( | float | r | ) |
この行列を Z 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
void ln::Matrix::scale | ( | float | x, |
float | y, | ||
float | z | ||
) |
この行列を各軸にそってスケーリングします。
[in] | x | : X 軸の拡縮率 |
[in] | y | : Y 軸の拡縮率 |
[in] | z | : Z 軸の拡縮率 |
void ln::Matrix::scale | ( | const Vector3 & | vec | ) |
この行列を各軸にそってスケーリングします。
[in] | vec | : 各軸の拡縮率 |
void ln::Matrix::scale | ( | float | xyz | ) |
この行列を各軸にそってスケーリングします。
[in] | xyz | : 全ての軸の拡縮率 |
Vector3 ln::Matrix::toEulerAngles | ( | RotationOrder | order = RotationOrder::ZXY , |
bool * | locked = nullptr |
||
) | const |
この回転行列を XYZ 各軸のオイラー角度に変換します。
[in] | order | : 回転順序 |
[in] | locked | : ジンバルロックの発生有無を格納する変数へのポインタ (ジンバルロックが発生した場合 true) |
回転行列は order に指定された順序で乗算されたものでなければ本来の回転角度が取得できないことに注意してください。
例えば RotationYawPitchRoll() は、回転軸 Z → Y → X の順に回転を行いますが、 これから元の角度を取り出すには RotationOrder_ZXY を指定します。
void ln::Matrix::translate | ( | float | x, |
float | y, | ||
float | z | ||
) |
この行列を平行移動します。
[in] | x | : X 軸の移動量 |
[in] | y | : Y 軸の移動量 |
[in] | z | : Z 軸の移動量 |
void ln::Matrix::translate | ( | const Vector3 & | vec | ) |
この行列を平行移動します。
[in] | vec | : 移動量 |