summaryrefslogtreecommitdiff
path: root/lib/maths.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:07:16 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:07:16 +0000
commite7420b24c30d9c25bdcc9369fb1ae7a409fda7d4 (patch)
treee9154bdb8e5541155a48de7d2eaadf955026385d /lib/maths.h
parentAdd coverage variant (diff)
downloadilt-e7420b24c30d9c25bdcc9369fb1ae7a409fda7d4.tar.bz2
ilt-e7420b24c30d9c25bdcc9369fb1ae7a409fda7d4.tar.xz
ilt-e7420b24c30d9c25bdcc9369fb1ae7a409fda7d4.zip
Our own matrix rotations
Simpler and faster than glm's as we don't need arbitrary axes.
Diffstat (limited to 'lib/maths.h')
-rw-r--r--lib/maths.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/maths.h b/lib/maths.h
index c072283..d304b65 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -1,6 +1,7 @@
#ifndef MATH_H
#define MATH_H
+#include <cmath>
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <utility>
@@ -29,6 +30,26 @@ constexpr auto two_pi {glm::two_pi<float>()};
glm::mat4 flat_orientation(const glm::vec3 & diff);
+// C++ wrapper for C's sincosf, but with references, not pointers
+inline auto
+sincosf(float a, float & s, float & c)
+{
+ return sincosf(a, &s, &c);
+}
+
+inline std::pair<float, float>
+sincosf(float a)
+{
+ std::pair<float, float> sc;
+ sincosf(a, &sc.first, &sc.second);
+ return sc;
+}
+
+glm::mat4 rotate_roll(float);
+glm::mat4 rotate_yaw(float);
+glm::mat4 rotate_pitch(float);
+glm::mat4 rotate_ypr(glm::vec3);
+
float vector_yaw(const glm::vec3 & diff);
float vector_pitch(const glm::vec3 & diff);