MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / invert

Function invert

test/hello_world_gles_proxy.c:411–429  ·  view source on GitHub ↗

* Inverts a 4x4 matrix. * * This function can currently handle only pure translation-rotation matrices. * Read http://www.gamedev.net/community/forums/topic.asp?topic_id=425118 * for an explanation. */

Source from the content-addressed store, hash-verified

409 * for an explanation.
410 */
411static void
412invert(GLfloat *m)
413{
414 GLfloat t[16];
415 identity(t);
416
417 // Extract and invert the translation part 't'. The inverse of a
418 // translation matrix can be calculated by negating the translation
419 // coordinates.
420 t[12] = -m[12]; t[13] = -m[13]; t[14] = -m[14];
421
422 // Invert the rotation part 'r'. The inverse of a rotation matrix is
423 // equal to its transpose.
424 m[12] = m[13] = m[14] = 0;
425 transpose(m);
426
427 // inv(m) = inv(r) * inv(t)
428 multiply(m, t);
429}
430
431/**
432 * Calculate a perspective projection transformation.

Callers 1

draw_gearFunction · 0.70

Calls 3

identityFunction · 0.70
transposeFunction · 0.70
multiplyFunction · 0.70

Tested by

no test coverage detected