ExMa2D is a tiny external math library for 2D.
We internally use cppDegRag for user-defined literals of angles. Also, for tests we use MosquitoNet.
Both of these are header-only and they are present in the repo as submodules, so you don't have to explicitly take care of them.
Yes, it takes a bit of compile-time, but that's the price for templates. It's easier to set up the library as well!
These functions work on any vector class which has public x
and y
members,
and can be initialized via argument list. For instance:
struct VectorF
{
float x, y;
};
#include "exma2D/vector2D.hpp"
using namespace exma::vector;
struct VectorF
{
float x, y;
};
constexpr VectorF vec{2.f, 5.f};
constexpr VectorF origin{0.f, 0.f};
constexpr auto crazy = -perpendicule(vec)
constexpr auto silly = project(crazy, vec) * 3;
constexpr auto crazy_silly = reflect(crazy, silly);
auto go_round = rotate(crazy_silly, origin, 180_deg);
auto length = len(go_round);
constexpr auto dot_product = dot(crazy, silly);
- C++14 compiler
Tested with g++ 5.2.1 and clang 3.6.2
ExMa2D is licensed under zlib/libpng. You can use it in your projects, no matter whether they are free, commercial, open-source or closed-sourced.
It would be nice if you mentioned somewhere in your project description or documentation (or anywhere else) that you're using ExMa2D, but you're not legally obliged to do so.