maths: add float overload of to_radians

This commit is contained in:
Danny Robson 2015-01-13 18:32:30 +11:00
parent a691f3b748
commit f309c5dbd0
2 changed files with 9 additions and 1 deletions

View File

@ -154,6 +154,13 @@ to_degrees (double radians) {
return radians * 180 / PI;
}
//-----------------------------------------------------------------------------
constexpr float
to_radians (float degrees) {
return degrees / 180 * static_cast<float> (PI);
}
constexpr double
to_radians (double degrees) {
return degrees / 180 * PI;

View File

@ -40,7 +40,8 @@ main (int, char **) {
CHECK_EQ (sign (-numeric_limits<double>::infinity ()), -1);
CHECK_EQ (to_degrees (PI), 180);
CHECK_EQ (to_radians (180), PI);
CHECK_EQ (to_radians (180.f), PI);
CHECK_EQ (to_radians (180.0), PI);
CHECK_EQ (log2 (8u), 3);
CHECK_EQ (log2 (1u), 0);