00001
00002
00003 #ifndef CAJUN_SIM_UTIL_H
00004 #define CAJUN_SIM_UTIL_H
00005
00006 #define D2R M_PI/180.0
00007 #define R2D 180.0/M_PI
00008
00009 #define POSX 0
00010 #define POSY 1
00011 #define POSZ 2
00012
00013 #define ANGLEX 0
00014 #define ANGLEY 1
00015 #define ANGLEZ 2
00016
00017 #include <iostream>
00018 #include "data_type.H"
00019 #include "cbmesg_logger.H"
00020
00021 using namespace std;
00022
00023 namespace cajun
00024 {
00025 class cbsim_utils_t
00026 {
00027 public:
00028 cbsim_utils_t ();
00029 void init ();
00030 void log (const char *message);
00031 private:
00032 cbmesg_logger_t m_cbmesg;
00033 };
00034
00035 struct orientation_t
00036 {
00037 double angleX, angleY, angleZ;
00038 };
00039
00040
00041 float calculate_angle (float pos1x, float pos1y, float pos2x, float pos2y);
00042 double sqr (double x);
00043 void HomogTformPt (double T[3][4], double x[3], double p[3]);
00044 void tform_mult (double a[3][4], double b[3][4], double c[3][4]);
00045 float radian (float te);
00046 float calculate_distance (float posx1,float posy1, float posz1,
00047 float posx2, float posy2, float posz2);
00048 float mod (float i);
00049 float angle (float x,float y);
00050 float distance (float x1,float y1, float x2,float y2);
00051 void my_sleep (double mSec);
00052 void load_ppm_p6 (char *fname, unsigned int *w, unsigned int *h,
00053 unsigned char **data, int mallocflag);
00054 void load_ppm_p3 (char *fname, unsigned int *w, unsigned int *h,
00055 unsigned char **data, int mallocflag);
00056 void Normal_Plane (float v[3],float x[3],float y[3],float z[3]);
00057 void Render_Polygon (float v[4][3],float color[3],int texon,char *ppmname);
00058 void Render_Quadric (int type,float radius,float outerradius,
00059 float length,float color[3],int texon,char *ppmname);
00060 void Render_box (float dimensions[3],float color[3],int texon,char *ppmname);
00061 void Render_Ground (float size,float color[3],int texon,char *ppmname);
00062 void Render_Sky (float size,float color[3],int texon,char *ppmname);
00063
00064 void get_rotation_matrix( double rot[16], double heading, double pitch,
00065 double roll);
00066 void matrix_to_euler (const double m[16], double &heading, double &attitude, double &bank);
00067 };
00068 #endif