Magnum now has compile-time matrix/vector library. With full C++14 support in Clang 3.4 you can throw out nearly all manual precomputations, just slap constexpr
on the result and be done with it:
#include <Magnum/Magnum.h>
#include <Magnum/Math/Matrix4.h>
using namespace Magnum;
int main() {
constexpr auto a = Matrix4::scaling(Vector3::xScale(3.0f))*
Matrix4::translation({1.5f, -0.3f, 1.1f});
constexpr auto b = a.inverted();
static_assert((a*b).determinant() > 1.0f - Math::TypeTraits<Float>::epsilon() &&
(a*b).determinant() < 1.0f + Math::TypeTraits<Float>::epsilon(),
"The inversion went bad!");
}
Because why not. The code will compile without any problem, try to change the comparison to something else to see the difference.
The code is in
cpp14
branch of Corrade and Magnum libraries. Enjoy!