「Matrix3D(API)」の版間の差分
提供: Eospedia
(ページの作成:「General/'''Matrix3D'''は、3次元変換のためのAPI です。 == 構造体 == == API == *配列の初期化 extern void matrix3DInit(Matrix3D Matrix); extern v...」) |
(→API) |
||
(2人の利用者による、間の6版が非表示) | |||
行1: | 行1: | ||
− | General/'''Matrix3D''' | + | General/'''Matrix3D'''は、3次元変換のための行列に関するAPI です。 |
+ | |||
+ | == 定数 == | ||
+ | 行・列成分の次元 | ||
+ | #define MATRIX_3D_WIDTH 4 | ||
+ | #define MATRIX_3D_HEIGHT 4 | ||
+ | |||
+ | 初期化モード(0: 初期化しない, 1: 初期化する) | ||
+ | #define MATRIX_3D_MODE_NOT_INITIALIZE 0 | ||
+ | #define MATRIX_3D_MODE_INITIALIZE 1 | ||
+ | |||
+ | #define MATRIX_3D_NEGLECT_VALUE 1e-6 | ||
+ | |||
== 構造体 == | == 構造体 == | ||
+ | typedef float matrix3DParaTypeReal; | ||
+ | typedef matrix3DParaTypeReal Matrix3D[MATRIX_3D_WIDTH][MATRIX_3D_HEIGHT]; | ||
+ | typedef char matrix3DEulerAngleMode; | ||
== API == | == API == | ||
− | + | ===行列の初期化=== | |
− | + | 4x4の単位行列に初期化します。 | |
extern void matrix3DInit(Matrix3D Matrix); | extern void matrix3DInit(Matrix3D Matrix); | ||
+ | |||
+ | ===変換処理=== | ||
+ | 回転行列(2x2)から4x4行列を作成します。 | ||
extern void matrix3DFromRotationMatrix(Matrix3D dst, Array a); | extern void matrix3DFromRotationMatrix(Matrix3D dst, Array a); | ||
− | + | ===逆変換=== | |
+ | 逆変換用の行列に書き換えます。 | ||
extern void matrix3DInverse(Matrix3D mat); | extern void matrix3DInverse(Matrix3D mat); | ||
− | + | ===積演算=== | |
+ | 行列積 | ||
extern void matrix3DMultiply(Matrix3D A, Matrix3D B); /* A = A*B */ | extern void matrix3DMultiply(Matrix3D A, Matrix3D B); /* A = A*B */ | ||
extern void matrix3DMultiplyInv(Matrix3D A, Matrix3D B); /* B = A*B */ | extern void matrix3DMultiplyInv(Matrix3D A, Matrix3D B); /* B = A*B */ | ||
+ | ベクトルと行列の積 | ||
extern void matrix3DMultiplyVector(floatVector* v, Matrix3D A); | extern void matrix3DMultiplyVector(floatVector* v, Matrix3D A); | ||
extern void matrix3DMultiplyVectors(floatVector* vs, int n, Matrix3D A); | extern void matrix3DMultiplyVectors(floatVector* vs, int n, Matrix3D A); | ||
− | + | ===ファイル処理=== | |
− | + | ファイルfptを読み出して行列Matrixへ出力します。 | |
extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix); | extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix); | ||
+ | 行列Matrixをファイルfptへ書き込みます。 | ||
extern void matrix3DFileWrite(FILE* fpt, Matrix3D Matrix); | extern void matrix3DFileWrite(FILE* fpt, Matrix3D Matrix); | ||
+ | ヘルプをファイルfptへ出力します。 | ||
+ | extern void matrix3DFileFormat(FILE* fpt); | ||
− | + | === アフィン行列 === | |
+ | ==== 行列の算出 ==== | ||
+ | 回転角度から行列Matrixを算出します。<br> | ||
+ | mode: 回転軸名, rot: 回転角, Mode: 初期化フラグ | ||
extern void matrix3DRotationSet(Matrix3D Matrix, char mode, matrix3DParaTypeReal rot, long Mode); | extern void matrix3DRotationSet(Matrix3D Matrix, char mode, matrix3DParaTypeReal rot, long Mode); | ||
− | + | 指定した軸の順番によるrot毎の回転(mode: 初期化フラグ) | |
extern void matrix3DRotationSetXYZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | extern void matrix3DRotationSetXYZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | ||
extern void matrix3DRotationSetZYX(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | extern void matrix3DRotationSetZYX(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | ||
extern void matrix3DRotationSetZXY(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | extern void matrix3DRotationSetZXY(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | ||
extern void matrix3DRotationSetYXZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | extern void matrix3DRotationSetYXZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | ||
− | + | (rotx, roty, rotz)についての平行移動(mode: 初期化フラグ) | |
− | + | extern void matrix3DTranslationSet(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | |
+ | [[オイラー角]](Mode, rot1, rot2, rot3)による算出(mode: 初期化フラグ) | ||
extern void matrix3DRotationSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode); | extern void matrix3DRotationSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode); | ||
extern void matrix3DRotationAntiSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode); | extern void matrix3DRotationAntiSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode); | ||
+ | |||
+ | ==== 回転角の算出 ==== | ||
+ | 行列Matrixと[[オイラー角]]モードModeから回転角度rot1, rot2, rot3を算出します。 | ||
extern void matrix3DEulerAngleGetFromMatrix3D(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal* rot1, matrix3DParaTypeReal* rot2, matrix3DParaTypeReal* rot3, long mode); | extern void matrix3DEulerAngleGetFromMatrix3D(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal* rot1, matrix3DParaTypeReal* rot2, matrix3DParaTypeReal* rot3, long mode); |
2014年10月7日 (火) 05:46時点における最新版
General/Matrix3Dは、3次元変換のための行列に関するAPI です。
目次
定数
行・列成分の次元
#define MATRIX_3D_WIDTH 4 #define MATRIX_3D_HEIGHT 4
初期化モード(0: 初期化しない, 1: 初期化する)
#define MATRIX_3D_MODE_NOT_INITIALIZE 0 #define MATRIX_3D_MODE_INITIALIZE 1
#define MATRIX_3D_NEGLECT_VALUE 1e-6
構造体
typedef float matrix3DParaTypeReal; typedef matrix3DParaTypeReal Matrix3D[MATRIX_3D_WIDTH][MATRIX_3D_HEIGHT]; typedef char matrix3DEulerAngleMode;
API
行列の初期化
4x4の単位行列に初期化します。
extern void matrix3DInit(Matrix3D Matrix);
変換処理
回転行列(2x2)から4x4行列を作成します。
extern void matrix3DFromRotationMatrix(Matrix3D dst, Array a);
逆変換
逆変換用の行列に書き換えます。
extern void matrix3DInverse(Matrix3D mat);
積演算
行列積
extern void matrix3DMultiply(Matrix3D A, Matrix3D B); /* A = A*B */ extern void matrix3DMultiplyInv(Matrix3D A, Matrix3D B); /* B = A*B */
ベクトルと行列の積
extern void matrix3DMultiplyVector(floatVector* v, Matrix3D A); extern void matrix3DMultiplyVectors(floatVector* vs, int n, Matrix3D A);
ファイル処理
ファイルfptを読み出して行列Matrixへ出力します。
extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix);
行列Matrixをファイルfptへ書き込みます。
extern void matrix3DFileWrite(FILE* fpt, Matrix3D Matrix);
ヘルプをファイルfptへ出力します。
extern void matrix3DFileFormat(FILE* fpt);
アフィン行列
行列の算出
回転角度から行列Matrixを算出します。
mode: 回転軸名, rot: 回転角, Mode: 初期化フラグ
extern void matrix3DRotationSet(Matrix3D Matrix, char mode, matrix3DParaTypeReal rot, long Mode);
指定した軸の順番によるrot毎の回転(mode: 初期化フラグ)
extern void matrix3DRotationSetXYZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); extern void matrix3DRotationSetZYX(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); extern void matrix3DRotationSetZXY(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); extern void matrix3DRotationSetYXZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode);
(rotx, roty, rotz)についての平行移動(mode: 初期化フラグ)
extern void matrix3DTranslationSet(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode);
オイラー角(Mode, rot1, rot2, rot3)による算出(mode: 初期化フラグ)
extern void matrix3DRotationSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode); extern void matrix3DRotationAntiSetFollowingEulerAngle(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal rot1, matrix3DParaTypeReal rot2, matrix3DParaTypeReal rot3, long mode);
回転角の算出
行列Matrixとオイラー角モードModeから回転角度rot1, rot2, rot3を算出します。
extern void matrix3DEulerAngleGetFromMatrix3D(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal* rot1, matrix3DParaTypeReal* rot2, matrix3DParaTypeReal* rot3, long mode);