Alex Dixon

Welcome to my programming blog and portfolio, I have worked in gamedev for over 10 years and I am currently principal programmer at Flavourworks. I enjoy shuffling bytes and swizzling vectors...


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.

There is a live WebGL demo of the intersection functions, this visual representation was also used to generate and verify test cases which run continuously via Travis CI and AppVeyor.

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 *= 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.