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.

  1. M translate(M m, X x, Y y)
    pure @safe @nogc nothrow
    M
    translate
    (
    M
    X
    Y
    )
    (
    in M m
    ,
    in X x
    ,
    in Y y
    )
    if (
    isMat!(3, 3, M) &&
    allSatisfy!(isNumeric, X, Y)
    )
  2. M translate(M m, X x, Y y)
  3. M translate(M m, V v)
  4. M translate(M m, X x, Y y, Z z)
  5. M translate(M m, X x, Y y, Z z)
  6. M translate(M m, V v)

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