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 "node_modules/linmath.c/linmath.h"
int main() { /* ... */ }And then compile with clang or gcc as usual.
$ clang main.c # or, use gcc
$ gcc main.cYou may also use a simpler approach:
// main.c
#include <linmath.h>
int main() { /* ... */ }If you add 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.c