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

Function invert

test/full_es2_sdlproc.c:393–411  ·  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

391 * for an explanation.
392 */
393static void
394invert(GLfloat *m)
395{
396 GLfloat t[16];
397 identity(t);
398
399 // Extract and invert the translation part 't'. The inverse of a
400 // translation matrix can be calculated by negating the translation
401 // coordinates.
402 t[12] = -m[12]; t[13] = -m[13]; t[14] = -m[14];
403
404 // Invert the rotation part 'r'. The inverse of a rotation matrix is
405 // equal to its transpose.
406 m[12] = m[13] = m[14] = 0;
407 transpose(m);
408
409 // inv(m) = inv(r) * inv(t)
410 multiply(m, t);
411}
412
413/**
414 * 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