X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fphysics%2FDerivative.hpp;fp=src%2Fphysics%2FDerivative.hpp;h=ae3d5e58d2b1b2a56df7fbc48e2528a284ce09c7;hb=d220b0348951ce210ad4ea18dbe9934dd2999a60;hp=0000000000000000000000000000000000000000;hpb=9932ee17a767b64cb52c213e133c6b91a90a8dd2;p=gong.git diff --git a/src/physics/Derivative.hpp b/src/physics/Derivative.hpp new file mode 100644 index 0000000..ae3d5e5 --- /dev/null +++ b/src/physics/Derivative.hpp @@ -0,0 +1,49 @@ +#ifndef GONG_PHYSICS_DERIVATIVE_HPP_ +#define GONG_PHYSICS_DERIVATIVE_HPP_ + +#include "../graphics/glm.hpp" + +#include + + +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