Linear algebra library for c++.
A linear algebra library written in c++ with vector swizzling and a comprehensive collection of useful functions for games and graphics development. A good maths library is an essential tool for any games or graphics programmer. I have built this library up and maintained it since I began my journey into game development.
It’s most interesting feature is probably the vector swizzling, it uses c++11’s template parameter pack to allow shader style swizzles. I wrote a rust program permute which code generates the c++ template permutations in swizzle.h
vec4f swizz = v.wzyx; // construct from swizzle swizz = v.xxxx; // assign from swizzle swizz.wyxz = v.xxyy; // assign swizzle to swizzle vec2f v2 = swizz.yz; // contstruct truncated swizz.wx = v.xy; // assign truncated swizz.xyz *= swizz2.www; // arithmetic on swizzles vec2 v2 = swizz.xy * 2.0f; // swizzle / scalar arithmentic // sometimes you may need to cast from swizzle to vec if c++ cant apply implict casts f32 dp = dot((vec2f)swizz.xz, (vec2f)swizz.yy):
For more information or to clone or fork this repository please visit the github page.