Skip to content

A lean linear math library, aimed at graphics programming. Supports vec3, vec4, mat4x4 and quaternions; Wolfgang Draxinger (2013).

License

Notifications You must be signed in to change notification settings

nodef/linmath.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linmath.h

A small library for linear math as required for computer graphics

linmath.h provides the most used types required for programming computer graphics:

  • vec3 -- 3 element vector of floats
  • vec4 -- 4 element vector of floats (4th component used for homogenous computations)
  • mat4x4 -- 4 by 4 elements matrix, computations are done in column major order
  • quat -- 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.


Installation

Run:

$ npm i linmath.c

And 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.c

You 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



SRC ORG

About

A lean linear math library, aimed at graphics programming. Supports vec3, vec4, mat4x4 and quaternions; Wolfgang Draxinger (2013).

Resources

License

Stars

Watchers

Forks