Matrix3D(API)

提供: Eospedia
2014年5月16日 (金) 02:15時点におけるKinoshita (トーク | 投稿記録)による版

移動: 案内検索

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); 

ファイルとやり取り

extern void matrix3DFileFormat(FILE* fpt);
extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix);
extern void matrix3DFileWrite(FILE* fpt, Matrix3D Matrix);

3次元行列の設定

extern void matrix3DRotationSet(Matrix3D Matrix, char mode, matrix3DParaTypeReal rot, long Mode);
extern void matrix3DTranslationSet(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 matrix3DRotationSetZXY(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode);
extern void matrix3DRotationSetYXZ(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode);

3次元行列のオイラー角による指定

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 matrix3DEulerAngleGetFromMatrix3D(Matrix3D Matrix, const char Mode[4], matrix3DParaTypeReal* rot1, matrix3DParaTypeReal* rot2, matrix3DParaTypeReal* rot3, long mode);