linmath.h provides the most used types required for programming computer graphics:
vec3-- 3 element vector of floatsvec4-- 4 element vector of floats (4th component used for homogenous computations)mat4x4-- 4 by 4 elements matrix, computations are done in column major orderquat-- quaternion
The types are deliberately named like the types in GLSL. In fact they are meant to be used for the client side computations and passing to same typed GLSL uniforms.
Run:
$ npm i linmath.cAnd then include linmath.h as follows:
// main.c
#include <linmath.h>
int main() { /* ... */ }Finally, compile while adding the path node_modules/linmath.c to your compiler's include paths.
$ clang -I./node_modules/linmath.c main.c # or, use gcc
$ gcc -I./node_modules/linmath.c main.cYou may also use a simpler approach with the cpoach tool, which automatically adds the necessary include paths of all the installed dependencies for your project.
$ cpoach clang main.c # or, use gcc
$ cpoach gcc main.c