quaternion: assert angles are less than a full rotation

This commit is contained in:
Danny Robson 2019-12-19 14:44:58 +11:00
parent 0624a3ad00
commit 16f460a2d2

View File

@ -23,6 +23,8 @@ template <typename T>
quaternion<T>
quaternion<T>::angle_axis (const T radians, const vector<3,T> axis)
{
CHECK (radians < cruft::pi<T> * 2);
CHECK (radians > -cruft::pi<T> * 2);
CHECK (is_normalised (axis));
auto w = std::cos (radians / 2);
@ -39,6 +41,8 @@ template <typename T>
quaternion<T>
quaternion<T>::from_euler (vector<3,T> angles)
{
CHECK (all (angles > -cruft::pi<T> * 2));
CHECK (all (angles < cruft::pi<T> * 2));
auto half = angles / 2;
auto c = std::cos (half);