Skip to content

Commit

Permalink
libdeng2|Math: Degreee/radian conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Apr 19, 2013
1 parent b155122 commit b39e467
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion doomsday/libdeng2/include/de/math.h
Expand Up @@ -34,7 +34,7 @@
namespace de {

#undef PI
ddouble const PI = 3.14159265358979323846;
ddouble const PI = 3.1415926535897932384626433832795028841971693993751;
ddouble const EPSILON = 1.0e-7;
dfloat const FLOAT_EPSILON = 1.0e-5f;

Expand Down Expand Up @@ -102,6 +102,16 @@ inline bool fequal(ddouble a, ddouble b) {
return abs(a - b) < EPSILON;
}

template <typename Type>
inline Type degreeToRadian(Type const &degree) {
return degree / Type(180) * PI;
}

template <typename Type>
inline Type radianToDegree(Type const &radian) {
return radian / PI * Type(180);
}

/// General comparison function.
template <typename Type>
inline dint cmp(Type const &a, Type const &b) {
Expand Down

0 comments on commit b39e467

Please sign in to comment.