From 0b183cf7a070c0ba0e7bb4df8064938877f09e73 Mon Sep 17 00:00:00 2001 From: tosh Date: Fri, 29 Mar 2013 00:30:57 +0100 Subject: [PATCH] adds function to convert between angle units --- shared/src/AngleUtils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shared/src/AngleUtils.h b/shared/src/AngleUtils.h index d241fa3fe6..1195c3c330 100644 --- a/shared/src/AngleUtils.h +++ b/shared/src/AngleUtils.h @@ -32,6 +32,16 @@ struct Rotations static float half_pi() { return 0.25f; } }; +/** + * Converts an angle from one unit to another. + */ +template< class UnitFrom, class UnitTo > +float angleConvert(float a) +{ + return a * (UnitTo::half_pi() / UnitFrom::half_pi()); +} + + /** * Clamps an angle to the range of [-180; 180) degrees. */