Function 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.

M rotate(M, T) (
  in M m,
  in T angle
)
if (isMat!(3, 3, M) && isFloatingPoint!T);

M rotate(M, T) (
  in M m,
  in T angle
)
if (isMat!(2, 3, M) && isFloatingPoint!T);

M rotate(M, T, V) (
  in M m,
  in T angle,
  in V axis
)
if (isMat!(4, 4, M) && isFloatingPoint!T && isVec!(3, V));

M rotate(M, T, V) (
  in M m,
  in T angle,
  in V axis
)
if (isMat!(3, 4, M) && isVec!(3, V) && isFloatingPoint!T);

M rotate(M, T) (
  in M m,
  in T angle,
  in T x,
  in T y,
  in T z
)
if ((isMat!(3, 4, M) || isMat!(4, 4, M)) && isFloatingPoint!T);

Example

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));

Example

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));