[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
|
NNM is a "No-Nonsense", C++ 17, single-header-only Math library geared towards graphics programming. Think of it as a lightweight, more readable alternative to a library like glm and inspired by the OOP style of Godot's math library.
A full list of all functions/classes can be found in docs/reference.md.
NNM provides classes for:
where the trailing number represents the "dimension" of the class. These classes are templated with either Real or Int types that allow for various floating point and integer types. Aliases are created for those cases such as Vector2f and Vector2d for float and double respectively as well as Vector3i32, Vector2u16, Vector3i64, etc. for integer classes.
In addition to these classes, NNM provides for a number of standalone math functions such as lerp, clamp, approx_equal, etc.
Other notable features/qualities of NNM include:
The easiest way would be to just copy the include/nnm/nnm.hpp file directly into your project and just #include it to use!
Another method is to add the project as a CMake submodule by copying the repository to a directory and adding:
You might be asking, "What is up with all these variations of perspective/orthographic projection methods? Which one do I use??" This depends on the graphics API you are using as well as the coordinate system you choose for your application. There are two considerations to be aware of, the handedness and the normalization of the graphics API. Here is a short list of common graphics APIs' normalized device coordinate (NDC) conventions:
This means if your application and graphics API use the same coordinate system, you just need to choose the method with the correct handedness and normalization corresponding to that graphics API. However, if your application and chosen graphics API have mismatching handedness, you must flip the z-axis. For example, if you are using OpenGL (which is left-handed) but wish to use right-handed coordinates in your application, you would still use the projection method corresponding with OpenGL's convention of left-handed and -1 to 1 normalization but just need to flip the z-axis to account for the switched handedness:
After cloning the repository, configure the project with CMake ensuring to enable building tests:
NNM is licensed under the MIT license. See LICENSE.txt for full license.