//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00015 #ifndef _DIRECTIONCONE_H 00016 #define _DIRECTIONCONE_H 00017 00018 #include "GoTools/utils/Point.h" 00019 #include "GoTools/utils/config.h" 00020 00021 namespace Go { 00022 00032 class GO_API DirectionCone { 00033 public: 00035 DirectionCone() : greater_than_pi_(-1), zero_tol_(0.0) {} 00036 00041 DirectionCone(const Point& pt) 00042 : centre_(pt), angle_(0.0), greater_than_pi_(0), zero_tol_(0.0) 00043 { 00044 if (pt.length() > 0.0) 00045 centre_.normalize(); 00046 } 00047 00052 DirectionCone(const Point& centre, double angle) 00053 : centre_(centre), angle_(angle), zero_tol_(0.0) 00054 { 00055 if (centre_.length() > 0.0) 00056 centre_.normalize(); 00057 check_angle(); 00058 } 00059 00061 ~DirectionCone() { } 00062 00070 void setFromArray(const double* start, const double* end, int dim); 00071 00074 int dimension() const { return centre_.size(); } 00075 00077 const Point& centre() const { return centre_; } 00078 00080 double angle() const { return angle_; } 00081 00085 int greaterThanPi() const { return greater_than_pi_; } 00086 00089 bool overlaps(const DirectionCone& cone) const; 00090 00093 bool perpendicularOverlaps(const DirectionCone& cone) const; 00094 00097 bool containsDirection(const Point& pt, double tol = 0.0) const; 00098 00101 void addUnionWith(const Point& pt); 00102 00105 void addUnionWith(const DirectionCone& cone); 00106 00108 void read(std::istream& is); 00109 00111 void write(std::ostream& os) const; 00112 00113 // void setZeroTol(double zero_tol) 00114 // { 00115 // zero_tol_ = zero_tol; 00116 // } 00117 00118 private: 00119 00120 void check_angle() const; 00121 00122 Point centre_; 00123 double angle_; 00124 mutable int greater_than_pi_; 00125 00126 double zero_tol_; // By default the zero-tol is 0.0. Used in greaterThanPi(). 00127 00128 }; 00129 00130 00131 } // namespace Go 00132 00133 00134 #endif // _DIRECTIONCONE_H 00135
Generated on Tue Sep 21 15:44:17 2010 for GoTools Core by  doxygen 1.6.3