C++ header-only library for vector and matrix math
This project provides the following functionalities:
- constanst (PI, EULER, GOLEN_RATIO, ...)
- arithmetic (abs, floor, ceil, exp, max, ...)
- vector and matrix math (Vec<T, N, M>, Mat<T, N, M>)
- 3D math (RotationMatrix, PerspectiveMatrix, ...)
- curves (lerp, quadratic, cubic ...)
These functionalities are optimized for readability, not performance.
- beaver (optional, for error logging), see https://github.com/fburgerdev/beaver
#include "vecmath/vecmath.hpp"
int main() {
Math::Vec3F vec = Math::normalize(Math::Vec3F(1, 2, 3));
Math::Mat3F mat = Math::Identity<float, 3>();
mat.at(0, 1) = 2;
std::cout << Math::transpose(mat * vec) << std::endl;
return EXIT_SUCCESS;
}
In your c++ project
- add include/vecmath to your include directories
optionally, to use precompiled templates
- add lib/[config] to your library directories (depending on your configuration)
- link the library libvecmath.a (for linux) and vecmath.lib (for windows)
In order to resolve the dependancies
- for beaver (optional, for error logging)
- add modules/beaver/lib/[config] to your include directories
- link the library libbeaver.a or beaver.lib
Locate the build folder, then execute the following command in the console:
make config=[config]
If you have not installed make:
sudo apt-get install make -y
Open the build/vecmath.sln solution with Visual Studio.
After selecting your desired configuration, click on Build > Build Solution.
Note: Make sure you have the Desktop developement with C++ workload installed.