platform.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "platform.h"
  2. Platform::Platform(QObject *parent, uint32_t ID, QString Name,
  3. double initlon, double initlat, double inith,
  4. double vx, double vy, double vz,
  5. double ax,double ay, double az) : QObject(parent)
  6. {
  7. this->ID = ID;
  8. this->Name = Name;
  9. lon = initlon;
  10. lat = initlat;
  11. h = inith;
  12. x = new double();
  13. y = new double();
  14. z = new double();
  15. blh2xyz(initlat,initlon,inith,x,y,z);
  16. this->vx = vx;
  17. this->vy = vy;
  18. this->vz = vz;
  19. this->ax = ax;
  20. this->ay = ay;
  21. this->az = az;
  22. TimerUpdatePos = startTimer(1000);
  23. }
  24. void Platform::UpdateAcc(double ax, double ay, double az)
  25. {
  26. this->ax = ax;
  27. this->ay = ay;
  28. this->az = az;
  29. }
  30. void Platform::UpdateVel(double vx, double vy, double vz)
  31. {
  32. this->vx = vx;
  33. this->vy = vy;
  34. this->vz = vz;
  35. }
  36. void Platform::timerEvent(QTimerEvent *event)
  37. {
  38. if (event->timerId() == TimerUpdatePos)
  39. {
  40. vx = vx + ax;
  41. vy = vy + ay;
  42. vz = vz + az;
  43. double vel = vx*vx + vy*vy +vz*vz;
  44. if (vel > 1e-5)
  45. {
  46. *x = *x + vx;
  47. *y = *y + vy;
  48. *z = *z + vz;
  49. double pos[3] = {*x,*y,*z};
  50. XYZ2ELL(pos,&lat,&lon,&h);
  51. qDebug() << this->Name << QString::fromLocal8Bit("位置更新");
  52. }
  53. }
  54. }