scale - multiple declarations
Function scale
Build a scale matrix.
Function scale
Append a scale transform inferred from arguments to the matrix m. This is equivalent to the expression
scale(...) * mbut actually save computation by knowing where the ones and zeros are in a pure scale matrix.
M scale(M, X, Y)
(
in M m,
in X x,
in Y y
)
if (isMat!(3, 3, M) && allSatisfy!(isNumeric, X, Y));
M scale(M, X, Y)
(
in M m,
in X x,
in Y y
)
if (isMat!(2, 3, M) && allSatisfy!(isNumeric, X, Y));
M scale(M, V)
(
in M m,
in V v
)
if ((isMat!(2, 3, M) || isMat!(3, 3, M)) && isVec!(2, V));
M scale(M, X, Y, Z)
(
in M m,
in X x,
in Y y,
in Z z
)
if (isMat!(4, 4, M) && allSatisfy!(isNumeric, X, Y, Z));
M scale(M, X, Y, Z)
(
in M m,
in X x,
in Y y,
in Z z
)
if (isMat!(3, 4, M) && allSatisfy!(isNumeric, X, Y, Z));
M scale(M, V)
(
in M m,
in V v
)
if ((isMat!(3, 4, M) || isMat!(4, 4, M)) && isVec!(3, V));
Example
import gfx .math .approx : approxUlp;
immutable m = DMat3( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
immutable expected = scale(4, 5) * m; // full multiplication
immutable result = scale(m, 4, 5); // simplified multiplication
assert (approxUlp(expected, result));
Example
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 = scale(4, 5, 6) * m; // full multiplication
immutable result = scale(m, 4, 5, 6); // simplified multiplication
assert (approxUlp(expected, result));