translate

Append a translation transform inferred from arguments to the matrix m. This is equivalent to the expression

translation(...) * m
but actually save computation by knowing where the ones and zeros are in a pure translation matrix.

Examples

import gfx.math.approx : approxUlp;

immutable m = DMat3( 1, 2, 3, 4, 5, 6, 7, 8, 9 );

immutable expected = translation(7, 12) * m;  // full multiplication
immutable result = translate(m, 7, 12);       // simplified multiplication

assert (approxUlp(expected, result));
import gfx.math.approx : approxUlp;

immutable m = DMat4( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );

immutable expected = translation(7, 12, 18) * m;  // full multiplication
immutable result = translate(m, 7, 12, 18);       // simplified multiplication

assert (approxUlp(expected, result));

Meta