]> git.tdb.fi Git - libs/math.git/commitdiff
Normalize the axis in Quaternion::rotation
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Jan 2023 19:45:19 +0000 (21:45 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Jan 2023 19:45:19 +0000 (21:45 +0200)
source/geometry/quaternion.h

index 5cb45fffcbcc6a20f31114a235d534efdaef9394..ef5504e5c33390aeb921fad4c12ff9fd3cae518a 100644 (file)
@@ -46,8 +46,8 @@ struct Quaternion
 template<typename T>
 Quaternion<T> Quaternion<T>::rotation(Angle<T> angle, const LinAl::Vector<T, 3> &axis)
 {
-       float c = cos(angle/T(2));
-       float s = sin(angle/T(2));
+       T c = cos(angle/T(2));
+       T s = sin(angle/T(2))/axis.norm();
        return Quaternion<T>(c, s*axis.x, s*axis.y, s*axis.z);
 }