X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fangle.h;h=2d178d2235128f6e88a62d37fc00dfd8f0d09988;hb=44bd1d1ab256d397be4e2169c4ca5efdd0569d31;hp=207a5a273721a3475e6302abeffa6995f336dbf7;hpb=93e7cf250208c36befb4b1a7337f5302c0e1da54;p=libs%2Fmath.git diff --git a/source/geometry/angle.h b/source/geometry/angle.h index 207a5a2..2d178d2 100644 --- a/source/geometry/angle.h +++ b/source/geometry/angle.h @@ -27,15 +27,15 @@ public: static Angle from_turns(T); static Angle zero() { return from_radians(0); } - static Angle right() { return from_radians(M_PI/2); } + static Angle right() { return from_turns(0.25); } static Angle quarter_turn() { return right(); } - static Angle straight() { return from_radians(M_PI); } + static Angle straight() { return from_turns(0.5); } static Angle half_turn() { return straight(); } - static Angle full_turn() { return from_radians(2*M_PI); } + static Angle full_turn() { return from_turns(1); } - T degrees() const { return value*180/M_PI; } + T degrees() const { return value*57.2957795130823208768; } T radians() const { return value; } - T turns() const { return value/(2*M_PI); } + T turns() const { return value/6.28318530717958647692; } Angle &operator+=(const Angle &); Angle &operator-=(const Angle &); @@ -57,7 +57,7 @@ public: template inline Angle Angle::from_degrees(T d) { - return Angle(d*M_PI/180); + return Angle(d/57.2957795130823208768); } template @@ -69,7 +69,7 @@ inline Angle Angle::from_radians(T r) template inline Angle Angle::from_turns(T t) { - return Angle(t*2*M_PI); + return Angle(t*6.28318530717958647692); } template @@ -155,10 +155,11 @@ inline T operator/(const Angle &a1, const Angle &a2) template inline Angle &Angle::wrap_with_base(const Angle &b) { + const float two_pi = 6.28318530717958647692; while(value=b.value+2*M_PI) - value -= 2*M_PI; + value += two_pi; + while(value>=b.value+two_pi) + value -= two_pi; return *this; }