X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_angle.h;h=c15f90d813e97601ec0a2ba71fd011571f4d8cfd;hb=0ec96dc9bd274f5c79f37d95ca0abcc24099217a;hp=1abf9303b9d392e66ef3ce914164119eb8c32503;hpb=4dd6c6c11c69d048bd14cddf9c4336017dcd6ea7;p=synfig.git diff --git a/ETL/trunk/ETL/_angle.h b/ETL/trunk/ETL/_angle.h index 1abf930..c15f90d 100644 --- a/ETL/trunk/ETL/_angle.h +++ b/ETL/trunk/ETL/_angle.h @@ -5,6 +5,7 @@ ** $Id$ ** ** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -40,6 +41,8 @@ # define HALF_PI (PI/2) #endif +#define ANGLE_EPSILON (1.0e-6) + /* === T Y P E D E F S ===================================================== */ /* === C L A S S E S & S T R U C T S ======================================= */ @@ -115,6 +118,7 @@ public: return ret; } +#ifdef ETL_NOT_USED //! 180 degree rotation operator /*! Returns the angle directly opposite of the given angle, and will yield a result @@ -126,7 +130,9 @@ public: ret.v = v+PI; return ret.mod(); } +#endif // ETL_NOT_USED +#ifdef ETL_WRAP_ANGLES /*! Returns true if the shortest angle from the left-hand to the right-hand side is counter-clockwise */ @@ -164,15 +170,68 @@ public: on the unit circle. */ bool operator==(const angle &rhs)const - { return std::abs(dist(rhs).v)epsilon; } + { return std::abs(dist(rhs).v)>ANGLE_EPSILON; } +#else // ETL_WRAP_ANGLES + /*! Returns true if the left-hand + side is less than the + right-hand side */ + bool + operator<(const angle &rhs)const + { return v < rhs.v; } + + /*! Returns true if the left-hand + side is greater than the + right-hand side */ + bool + operator>(const angle &rhs)const + { return v > rhs.v; } + + /*! Returns true if the left-hand + side is less or equal to the + right-hand side */ + bool + operator<=(const angle &rhs)const + { return v <= rhs.v; } + + /*! Returns true if the left-hand + side is greater than or equal + to the right-hand side */ + bool + operator>=(const angle &rhs)const + { return v >= rhs.v; } + + /*! Returns true if the angles + are the same, or close */ + bool + operator==(const angle &rhs)const + { return std::abs(v - rhs.v)ANGLE_EPSILON; } +#endif // ETL_WRAP_ANGLES + //! Absolute Angle Function + /*! This function will return the + absolute value of the angle. */ + angle + abs()const + { + angle ret; + ret.v=std::abs(v); + return ret; + } + +#ifdef ETL_WRAP_ANGLES //! Angle Difference Function /*! This function will return the shortest physical distance between @@ -197,6 +256,26 @@ public: ret.v-=rot_floor(ret.v); return ret; } +#else // ETL_WRAP_ANGLES + //! Angle Difference Function + /*! This function will return the + difference between + two angles, just like + \sa angle operator-(const angle &) */ + angle + dist(const angle &rhs)const + { return angle(*this)-=rhs; } + + //! Rotation Modulus + /*! This function will return the + value of the angle */ + angle + mod()const + { + angle ret(*this); + return ret; + } +#endif // ETL_WRAP_ANGLES //! Zero Rotation (0 degrees) static angle @@ -225,14 +304,14 @@ public: return ret; } - bool operator!()const { return std::abs(mod().v) < epsilon; } + bool operator!()const { return std::abs(mod().v) < ANGLE_EPSILON; } private: +#ifdef ETL_WRAP_ANGLES static value_type rot_floor(value_type x) { return static_cast(std::floor(x/(PI*2))*PI*2); } - - static const value_type epsilon = 1.0e-6; +#endif // ETL_WRAP_ANGLES public: /*