Skip to content

Instantly share code, notes, and snippets.

@rygorous
rygorous / gist:8c03770f4b1c93895d8c
Last active August 29, 2015 14:15
Simple approximate eigensolver for paniq
static float const singularEps = 2 * 1.192092896e-7f; // float32 epsilon, *2 to have a bit of margin
// QR factorization using MGS
// store 1 / diag elements in diag of R since that's what we need
bool QR(IN(mat3,m),OUT(mat3,q),OUT(mat3,r)) {
q[0] = normalize(m[0]);
q[1] = normalize(m[1] - dot(m[1], q[0])*q[0]);
q[2] = cross(q[0], q[1]);
float d0 = dot(m[0], q[0]);