Changeset 15 in flair-src for trunk/lib/FlairSimulator/src/Simulator.cpp
- Timestamp:
- 04/08/16 15:40:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSimulator/src/Simulator.cpp
r10 r15 27 27 using namespace flair::core; 28 28 29 namespace 30 { 31 flair::simulator::Simulator* simu=NULL; 29 namespace { 30 flair::simulator::Simulator *simu = NULL; 32 31 } 33 32 34 namespace flair 35 { 36 namespace simulator 37 { 33 namespace flair { 34 namespace simulator { 38 35 39 Simulator* getSimulator(void) { 40 return simu; 36 Simulator *getSimulator(void) { return simu; } 37 38 Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg) 39 : FrameworkManager(name) { 40 if (simu != NULL) 41 Err("Simulator should be instanced only one time\n"); 42 43 pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg); 44 simu = this; 41 45 } 42 46 43 Simulator::Simulator(string name,int optitrack_mstime,float yaw_deg): FrameworkManager(name) 44 { 45 if(simu!=NULL) Err("Simulator should be instanced only one time\n"); 46 47 pimpl_=new Simulator_impl(this,optitrack_mstime,yaw_deg); 48 simu=this; 49 } 50 51 Simulator::~Simulator() 52 { 53 delete pimpl_; 54 } 47 Simulator::~Simulator() { delete pimpl_; } 55 48 56 49 Quaternion Simulator::ToVRPNReference(Quaternion quat_in) { 57 Quaternion yaw_rot_quat; 58 Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference 59 yaw_rot_euler.ToQuaternion(yaw_rot_quat); 50 Quaternion yaw_rot_quat; 51 Euler yaw_rot_euler( 52 0, 0, -pimpl_->yaw_rad); // yaw_rad is vrpn rotation in earth reference 53 yaw_rot_euler.ToQuaternion(yaw_rot_quat); 60 54 61 return yaw_rot_quat*quat_in;55 return yaw_rot_quat * quat_in; 62 56 } 63 57 64 58 Vector3D Simulator::ToVRPNReference(Vector3D point_in) { 65 Quaternion yaw_rot_quat; 66 Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference 67 yaw_rot_euler.ToQuaternion(yaw_rot_quat); 68 point_in.Rotate(yaw_rot_quat); 59 Quaternion yaw_rot_quat; 60 Euler yaw_rot_euler( 61 0, 0, -pimpl_->yaw_rad); // yaw_rad is vrpn rotation in earth reference 62 yaw_rot_euler.ToQuaternion(yaw_rot_quat); 63 point_in.Rotate(yaw_rot_quat); 69 64 70 65 return point_in; 71 66 } 72 67 73 float Simulator::Yaw(void) const 74 { 75 return pimpl_->yaw_rad; 76 } 68 float Simulator::Yaw(void) const { return pimpl_->yaw_rad; } 77 69 78 void Simulator::RunSimu(void) 79 { 80 pimpl_->RunSimu(); 81 } 70 void Simulator::RunSimu(void) { pimpl_->RunSimu(); } 82 71 83 72 } // end namespace simulator
Note:
See TracChangeset
for help on using the changeset viewer.