point.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _POINT_HPP_
  2. #define _POINT_HPP_
  3. #define NAMESPACE_POINT op
  4. #define NAMESPACE_POINT_BEGIN(x) namespace x {
  5. #define NAMESPACE_POINT_END(x) };
  6. #include <tuple>
  7. NAMESPACE_POINT_BEGIN (NAMESPACE_POINT)
  8. struct point
  9. {
  10. point();
  11. point(double x_,double y_)
  12. :x(x_)
  13. ,y(y_)
  14. {
  15. }
  16. static point min_(const point&a,const point&b);
  17. static point max_(const point&a,const point&b);
  18. void set(const point&p);
  19. void set(double,double);
  20. void swap(point&p);
  21. bool operator<(const point&p)const;
  22. static bool eq(double l,double r,double deta);
  23. bool empty()const;
  24. bool invalid()const;
  25. bool operator==(const point&r)const;
  26. double dist_direct(const point&o)const;
  27. double dist_direct(double x,double y)const;
  28. double dist(const point&o)const;
  29. double dist(double x,double y)const;
  30. double cos_k(const point&o)const;
  31. double sin_k(const point&o)const;
  32. point middle(const point&o)const;
  33. std::tuple<double,double,double> get_abc(const point&o)const;
  34. public:
  35. double x,y;
  36. };
  37. NAMESPACE_POINT_END(NAMESPACE_POINT)
  38. #endif