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 &);
template<typename T>
inline Angle<T> Angle<T>::from_degrees(T d)
{
- return Angle<T>(d*M_PI/180);
+ return Angle<T>(d/57.2957795130823208768);
}
template<typename T>
template<typename T>
inline Angle<T> Angle<T>::from_turns(T t)
{
- return Angle<T>(t*2*M_PI);
+ return Angle<T>(t*6.28318530717958647692);
}
template<typename T>
template<typename T>
inline Angle<T> &Angle<T>::wrap_with_base(const Angle<T> &b)
{
+ const float two_pi = 6.28318530717958647692;
while(value<b.value)
- value += 2*M_PI;
- 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;
}