Posted to tcl by auriocus at Sun Nov 26 14:39:12 GMT 2017view pretty
#include "cl.hpp" // OpenCL, here cl_float4 is defined typedef std::array<cl_float4, 4> mat4; // Diagonal matrix mat4 diag(float xs, float ys, float zs, float ws) { return mat4 {{ {xs, 0, 0, 0}, {0, ys, 0, 0}, {0, 0, zs, 0}, {0, 0, 0, ws} }}; } // Unit matrix mat4 eye() { return diag(1, 1, 1, 1); } // Isotropic scaling mat4 scale(float s) { return diag(s, s, s, 1); } // Euler rotation matrices mat4 eulerz(float alpha) { float c = cos(alpha); float s = sin(alpha); return mat4 {{ { c, s, 0, 0}, {-s, c, 0, 0}, { 0, 0, 1, 0}, { 0, 0, 0, 1} }}; }