transform

Transform a vector by a matrix in homogenous coordinates.

  1. auto transform(V v, M m)
    pure @safe @nogc nothrow
    transform
    (
    V
    M
    )
    (
    in V v
    ,
    in M m
    )
    if (
    isVec!(2, V) &&
    isMat!(3, 3, M)
    )
  2. auto transform(V v, M m)
  3. auto transform(V v, M m)
  4. auto transform(V v, M m)
  5. auto transform(V v, M m)

Examples

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

immutable v = dvec(2, 0);
auto m = DMat2x3.identity;

m = m.rotate(PI/2);
assert ( approxUlpAndAbs(transform(v, m), dvec(0, 2)) );

m = m.translate(2, 2);
assert ( approxUlp(transform(v, m), dvec(2, 4)) );

m = m.scale(2, 2);
assert ( approxUlp(transform(v, m), dvec(4, 8)) );
import gfx.math.approx : approxUlp;

auto st = scale!float(2, 2).translate(3, 1);
assert( approxUlp(transform(fvec(0, 0), st), fvec(3, 1)) );
assert( approxUlp(transform(fvec(1, 1), st), fvec(5, 3)) );

auto ts = translation!float(3, 1).scale(2, 2);
assert( approxUlp(transform(fvec(0, 0), ts), fvec(6, 2)) );
assert( approxUlp(transform(fvec(1, 1), ts), fvec(8, 4)) );

Meta