CDirection2d.h
Go to the documentation of this file.
1 #ifndef i2d_CDirection2d_included
2 #define i2d_CDirection2d_included
3 
4 
5 namespace i2d
6 {
7 
8 
9 class CVector2d;
10 
11 
16 {
17 public:
18  CDirection2d();
19 
23  CDirection2d(const CDirection2d& direction);
24 
29  explicit CDirection2d(double radian);
30 
34  CDirection2d(const CVector2d& direction);
35 
39  static CDirection2d FromRadian(double radian);
40 
44  static CDirection2d FromDegree(double degree);
45 
50  double ToDegree() const;
51 
56  double ToRadian() const;
57 
62  double DistInRadian(const CDirection2d& dir2) const;
63 
68  double DistInDegree(const CDirection2d& dir2) const;
69 
74  CDirection2d Avg(const CDirection2d& dir2) const;
75 
80  CDirection2d Avg(double weight, const CDirection2d& dir2) const;
81 
82  CDirection2d TurnByRadian(double turn) const;
83 
89  bool operator==(const CDirection2d& dir2) const;
90 
94  bool IsInRange(const CDirection2d& leftDirectionLimit, const CDirection2d& rightDirectionLimit) const;
95 
96 private:
101  bool Invariant() const;
102 
106  static double Normalize(double radian);
107 
111  double m_direction;
112 };
113 
114 
115 } // namespace i2d
116 
117 
118 #endif // !i2d_CDirection2d_included
119 
120 
double ToDegree() const
Get direction in degrees.
double DistInRadian(const CDirection2d &dir2) const
Get angle difference in radians.
CDirection2d TurnByRadian(double turn) const
static CDirection2d FromDegree(double degree)
Construct a new CDirection2d object and initialize from degree.
double ToRadian() const
Get direction in radians.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
bool IsInRange(const CDirection2d &leftDirectionLimit, const CDirection2d &rightDirectionLimit) const
Check if the direction is in the direction range between leftDirectionLimit and rightDirectionLimit.
static CDirection2d FromRadian(double radian)
Construct a new CDirection2d object and initialize from radian.
Represents a direction in 2D space.
Definition: CDirection2d.h:15
double DistInDegree(const CDirection2d &dir2) const
Get angle difference in degrees.
CDirection2d Avg(const CDirection2d &dir2) const
Get minimal distance between two directions.
bool operator==(const CDirection2d &dir2) const
Compare the objects direction with the one of dir2.

© 2007-2017 Witold Gantzke and Kirill Lepskiy