123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #ifndef __BASE_DATA__
- #define __BASE_DATA__
- #include <map>
- #include <list>
- #include <deque>
- #include <vector>
- #include <cmath>
- struct point_2
- {
- double x_;
- double y_;
- point_2()
- :x_(0x12345678)
- ,y_(0x87654321)
- {
- }
- point_2(double x,double y)
- :x_(x),y_(y)
- {}
- void setX(double x)
- {
- x_ = x;
- }
- void setY(double y)
- {
- y_ = y;
- }
- static inline bool is_valid(const point_2&p)
- {
- const point_2 &pt=invalid_point();
- return pt.x_!=p.x_ || pt.y_!=p.y_;
- }
- static inline const point_2& invalid_point()
- {
- static const point_2 pt;
- return pt;
- }
- static inline double sqr(double x)
- {
- return x*x;
- }
- double dist_to(double x,double y)
- {
- return std::sqrt(sqr(x-x_)+sqr(y-y_));
- }
- double dist_to(const point_2&pt)
- {
- return dist_to(pt.x_,pt.y_);
- }
- };
- struct st_coord :point_2
- {
- uint64_t gen_time_;
- uint16_t m_ct;//ct
- void clear()
- {
- gen_time_ = 0;
- m_ct = 0;
- x_ = 0;
- y_ = 0;
- }
- void setTime(uint64_t t)
- {
- gen_time_ = t;
- }
- void setCT(uint16_t t)
- {
- m_ct = t;
- }
- };
- #endif
|