Guest User

Untitled

a guest
Feb 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.21 KB | None | 0 0
  1.     class qpoint3d
  2.     {
  3.     public:
  4.         float x;
  5.         float y;
  6.         float z;
  7.  
  8.         qpoint3d(){x=y=x=0;}
  9.         qpoint3d(float x,float y,float z) : x(x),y(y),z(z){}
  10.     };
  11.  
  12.     class worldqpoint3d
  13.     {
  14.     public:
  15.         qpoint3d osp;//Object Space qpoint
  16.         qpoint3d wsp;//World Space qpoint
  17.  
  18.         worldqpoint3d()
  19.         {
  20.         }
  21.         worldqpoint3d(float x,float y,float z) : osp(x,y,z){}
  22.     };
  23.  
  24.     class worldqpoint3drot:public worldqpoint3d
  25.     {
  26.     public:
  27.         float yaw;
  28.         float pitch;
  29.         float roll;
  30.         worldqpoint3drot()
  31.         {
  32.             yaw=pitch=roll=0;
  33.         }
  34.         worldqpoint3drot(float x,float y,float z,float Yaw,float Pitch,float Roll)
  35.         {
  36.             osp=qpoint3d(x,y,z);
  37.             yaw=Yaw;
  38.             pitch=Pitch;
  39.             roll=Roll;
  40.         }
  41.  
  42.         void rotate2d(float& X,float& Y,float angle)
  43.         {
  44.             if(angle)  //the same as if(angle!=0)   != means NOT EQUAL
  45.             {
  46.                 float NewX=X*cos(angle)-Y*sin(angle);
  47.                 float NewY=X*sin(angle)+Y*cos(angle);
  48.                 X=NewX;
  49.                 Y=NewY;
  50.             }
  51.         }
  52.  
  53.     };
  54.  
  55.  
  56.     class qpointcloud:public worldqpoint3drot
  57.     {
  58.     public:
  59.         CString name;
  60.         vector<worldqpoint3d> qpoints;
  61.  
  62.         void rotateqpoints()
  63.         {
  64.             for(int i=0;i<qpoints.size();i++)
  65.             {
  66.                 rotateqpoint(qpoints[i]);
  67.             }
  68.         }
  69.         qpointcloud(CString Name,float X=0,float Y=0,float Z=0,float Pitch=0,float Yaw=0,float Roll=0)
  70.         {
  71.             name=Name;
  72.             osp.x=X;
  73.             osp.y=Y;
  74.             osp.z=Z;
  75.             pitch=Pitch;
  76.             yaw=Yaw;
  77.             roll=Roll;
  78.         }
  79.     private:
  80.         void rotateqpoint(worldqpoint3d& qPoint)
  81.         {
  82.             qPoint.wsp=qPoint.osp;
  83.             rotate2d(qPoint.wsp.y,qPoint.wsp.z,roll);
  84.             rotate2d(qPoint.wsp.x,qPoint.wsp.z,pitch);
  85.             rotate2d(qPoint.wsp.x,qPoint.wsp.y,yaw);
  86.             qPoint.wsp.x+=wsp.x;
  87.             qPoint.wsp.y+=wsp.y;
  88.             qPoint.wsp.z+=wsp.z;
  89.         }
  90.     };
  91.  
  92.     class world:public worldqpoint3drot
  93.     {
  94.     private:
  95.  
  96.         void rotateqpoint(worldqpoint3d& qPoint)
  97.         {
  98.             qPoint.wsp=qPoint.osp;
  99.             rotate2d(qPoint.wsp.x,qPoint.wsp.y,roll);
  100.             rotate2d(qPoint.wsp.y,qPoint.wsp.z,pitch);
  101.             rotate2d(qPoint.wsp.x,qPoint.wsp.z,yaw);
  102.             qPoint.wsp.x-=osp.x;
  103.             qPoint.wsp.y-=osp.y;
  104.             qPoint.wsp.z-=osp.z;
  105.         }
  106.  
  107.  
  108.     public:
  109.         vector<qpointcloud> qpoints;
  110.         void rotateqpoints()
  111.         {
  112.             for(int i=0;i<qpoints.size();i++)
  113.             {
  114.                
  115.                 rotateqpoint(qpoints[i]);
  116.                 qpoints[i].rotateqpoints();
  117.                
  118.                
  119.             }
  120.         }
  121.     };
  122.  
  123.     world World;
Add Comment
Please, Sign In to add comment