From 34f5bc6fcee85764bca21bf864f8f810f9d797e5 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 21 Jul 2024 02:06:01 +0200 Subject: [PATCH] Use std math functions To avoid implicit conversions from float to double and back. --- components/misc/mathutil.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/misc/mathutil.hpp b/components/misc/mathutil.hpp index 9236d248a0..e0c52eaf0c 100644 --- a/components/misc/mathutil.hpp +++ b/components/misc/mathutil.hpp @@ -7,6 +7,7 @@ #include #include +#include #include namespace Misc @@ -28,8 +29,8 @@ namespace Misc inline osg::Vec3f toEulerAnglesXZ(osg::Vec3f forward) { - float x = -asin(forward.z()); - float z = atan2(forward.x(), forward.y()); + float x = -std::asin(forward.z()); + float z = std::atan2(forward.x(), forward.y()); return osg::Vec3f(x, 0, z); } @@ -49,10 +50,10 @@ namespace Misc inline osg::Vec3f toEulerAnglesZYX(osg::Vec3f forward, osg::Vec3f up) { - float y = -asin(up.x()); - float x = atan2(up.y(), up.z()); + float y = -std::asin(up.x()); + float x = std::atan2(up.y(), up.z()); osg::Vec3f forwardZ = (osg::Quat(x, osg::Vec3f(1, 0, 0)) * osg::Quat(y, osg::Vec3f(0, 1, 0))) * forward; - float z = atan2(forwardZ.x(), forwardZ.y()); + float z = std::atan2(forwardZ.x(), forwardZ.y()); return osg::Vec3f(x, y, z); }