]> git.localhorst.tv Git - gong.git/blobdiff - src/physics/Derivative.hpp
simple physics simulation
[gong.git] / src / physics / Derivative.hpp
diff --git a/src/physics/Derivative.hpp b/src/physics/Derivative.hpp
new file mode 100644 (file)
index 0000000..ae3d5e5
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef GONG_PHYSICS_DERIVATIVE_HPP_
+#define GONG_PHYSICS_DERIVATIVE_HPP_
+
+#include "../graphics/glm.hpp"
+
+#include <glm/gtc/quaternion.hpp>
+
+
+namespace gong {
+namespace physics {
+
+struct State;
+
+
+struct Derivative {
+
+       glm::vec3 dpos;
+       glm::vec3 dlin;
+       glm::quat dorient;
+       glm::vec3 dang;
+
+       Derivative() noexcept;
+       Derivative(
+               const glm::vec3 &,
+               const glm::vec3 &,
+               const glm::quat &,
+               const glm::vec3 &
+       ) noexcept;
+
+};
+
+
+inline Derivative operator +(const Derivative &a, const Derivative &b) noexcept {
+       return Derivative(a.dpos + b.dpos, a.dlin + b.dlin, a.dorient * b.dorient, a.dang + b.dang);
+}
+
+inline Derivative operator *(float f, const Derivative &d) noexcept {
+       return Derivative(f * d.dpos, f * d.dlin, f * d.dorient, f * d.dang);
+}
+inline Derivative operator *(const Derivative &d, float f) noexcept {
+       return f * d;
+}
+
+State &operator +=(State &s, const Derivative &d) noexcept;
+
+}
+}
+
+#endif