radarmerge.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "radarmerge.h"
  2. #include <QDateTime>
  3. #include <math.h>
  4. static int g_seq = 0;
  5. iv::radar::radarobjectarray mergefunc(std::vector<iv::radar_data> xvectorradar)
  6. {
  7. iv::radar::radarobjectarray xradararray;
  8. xradararray.set_mstime(QDateTime::currentMSecsSinceEpoch());
  9. int i,j;
  10. for(i=0;i<xvectorradar.size();i++)
  11. {
  12. double cos_rotation,sin_rotation;
  13. cos_rotation = cos(xvectorradar[i].frotation);
  14. sin_rotation = sin(xvectorradar[i].frotation);
  15. if(xvectorradar[i].bUpdate)
  16. {
  17. for(j=0;j<xvectorradar[i].xradararray.obj_size();j++)
  18. {
  19. iv::radar::radarobject * pobj = xradararray.add_obj();
  20. pobj->CopyFrom(xvectorradar[i].xradararray.obj(j));
  21. double x,y;
  22. x = pobj->x();y = pobj->y();
  23. x = pobj->x()*cos_rotation +pobj->y()*sin_rotation;
  24. y = pobj->y()*cos_rotation - pobj->x()*sin_rotation;
  25. pobj->set_x(x + xvectorradar[i].foff_x);pobj->set_y(y + xvectorradar[i].foff_y);
  26. x = pobj->vx();y = pobj->vy();
  27. x = pobj->vx()*cos_rotation +pobj->vy()*sin_rotation;
  28. y = pobj->vy()*cos_rotation - pobj->vx()*sin_rotation;
  29. pobj->set_vx(x);pobj->set_vy(y);
  30. }
  31. }
  32. }
  33. return xradararray;
  34. }