145 lines
2.8 KiB
C
145 lines
2.8 KiB
C
|
#ifndef _QUATERNION_H_
|
|||
|
#define _QUATERNION_H_
|
|||
|
|
|||
|
typedef struct _MagCaliParam
|
|||
|
{
|
|||
|
float xOffset;
|
|||
|
float yOffset;
|
|||
|
float zOffset;
|
|||
|
float xScale;
|
|||
|
float yScale;
|
|||
|
float zScale;
|
|||
|
}MagCaliParam;
|
|||
|
|
|||
|
typedef struct _Quaternion
|
|||
|
{
|
|||
|
float w,x,y,z;
|
|||
|
}Quaternion;
|
|||
|
|
|||
|
|
|||
|
typedef struct _Vector3
|
|||
|
{
|
|||
|
float x,y,z;
|
|||
|
}Vector3;
|
|||
|
|
|||
|
typedef struct _EulerAngles{
|
|||
|
float Yaw;
|
|||
|
float Roll;
|
|||
|
float Pitch;
|
|||
|
}EulerAngles;
|
|||
|
|
|||
|
typedef struct _MVector3
|
|||
|
{
|
|||
|
float v[3];
|
|||
|
}MVector3;
|
|||
|
|
|||
|
|
|||
|
typedef struct _Matrix3
|
|||
|
{
|
|||
|
float m[3][3];
|
|||
|
}Matrix3;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C"{
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x,y,z<><7A><EFBFBD>ƴ˵<C6B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תangle<6C>Ƕȣ<C7B6><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>*/
|
|||
|
Quaternion CreateQuaternion(float angle,Vector3 v);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵Ľ<CBB5><C4BD><EFBFBD>*/
|
|||
|
Quaternion QuaternionMulti(Quaternion q1,Quaternion q2);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>*/
|
|||
|
Quaternion QuaternionConjugate(Quaternion q1);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>ģ*/
|
|||
|
float QuaternionMod(Quaternion q1);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
Quaternion QuaternionInversion(Quaternion q1);
|
|||
|
|
|||
|
void DisplayQuaternion(Quaternion q);
|
|||
|
|
|||
|
Quaternion EulerAnglesToQuaternion(EulerAngles e);
|
|||
|
|
|||
|
//EulerAngles QuaternionToEulerAngles(Quaternion q,bool useRefer);
|
|||
|
|
|||
|
void DisplayEulerAngles(EulerAngles e);
|
|||
|
|
|||
|
//void SetEulerAngles(EulerAngles *e,float Yaw,float Pitch,float Roll);
|
|||
|
|
|||
|
EulerAngles SetEulerAngles(float Yaw,float Pitch,float Roll);
|
|||
|
|
|||
|
/*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ture<72><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false*/
|
|||
|
bool QuaternionEqual(Quaternion q1,Quaternion q2);
|
|||
|
|
|||
|
|
|||
|
Vector3 SetVector3(float x,float y,float z);
|
|||
|
|
|||
|
Quaternion CreateQuaternionByGyro(float gx,float gy,float gz);
|
|||
|
|
|||
|
|
|||
|
Matrix3 QuaternionToMatrix(Quaternion q);
|
|||
|
|
|||
|
|
|||
|
MVector3 ComputeRotate(Matrix3 mMatrix,MVector3 vec);
|
|||
|
|
|||
|
EulerAngles MathQuaternionToEulerAngles(Quaternion q);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#else
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x,y,z<><7A><EFBFBD>ƴ˵<C6B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תangle<6C>Ƕȣ<C7B6><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>*/
|
|||
|
Quaternion CreateQuaternion(float angle,Vector3 v);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵Ľ<CBB5><C4BD><EFBFBD>*/
|
|||
|
Quaternion QuaternionMulti(Quaternion q1,Quaternion q2);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>*/
|
|||
|
Quaternion QuaternionConjugate(Quaternion q1);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>ģ*/
|
|||
|
float QuaternionMod(Quaternion q1);
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
Quaternion QuaternionInversion(Quaternion q1);
|
|||
|
|
|||
|
void DisplayQuaternion(Quaternion q);
|
|||
|
|
|||
|
Quaternion EulerAnglesToQuaternion(EulerAngles e);
|
|||
|
|
|||
|
//EulerAngles QuaternionToEulerAngles(Quaternion q,bool useRefer);
|
|||
|
|
|||
|
void DisplayEulerAngles(EulerAngles e);
|
|||
|
|
|||
|
void SetEulerAngles(EulerAngles *e,float Yaw,float Pitch,float Roll);
|
|||
|
|
|||
|
//EulerAngles SetEulerAngles(float Yaw,float Pitch,float Roll);
|
|||
|
|
|||
|
/*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ture<72><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false*/
|
|||
|
//bool QuaternionEqual(Quaternion q1,Quaternion q2);
|
|||
|
|
|||
|
|
|||
|
Vector3 SetVector3(float x,float y,float z);
|
|||
|
|
|||
|
Quaternion CreateQuaternionByGyro(float gx,float gy,float gz);
|
|||
|
|
|||
|
|
|||
|
Matrix3 QuaternionToMatrix(Quaternion q);
|
|||
|
|
|||
|
|
|||
|
MVector3 ComputeRotate(Matrix3 mMatrix,MVector3 vec);
|
|||
|
|
|||
|
EulerAngles MathQuaternionToEulerAngles(Quaternion q);
|
|||
|
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif
|