00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _DIRECTIONCONE_H
00034 #define _DIRECTIONCONE_H
00035
00036 #include "Point.h"
00037
00038 namespace Go {
00041
00042
00052 class DirectionCone {
00053 public:
00055 DirectionCone() : greater_than_pi_(-1), zero_tol_(0.0) {}
00056
00061 DirectionCone(const Point& pt)
00062 : centre_(pt), angle_(0.0), greater_than_pi_(0), zero_tol_(0.0)
00063 {
00064 if (pt.length() > 0.0)
00065 centre_.normalize();
00066 }
00067
00072 DirectionCone(const Point& centre, double angle)
00073 : centre_(centre), angle_(angle), zero_tol_(0.0)
00074 {
00075 if (centre_.length() > 0.0)
00076 centre_.normalize();
00077 check_angle();
00078 }
00079
00081 ~DirectionCone() { }
00082
00090 void setFromArray(const double* start, const double* end, int dim);
00091
00094 int dimension() const { return centre_.size(); }
00095
00097 const Point& centre() const { return centre_; }
00098
00100 double angle() const { return angle_; }
00101
00105 int greaterThanPi() const { return greater_than_pi_; }
00106
00109 bool overlaps(const DirectionCone& cone) const;
00110
00113 bool perpendicularOverlaps(const DirectionCone& cone) const;
00114
00117 bool containsDirection(const Point& pt, double tol = 0.0) const;
00118
00121 void addUnionWith(const Point& pt);
00122
00125 void addUnionWith(const DirectionCone& cone);
00126
00128 void read(std::istream& is);
00129
00131 void write(std::ostream& os) const;
00132
00133
00134
00135
00136
00137
00138 private:
00139
00140 void check_angle() const;
00141
00142 Point centre_;
00143 double angle_;
00144 mutable int greater_than_pi_;
00145
00146 double zero_tol_;
00147
00148 };
00149
00150
00152 }
00153
00154
00155 #endif // _DIRECTIONCONE_H
00156
00157