rotate

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

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

  1. M rotate(M m, T angle)
  2. M rotate(M m, T angle)
    pure @safe @nogc nothrow
    M
    rotate
    (
    M
    T
    )
    (
    in M m
    ,
    in T angle
    )
    if (
    isMat!(2, 3, M) &&
    isFloatingPoint!T
    )
  3. M rotate(M m, T angle, V axis)
  4. M rotate(M m, T angle, V axis)
  5. M rotate(M m, T angle, T x, T y, T z)

Examples

import gfx.math.approx : approxUlp;
import std.math : PI;

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

immutable expected = rotation!double(PI) * m; // full multiplication
immutable result = rotate(m, PI);      // simplified multiplication

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

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

immutable expected = rotation(angle, v) * m; // full multiplication
immutable result = rotate(m, angle, v);      // simplified multiplication

assert (approxUlp(expected, result));

Meta