「Matrix3D(API)」の版間の差分
提供: Eospedia
細 (Kinoshita がページ「Matrix3D」を「Matrix3D(API)」に移動しました: コマンド及び他の記事との重複を避けるため) |
|||
行1: | 行1: | ||
− | General/'''Matrix3D''' | + | General/'''Matrix3D'''は、3次元変換のための行列に関するAPI です。 |
== 定数 == | == 定数 == | ||
+ | 行・列成分の次元 | ||
#define MATRIX_3D_WIDTH 4 | #define MATRIX_3D_WIDTH 4 | ||
#define MATRIX_3D_HEIGHT 4 | #define MATRIX_3D_HEIGHT 4 | ||
+ | |||
+ | 初期化判定(0: 初期化しない, 1: 初期化する) | ||
#define MATRIX_3D_MODE_NOT_INITIALIZE 0 | #define MATRIX_3D_MODE_NOT_INITIALIZE 0 | ||
#define MATRIX_3D_MODE_INITIALIZE 1 | #define MATRIX_3D_MODE_INITIALIZE 1 | ||
+ | |||
#define MATRIX_3D_NEGLECT_VALUE 1e-6 | #define MATRIX_3D_NEGLECT_VALUE 1e-6 | ||
行13: | 行17: | ||
== API == | == API == | ||
− | + | ===行列の初期化=== | |
− | + | ||
extern void matrix3DInit(Matrix3D Matrix); | extern void matrix3DInit(Matrix3D Matrix); | ||
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); | ||
− | + | ===ファイルとやり取り=== | |
extern void matrix3DFileFormat(FILE* fpt); | extern void matrix3DFileFormat(FILE* fpt); | ||
extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix); | extern void matrix3DFileRead(FILE* fpt, Matrix3D Matrix); | ||
extern void matrix3DFileWrite(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 matrix3DRotationSet(Matrix3D Matrix, char mode, matrix3DParaTypeReal rot, long Mode); | ||
extern void matrix3DTranslationSet(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | extern void matrix3DTranslationSet(Matrix3D Matrix, matrix3DParaTypeReal rotx, matrix3DParaTypeReal roty, matrix3DParaTypeReal rotz, long mode); | ||
行41: | 行46: | ||
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); | ||
− | + | ===3次元行列の[[オイラー角]]による指定=== | |
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); | ||
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年5月16日 (金) 01:26時点における版
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
行列の初期化
extern void matrix3DInit(Matrix3D Matrix); 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);