Skip to content


Stefan Maierhofer edited this page Sep 5, 2017 · 4 revisions

Transforming Vectors and Points

Matrices and vectors of the same dimension can be multiplied directly:

V4d v;
M44d m;
V4d r = m * v; // matrix * vector -> vector

In order to multiply 3-dim vectors by a 4x4 matrix (which is often the case in computer graphics) you have to use one of the Transform methods provided by matrix types:

V3d p, v;
M44d m;
V3d a = m.TransformPos(p);  // w-component assumed to be 1 (location)
V3d b = m.TransformDir(v);  // w-component assumed to be 0 (direction)

A Trafo3d is a Container for two M44d fields, a Matrix and its Inverse

Since it is often a lot easier to maintain the inverse of a matrix as opposed to computing the inverse as necessary, a special object that contains both, a matrix and its inverse, has been created. Thus a Trafo3d contains two M44d members, one called Forward, one called Backward .

Note also, that the multiplication of two M44d structs follows mathematical rules:

M44d m1;
M44d m2;
M44d m = m2 * m1; // transform first by m1, then by m2 !!!

whereas, the multiplication of two Trafo3d objects is defined differently:

Trafo3d t1;
Trafo3d t2;
Trafo3d t = t1 * t2; // transform first by t1, then by t2 !!!
Clone this wiki locally
You can’t perform that action at this time.