]> git.lizzy.rs Git - minetest.git/blobdiff - src/util/numeric.h
Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019)
[minetest.git] / src / util / numeric.h
index bfdff84a0e878101fc066576a17b2ac0c77031e0..6f82a18c1b4d858019e29d8f5a9c0da064b6a3a1 100644 (file)
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "irr_v2d.h"
 #include "irr_v3d.h"
 #include "irr_aabb3d.h"
+#include <matrix4.h>
 
 #define rangelim(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
 #define myfloor(x) ((x) < 0.0 ? (int)(x) - 1 : (int)(x))
@@ -417,3 +418,17 @@ inline void wrappedApproachShortest(T &current, const T target, const T stepsize
                current = target;
        }
 }
+
+void setPitchYawRollRad(core::matrix4 &m, const v3f &rot);
+
+inline void setPitchYawRoll(core::matrix4 &m, const v3f &rot)
+{
+       setPitchYawRollRad(m, rot * core::DEGTORAD64);
+}
+
+v3f getPitchYawRollRad(const core::matrix4 &m);
+
+inline v3f getPitchYawRoll(const core::matrix4 &m)
+{
+       return getPitchYawRollRad(m) * core::RADTODEG64;
+}