In order to easily work with GLSL, the operations are performed in a column-major fashion. The library supports arithmetic operations on vectors, matrices and quaternions. It also provides basic transformation functions.
CinMath utilizes SIMD intrinsics (single instruction multiple data) - both 128 bit wide and 256 bit wide registers can be used to parallelize non-dependant computations.
All of the library functionalities come in a single header (CinMath.h). The library can be configured to use either SSE or AVX instruction sets with a single define, above the main header:
#define CIN_USE_DEFAULT_INSTRUCTION_SET // No SIMD (default)
#include "CinMath/CinMath.h"#define CIN_USE_SSE // For sse instructions
#include "CinMath/CinMath.h"#define CIN_USE_AVX // For avx instructions
#include "CinMath/CinMath.h"The library comes with Radians and Degrees types used for constructing Angles used in transformations
const Radians rads{ 2_rad };
std::cout << "Radians: " << rads << '\n'; // Prints 2
std::cout << "Radians to degrees: " << rads.ToDegrees() << '\n'; // Prints 114.592
const Degrees degrees{ 114.5916_deg };
std::cout << "Degrees: " << degrees << '\n'; // Prints 114.5916
std::cout << "Degrees to radians: " << degrees.ToRadians() << '\n'; // Prints 2
const Angle angleInRadians{ rads }; // Degrees can be used too
std::cout << "Angle specified in radians:\n";
std::cout << "Radians: " << angleInRadians.ToRadians() << '\n';
std::cout << "Degrees: " << angleInRadians.ToDegrees() << '\n';
std::cout << '\n';
std::cout << "Sinus of 90 degrees angle: " << sin(Angle{ 90_deg }.ToRadians()); // standard sin() accepts an angle in radians. Prints 1void Update(const float deltaTimeSec)
{
...
m_Rotation += 3_deg * deltaTimeSec; // Rotate by 3 degrees every second
}#include "CinMath/CinMath.h"
int main(const int argc, const char** argv)
{
using namespace CinMath;
Vector4 vector{ 0.0f, 0.0f, 0.0f, 0.0f };
vector.xyz = { 1.0f, 1.0f, 1.0f };
vector.z = 2.0f;
vector.xy *= 1.0f;
return 0;
}git clone https://github.com/CzekoladowyKocur/CinMath.git
The header library can be used on both windows (MSVC) and linux (GCC) and possibly clang (not tested).
- Python 3
- CMake (minimum version 3.0.0)
- C++
20compatible compiler
run BuildWindows.bat
run ./BuildLinux.sh
