From bfd4e276c376213b22fd1634c45941ed55948f16 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Tue, 11 Nov 2003 04:31:53 +0000 Subject: [PATCH] added get_standardized_hpr --- panda/src/linmath/lvecBase3_src.I | 44 +++++++++++++++++++++++++++++++ panda/src/linmath/lvecBase3_src.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/panda/src/linmath/lvecBase3_src.I b/panda/src/linmath/lvecBase3_src.I index aa90976af4..955fa58637 100644 --- a/panda/src/linmath/lvecBase3_src.I +++ b/panda/src/linmath/lvecBase3_src.I @@ -441,6 +441,50 @@ operator != (const FLOATNAME(LVecBase3) &other) const { return !operator == (other); } +//////////////////////////////////////////////////////////////////// +// Function: get_standardized_rotation +// Access: file +// Description: return value in the range -180.0 to 179.99999. +// See Also: get_standardized_hpr +//////////////////////////////////////////////////////////////////// +static INLINE_LINMATH FLOATTYPE +get_standardized_rotation(FLOATTYPE angle_in_degrees) { + if (angle_in_degrees<0.0) { + angle_in_degrees = FLOATCONST(360.0) - fmod(angle_in_degrees * FLOATCONST(-1.0), FLOATCONST(360.0)); + } else { + angle_in_degrees = fmod(angle_in_degrees, FLOATCONST(360.0)); + } + // This can be changed to return values in the range 0.0 to 359.99999 + // by skipping this next part and returning now. + + return (angle_in_degrees