From 16f460a2d2a9f68f942c72ed40ae744b9daba536 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 19 Dec 2019 14:44:58 +1100 Subject: [PATCH] quaternion: assert angles are less than a full rotation --- quaternion.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quaternion.cpp b/quaternion.cpp index 7b0313a3..af634e08 100644 --- a/quaternion.cpp +++ b/quaternion.cpp @@ -23,6 +23,8 @@ template quaternion quaternion::angle_axis (const T radians, const vector<3,T> axis) { + CHECK (radians < cruft::pi * 2); + CHECK (radians > -cruft::pi * 2); CHECK (is_normalised (axis)); auto w = std::cos (radians / 2); @@ -39,6 +41,8 @@ template quaternion quaternion::from_euler (vector<3,T> angles) { + CHECK (all (angles > -cruft::pi * 2)); + CHECK (all (angles < cruft::pi * 2)); auto half = angles / 2; auto c = std::cos (half);