Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class qpoint3d
- {
- public:
- float x;
- float y;
- float z;
- qpoint3d(){x=y=x=0;}
- qpoint3d(float x,float y,float z) : x(x),y(y),z(z){}
- };
- class worldqpoint3d
- {
- public:
- qpoint3d osp;//Object Space qpoint
- qpoint3d wsp;//World Space qpoint
- worldqpoint3d()
- {
- }
- worldqpoint3d(float x,float y,float z) : osp(x,y,z){}
- };
- class worldqpoint3drot:public worldqpoint3d
- {
- public:
- float yaw;
- float pitch;
- float roll;
- worldqpoint3drot()
- {
- yaw=pitch=roll=0;
- }
- worldqpoint3drot(float x,float y,float z,float Yaw,float Pitch,float Roll)
- {
- osp=qpoint3d(x,y,z);
- yaw=Yaw;
- pitch=Pitch;
- roll=Roll;
- }
- void rotate2d(float& X,float& Y,float angle)
- {
- if(angle) //the same as if(angle!=0) != means NOT EQUAL
- {
- float NewX=X*cos(angle)-Y*sin(angle);
- float NewY=X*sin(angle)+Y*cos(angle);
- X=NewX;
- Y=NewY;
- }
- }
- };
- class qpointcloud:public worldqpoint3drot
- {
- public:
- CString name;
- vector<worldqpoint3d> qpoints;
- void rotateqpoints()
- {
- for(int i=0;i<qpoints.size();i++)
- {
- rotateqpoint(qpoints[i]);
- }
- }
- qpointcloud(CString Name,float X=0,float Y=0,float Z=0,float Pitch=0,float Yaw=0,float Roll=0)
- {
- name=Name;
- osp.x=X;
- osp.y=Y;
- osp.z=Z;
- pitch=Pitch;
- yaw=Yaw;
- roll=Roll;
- }
- private:
- void rotateqpoint(worldqpoint3d& qPoint)
- {
- qPoint.wsp=qPoint.osp;
- rotate2d(qPoint.wsp.y,qPoint.wsp.z,roll);
- rotate2d(qPoint.wsp.x,qPoint.wsp.z,pitch);
- rotate2d(qPoint.wsp.x,qPoint.wsp.y,yaw);
- qPoint.wsp.x+=wsp.x;
- qPoint.wsp.y+=wsp.y;
- qPoint.wsp.z+=wsp.z;
- }
- };
- class world:public worldqpoint3drot
- {
- private:
- void rotateqpoint(worldqpoint3d& qPoint)
- {
- qPoint.wsp=qPoint.osp;
- rotate2d(qPoint.wsp.x,qPoint.wsp.y,roll);
- rotate2d(qPoint.wsp.y,qPoint.wsp.z,pitch);
- rotate2d(qPoint.wsp.x,qPoint.wsp.z,yaw);
- qPoint.wsp.x-=osp.x;
- qPoint.wsp.y-=osp.y;
- qPoint.wsp.z-=osp.z;
- }
- public:
- vector<qpointcloud> qpoints;
- void rotateqpoints()
- {
- for(int i=0;i<qpoints.size();i++)
- {
- rotateqpoint(qpoints[i]);
- qpoints[i].rotateqpoints();
- }
- }
- };
- world World;
Add Comment
Please, Sign In to add comment