locate_algorithm.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _LOCATE_ALGORITHM_H
  2. #define _LOCATE_ALGORITHM_H
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "classdef.h"
  6. #include "tdoa/TDOAFunctor.h"
  7. #define M_PI 3.14159265358979323846 // 角度转弧度 角度 * pi / 180
  8. #define M_PI_2 1.57079632679489661923
  9. #define M_PI_4 0.785398163397448309616
  10. // 最终定位坐标计算公式
  11. void AOAformula(struct _coordinate* ant, double angle, struct _coordinate* tar, bool is_line = false, double z_offset = 0);
  12. // 两个坐标之间的距离计算公式
  13. double Distanceformula(struct _coordinate* ant, struct _coordinate* last);
  14. // 三点定位
  15. void locatebycordinate(struct _coordinate** coor_list, struct _coordinate* dest);
  16. // 定位算法
  17. void algorithm_locate(struct _coordinate** coor_list, int size, struct _coordinate* hist, struct _coordinate* dest, double dist_limit, double z_offset);
  18. void algorithm_locate_ex(_coordinate** coor_list, int coor_size, _coordinate* hist, _coordinate* dest, double dist_limit);
  19. double getAngleByCoordinate(_coordinate* p1, _coordinate* p2);
  20. double getAngleByAngle(_coordinate* p1, _coordinate* p2);
  21. double getDistance(_coordinate* p1, _coordinate *p2);
  22. _coordinate* getCross(_coordinate* p1, _coordinate* p2);
  23. void calcCoordinate(_coordinate* p1, double dist, double angle, _coordinate* dest);
  24. bool is_all_inline(_coordinate** coor_list, int cnt );
  25. void HeapSort(_coordinate** pCoordinateArray,int nLen);
  26. void BuildMaxHeap(_coordinate** pCoordinateArray,int nLen);
  27. void AdjustMaxHeap(_coordinate** pCoordinateArray,int n,int nHeapSize);
  28. void SwapElement(_coordinate* a,_coordinate*b);
  29. void SelectSort(_coordinate** pCoordinateArray,int nLen);
  30. /*
  31. * 定位算法
  32. *
  33. */
  34. class LocateAlgorithm{
  35. public:
  36. //TOF算法函数
  37. static POS* Pos(ReaderPathMap rpm,int sta_num,int ant,double dist,INFO_PRE info_pre);
  38. static SOLUTION* GetPos(ReaderPathMap rpm,int sta_num,int ant,double dist,int i);
  39. static std::shared_ptr<POS> tof_locate_1d(std::shared_ptr<TOFReaderPathMap> trpm,int reader_id,int antenna_idx,double dist,TOF_REFER_DATA refer_data);
  40. static std::shared_ptr<SOLUTION> GetPos(std::shared_ptr<TOFReaderPathMap> trpm,int reader_id,int antenna_idx,double dist,int seg_idx);
  41. static std::shared_ptr<POS> tof_locate_2d(std::shared_ptr<ReceiveDataTofVector>& pRdtv);
  42. static std::vector<op::point> calc_pos(const op::point& circle_center, const double& radius, const op::point* pLine);
  43. //TDOA算法函数
  44. static std::shared_ptr<POS> Pos(std::shared_ptr<ReceiveDataMap> pRdm,std::shared_ptr<TDOAReaderPathMap> trpm);
  45. static std::unique_ptr<POS> LocatePos(std::shared_ptr<ReceiveDataMap> pRdm,std::shared_ptr<TDOAReaderPathMap> trpm);
  46. static std::shared_ptr<POS> Pos(std::shared_ptr<POS> pos,std::shared_ptr<TDOAReaderPathMap> trpm);
  47. static std::shared_ptr<POS> MappingToPath(std::shared_ptr<POS> pos, std::shared_ptr<TDOAReaderPathMap> trpm);
  48. static std::shared_ptr<POS> TdoaLocate2d(std::shared_ptr<ReceiveDataMap> pRdm);
  49. static std::shared_ptr<POS> TdoaLocate3d(std::shared_ptr<ReceiveDataMap> pRdm);
  50. static std::shared_ptr<POS> tdoa_locate_2d_by_fang(std::shared_ptr<ReceiveDataMap> pRdm);
  51. static std::vector<std::shared_ptr<POS>> tdoa_locate_2d_by_fang(std::shared_ptr<ReceiveDataUnorderedMap> pRdm);
  52. static double cal_real_distance_diff(const double& md,const double& d,const double& h,const int& s);
  53. static std::unique_ptr<POS> CalcCardPosition(std::shared_ptr<ReceiveDataMap> pRdm,std::shared_ptr<TDOAReaderPathMap> trpm);
  54. static std::shared_ptr<SOLUTION> GetPos(std::shared_ptr<ReaderPath> pRP,double dist,int i);
  55. static bool CheckPosInValid(POS* pos,ReceiveDataMap* pRdm,double dScale);
  56. static bool IsOnMap(std::shared_ptr<POS>& pos,std::shared_ptr<TDOAReaderPathMap> trpm);
  57. static bool IsInTriangle(std::vector<_point> vtp,_point p);
  58. static double GetTriangleArea(_point p0,_point p1,_point p2);
  59. static bool IsInLine(_point p,_point start_p,_point end_p);
  60. static bool PointIsInRect(_point p,_point tp,_point lp,_point bp,_point rp);
  61. static int CalcTdoaPosition(std::shared_ptr<ReceiveDataMap> pRdm,std::shared_ptr<TDOAReaderPathMap> trpm,std::vector<std::shared_ptr<POS>>& udm_pos);
  62. static int round(double value);
  63. };
  64. #endif