4x4 の行列を定義します。 More...
#include <Matrix.h>
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 SQTTransform &transform) | |
SQTTransform から 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 & | GetRight () const |
この行列の右方向を示すベクトルを取得します。 | |
const Vector3 & | GetUp () const |
この行列の上方向を示すベクトルを取得します。 | |
const Vector3 & | GetFront () const |
この行列の正面方向を示すベクトルを取得します。 | |
const Vector3 & | GetPosition () const |
この行列の平行移動量を示すベクトルを取得します。 | |
void | SetRow (int index, const Vector4 &row) |
この行列の行要素を設定します。 | |
const Vector4 & | GetRow (int index) const |
この行列の行要素を取得します。 | |
void | Translate (float x, float y, float z) |
この行列を平行移動します。 | |
void | Translate (const Vector3 &vec) |
この行列を平行移動します。 | |
void | RotateX (float r) |
この行列を X 軸で回転します。 | |
void | RotateY (float r) |
この行列を Y 軸で回転します。 | |
void | RotateZ (float r) |
この行列を Z 軸で回転します。 | |
void | RotateEulerAngles (float x, float y, float z, RotationOrder order=RotationOrder_ZXY) |
この行列を XYZ 各軸のオイラー角を指定して回転します。 | |
void | RotateEulerAngles (const Vector3 &angles, RotationOrder order=RotationOrder_ZXY) |
この行列を XYZ 各軸のオイラー角を指定して回転します。 | |
void | RotateAxis (const Vector3 &axis, float r) |
この行列を任意軸で回転します。 | |
void | RotateQuaternion (const Quaternion &qua) |
この行列を指定したクォータニオンで回転します。 | |
void | Scale (float x, float y, float z) |
この行列を各軸にそってスケーリングします。 | |
void | Scale (const Vector3 &vec) |
この行列を各軸にそってスケーリングします。 | |
void | Scale (float xyz) |
この行列を各軸にそってスケーリングします。 | |
void | Inverse () |
この行列を逆行列化します。 | |
void | Transpose () |
この行列を転置します。 | |
void | Decompose (Vector3 *scale, Quaternion *rotation, Vector3 *translation) const |
この行列をスケーリング、回転、移動要素に分解します。 | |
void | DecomposeMatrices (Matrix *scale, Matrix *rotation, Matrix *translation) const |
この行列をスケーリング、回転、移動行列に分解します。 | |
Vector3 | ToEulerAngles (RotationOrder order=RotationOrder_ZXY, bool *locked=NULL) const |
この回転行列を XYZ 各軸のオイラー角度に変換します。 | |
Matrix | GetRotationMatrix () const |
この行列の行要から回転行列を取り出します。 | |
bool | IsNaNOrInf () const |
要素のいずれかが NaN または Inf かを判別します。 | |
void | Print (const char *format=NULL, FILE *stream=NULL) const |
デバッグ用に文字列を標準出力します。 | |
Matrix & | operator*= (const Matrix &mat) |
bool | operator== (const Matrix &mat) const |
bool | operator!= (const Matrix &mat) const |
Static Public Member Functions | |
static Matrix | Multiply (const Matrix &mat1, const Matrix &mat2) |
2つのク行列の積を計算します。 | |
static Matrix | Translation (float x, float y, float z) |
平行移動行列を作成します。 | |
static Matrix | Translation (const Vector3 &vec) |
平行移動行列を作成します。 | |
static Matrix | RotationX (float r) |
X 軸を回転軸にして回転する行列を作成します。 | |
static Matrix | RotationY (float r) |
Y 軸を回転軸にして回転する行列を作成します。 | |
static Matrix | RotationZ (float r) |
Z 軸を回転軸にして回転する行列を作成します。 | |
static Matrix | RotationAxis (const Vector3 &axis, float r) |
回転軸と角度を指定して行列を作成します。 | |
static Matrix | RotationQuaternion (const Quaternion &qua) |
クォータニオンから回転行列を作成します。 | |
static Matrix | RotationEulerAngles (float x, float y, float z, RotationOrder order=RotationOrder_ZXY) |
XYZ 各軸のオイラー角から回転行列を作成します。 | |
static Matrix | RotationEulerAngles (const Vector3 &angles, RotationOrder order=RotationOrder_ZXY) |
XYZ 各軸のオイラー角から回転行列を作成します。 | |
static Matrix | RotationYawPitchRoll (float yaw, float pitch, float roll) |
ヨー、ピッチ、ロールを指定して行列を作成します。 | |
static Matrix | Scaling (float x, float y, float z) |
各軸にそってスケーリングする行列を作成します。 | |
static Matrix | Scaling (const Vector3 &vec) |
各軸にそってスケーリングする行列を作成します。 | |
static Matrix | Scaling (float xyz) |
各軸にそってスケーリングする行列を作成します。 | |
static Matrix | Inverse (const Matrix &mat) |
指定された行列の逆行列を作成します。 | |
static Matrix | Transpose (const Matrix &mat) |
指定された行列の転置行列を作成します。 | |
static Matrix | Reflection (const Plane &plane) |
平面に対して座標系を反転した行列を作成します。 | |
static Matrix | LookAtLH (const Vector3 &position, const Vector3 &lookAt, const Vector3 &up) |
左手座標系ビュー行列を作成します。 | |
static Matrix | LookAtRH (const Vector3 &position, const Vector3 &lookAt, const Vector3 &up) |
右手座標系ビュー行列を作成します。 | |
static Matrix | PerspectiveFovLH (float fovY, float aspect, float near, float far) |
右手座標系パースペクティブ射影行列を作成します。 | |
static Matrix | PerspectiveFovRH (float fovY, float aspect, float near, float far) |
右手座標系パースペクティブ射影行列を作成します。 | |
static Matrix | OrthoLH (float width, float height, float near, float far) |
右手座標系正射影行列を作成します。 | |
static Matrix | OrthoRH (float width, float height, float near, float far) |
右手座標系正射影行列を作成します。 | |
static Matrix | AffineTransformation (const Vector3 &scaling, const Vector3 &rotationCenter, const Quaternion &rotation, const Vector3 &translation) |
アフィン変換行列を作成します。 | |
Public Attributes | |
union { | |
struct { | |
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 | |
} | |
float M [4][4] | |
float m [16] | |
}; | |
Static Public Attributes | |
static const Matrix | Identity |
単位行列 | |
Friends | |
Matrix | operator* (const Matrix &mat1, const Matrix &mat2) |
Matrix | operator* (const Matrix &mat1, float v) |
4x4 の行列を定義します。
行列は行優先で、これは DirectX の定義と同じです。
このクラスは似た機能の static 関数とインスタンス関数があります。 例えば RotationX(static 関数) と RotateX(インスタンス関数) です。 前者は新しい行列を作成して返すのに対し、後者は現在の行列を変更します。 例えば、以下の m1 と m2 は同じ結果になります。
Matrix m1 = Matrix::RotationX(0.1) * Matrix::RotationY(0.2) * Matrix::RotationZ(0.3); Matrix m2; m2.RotateX(0.1); m2.RotateY(0.2); m2.RotateZ(0.3);
なお、後者は行列の生成と乗算をまとめて行うように最適化されており、高速に動作します。
static Matrix Lumino::Matrix::AffineTransformation | ( | const Vector3 & | scaling, |
const Vector3 & | rotationCenter, | ||
const Quaternion & | rotation, | ||
const Vector3 & | translation | ||
) | [static] |
アフィン変換行列を作成します。
[in] | scaling | : スケーリング係数 |
[in] | rotationCenter | : 回転の中心位置 |
[in] | rotation | : 回転 |
[in] | translation | : 平行移動 |
void Lumino::Matrix::Decompose | ( | Vector3 * | scale, |
Quaternion * | rotation, | ||
Vector3 * | translation | ||
) | const |
この行列をスケーリング、回転、移動要素に分解します。
[in] | scale | : スケーリング要素を格納するベクトルのポインタ |
[in] | rotation | : 回転要素を格納するクォータニオンのポインタ |
[in] | translation | : 平行移動要素を格納するベクトルのポインタ |
各引数は必要が無ければ NULL を指定できます。
void Lumino::Matrix::DecomposeMatrices | ( | Matrix * | scale, |
Matrix * | rotation, | ||
Matrix * | translation | ||
) | const |
この行列をスケーリング、回転、移動行列に分解します。
[in] | scale | : スケーリング行列を格納する変数のポインタ |
[in] | rotation | : 回転行列を格納する変数のポインタ |
[in] | translation | : 平行移動行列を格納する変数のポインタ |
各引数は必要が無ければ NULL を指定できます。
Matrix Lumino::Matrix::GetRotationMatrix | ( | ) | const |
この行列の行要から回転行列を取り出します。
分解ではなく、単純に3x3の部分をコピーします。 それ以外の要素は単位行列の値で初期化されます。
static Matrix Lumino::Matrix::Inverse | ( | const Matrix & | mat | ) | [static] |
指定された行列の逆行列を作成します。
[in] | mat | : 処理の基になる行列 |
bool Lumino::Matrix::IsIdentity | ( | ) | const [inline] |
この行列が単位行列であるかを判定します。
static Matrix Lumino::Matrix::LookAtLH | ( | const Vector3 & | position, |
const Vector3 & | lookAt, | ||
const Vector3 & | up | ||
) | [static] |
左手座標系ビュー行列を作成します。
[in] | position | : 視点の位置 |
[in] | lookAt | : 注視点 |
[in] | up | : 上方向 |
static Matrix Lumino::Matrix::LookAtRH | ( | const Vector3 & | position, |
const Vector3 & | lookAt, | ||
const Vector3 & | up | ||
) | [static] |
右手座標系ビュー行列を作成します。
[in] | position | : 視点の位置 |
[in] | lookAt | : 注視点 |
[in] | up | : 上方向 |
static Matrix Lumino::Matrix::Multiply | ( | const Matrix & | mat1, |
const Matrix & | mat2 | ||
) | [static] |
2つのク行列の積を計算します。
[in] | mat1 | : 処理の基になる行列 |
[in] | mat2 | : 処理の基になる行列 |
static Matrix Lumino::Matrix::OrthoLH | ( | float | width, |
float | height, | ||
float | near, | ||
float | far | ||
) | [static] |
右手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
static Matrix Lumino::Matrix::OrthoRH | ( | float | width, |
float | height, | ||
float | near, | ||
float | far | ||
) | [static] |
右手座標系正射影行列を作成します。
[in] | width | : スクリーンの幅 |
[in] | height | : スクリーンの高さ |
[in] | near | : 一番近いビュー平面の Z 値 |
[in] | far | : 一番遠いビュー平面の Z 値 |
static Matrix Lumino::Matrix::PerspectiveFovLH | ( | float | fovY, |
float | aspect, | ||
float | near, | ||
float | far | ||
) | [static] |
右手座標系パースペクティブ射影行列を作成します。
[in] | fovY | : Y 方向への視野角 (ラジアン単位) |
[in] | aspect | : アスペクト比 (横幅/高さ) |
[in] | near | : 近いビュー平面の Z 値 |
[in] | far | : 遠いビュー平面の Z 値 |
static Matrix Lumino::Matrix::PerspectiveFovRH | ( | float | fovY, |
float | aspect, | ||
float | near, | ||
float | far | ||
) | [static] |
右手座標系パースペクティブ射影行列を作成します。
[in] | fovY | : Y 方向への視野角 (ラジアン単位) |
[in] | aspect | : アスペクト比 (横幅/高さ) |
[in] | near | : 近いビュー平面の Z 値 |
[in] | far | : 遠いビュー平面の Z 値 |
void Lumino::Matrix::Print | ( | const char * | format = NULL , |
FILE * | stream = NULL |
||
) | const |
デバッグ用に文字列を標準出力します。
[in] | format | : 書式指定文字列 |
[in] | stream | : 出力先ストリーム |
format が NULL の場合、書式は "%f, %f, %f, %f\n %f, %f, %f, %f\n %f, %f, %f, %f\n %f, %f, %f, %f\n" を使用します。
static Matrix Lumino::Matrix::Reflection | ( | const Plane & | plane | ) | [static] |
平面に対して座標系を反転した行列を作成します。
[in] | mat | : 処理の基になる行列 |
[in] | plane | : 処理の基になる平面 |
plane は正規化してから計算を行います。
void Lumino::Matrix::RotateAxis | ( | const Vector3 & | axis, |
float | r | ||
) |
この行列を任意軸で回転します。
[in] | axis | : 回転軸 |
[in] | r | : 回転角度 (ラジアン単位) |
axis が単位ベクトルでない場合は正規化してから計算を行います。
void Lumino::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 Lumino::Matrix::RotateEulerAngles | ( | const Vector3 & | angles, |
RotationOrder | order = RotationOrder_ZXY |
||
) |
この行列を XYZ 各軸のオイラー角を指定して回転します。
[in] | angles | : XYZ 各軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
void Lumino::Matrix::RotateQuaternion | ( | const Quaternion & | qua | ) |
この行列を指定したクォータニオンで回転します。
[in] | qua | : 処理の基になるクォータニオン |
void Lumino::Matrix::RotateX | ( | float | r | ) |
この行列を X 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
void Lumino::Matrix::RotateY | ( | float | r | ) |
この行列を Y 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
void Lumino::Matrix::RotateZ | ( | float | r | ) |
この行列を Z 軸で回転します。
[in] | r | : 回転角度 (ラジアン単位) |
static Matrix Lumino::Matrix::RotationAxis | ( | const Vector3 & | axis, |
float | r | ||
) | [static] |
回転軸と角度を指定して行列を作成します。
[in] | axis | : 回転軸 |
[in] | r | : 回転角度 (ラジアン単位) |
axis が単位ベクトルでない場合は正規化してから計算を行います。
static Matrix Lumino::Matrix::RotationEulerAngles | ( | float | x, |
float | y, | ||
float | z, | ||
RotationOrder | order = RotationOrder_ZXY |
||
) | [static] |
XYZ 各軸のオイラー角から回転行列を作成します。
[in] | x | : X 軸の回転角度 (ラジアン単位) |
[in] | y | : Y 軸の回転角度 (ラジアン単位) |
[in] | z | : Z 軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
static Matrix Lumino::Matrix::RotationEulerAngles | ( | const Vector3 & | angles, |
RotationOrder | order = RotationOrder_ZXY |
||
) | [static] |
XYZ 各軸のオイラー角から回転行列を作成します。
[in] | angles | : XYZ 各軸の回転角度 (ラジアン単位) |
[in] | order | : 回転順序 |
static Matrix Lumino::Matrix::RotationQuaternion | ( | const Quaternion & | qua | ) | [static] |
クォータニオンから回転行列を作成します。
[in] | qua | : 処理の基になるクォータニオン |
static Matrix Lumino::Matrix::RotationX | ( | float | r | ) | [static] |
X 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
static Matrix Lumino::Matrix::RotationY | ( | float | r | ) | [static] |
Y 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
static Matrix Lumino::Matrix::RotationYawPitchRoll | ( | float | yaw, |
float | pitch, | ||
float | roll | ||
) | [static] |
ヨー、ピッチ、ロールを指定して行列を作成します。
[in] | yaw | : y 軸を中心とするヨー (ラジアン単位) |
[in] | pitch | : x 軸を中心とするピッチ (ラジアン単位) |
[in] | roll | : z 軸を中心とするロール (ラジアン単位) |
回転順序は Z → X → Y です。引数の並びとは逆順であることに注意してください。 これは D3DXMatrixRotationYawPitchRoll の回転順序と同じで、 RotationEulerAngles に RotationOrder_ZXY を指定して計算した結果とも同じです。
static Matrix Lumino::Matrix::RotationZ | ( | float | r | ) | [static] |
Z 軸を回転軸にして回転する行列を作成します。
[in] | r | : 回転角度 (ラジアン単位) |
void Lumino::Matrix::Scale | ( | float | x, |
float | y, | ||
float | z | ||
) |
この行列を各軸にそってスケーリングします。
[in] | x | : X 軸の拡縮率 |
[in] | y | : Y 軸の拡縮率 |
[in] | z | : Z 軸の拡縮率 |
void Lumino::Matrix::Scale | ( | const Vector3 & | vec | ) |
この行列を各軸にそってスケーリングします。
[in] | vec | : 各軸の拡縮率 |
void Lumino::Matrix::Scale | ( | float | xyz | ) |
この行列を各軸にそってスケーリングします。
[in] | xyz | : 全ての軸の拡縮率 |
static Matrix Lumino::Matrix::Scaling | ( | float | x, |
float | y, | ||
float | z | ||
) | [static] |
各軸にそってスケーリングする行列を作成します。
[in] | x | : X 軸の拡縮率 |
[in] | y | : Y 軸の拡縮率 |
[in] | z | : Z 軸の拡縮率 |
static Matrix Lumino::Matrix::Scaling | ( | const Vector3 & | vec | ) | [static] |
各軸にそってスケーリングする行列を作成します。
[in] | vec | : 各軸の拡縮率 |
static Matrix Lumino::Matrix::Scaling | ( | float | xyz | ) | [static] |
各軸にそってスケーリングする行列を作成します。
[in] | xyz | : 全ての軸の拡縮率 |
Vector3 Lumino::Matrix::ToEulerAngles | ( | RotationOrder | order = RotationOrder_ZXY , |
bool * | locked = NULL |
||
) | const |
この回転行列を XYZ 各軸のオイラー角度に変換します。
[in] | order | : 回転順序 |
[in] | locked | : ジンバルロックの発生有無を格納する変数へのポインタ (ジンバルロックが発生した場合 true) |
回転行列は order に指定された順序で乗算されたものでなければ本来の回転角度が取得できないことに注意してください。
例えば RotationYawPitchRoll() は、回転軸 Z → Y → X の順に回転を行いますが、 これから元の角度を取り出すには RotationOrder_ZXY を指定します。
void Lumino::Matrix::Translate | ( | float | x, |
float | y, | ||
float | z | ||
) |
この行列を平行移動します。
[in] | x | : X 軸の移動量 |
[in] | y | : Y 軸の移動量 |
[in] | z | : Z 軸の移動量 |
void Lumino::Matrix::Translate | ( | const Vector3 & | vec | ) |
この行列を平行移動します。
[in] | vec | : 移動量 |
static Matrix Lumino::Matrix::Translation | ( | float | x, |
float | y, | ||
float | z | ||
) | [static] |
平行移動行列を作成します。
[in] | x | : X 軸の移動量 |
[in] | y | : Y 軸の移動量 |
[in] | z | : Z 軸の移動量 |
static Matrix Lumino::Matrix::Translation | ( | const Vector3 & | vec | ) | [static] |
平行移動行列を作成します。
[in] | vec | : 移動量 |
static Matrix Lumino::Matrix::Transpose | ( | const Matrix & | mat | ) | [static] |
指定された行列の転置行列を作成します。
[in] | mat | : 処理の基になる行列 |