Efficiency in vector translation by matrix instead of vector

220 Views Asked by At

I try to understand math for 3D games.

If I want to translate a point, I may do it in two ways:
1. Using vector summation.
2. Using matrix multiplication.

For example: Initial vector $p =(1,2,3)$.
has to be translated by $t=(4,5,-6)$.
$p + a = p2 => (1+4, 2+5, 3-6) = (5,7,-3)$.

If I want to complete "undo", I may $p3 = p2 + (-a)$ ,
The math is simple.

But in books people often use matrix multiplication
from wiki

For me it seems like doing much more computation.

I wonder, why do people use 4x4 matrix to do the same thing?

2

There are 2 best solutions below

2
On BEST ANSWER

The basic idea is to describe all affine transformations (scaling, translation, rotation) by more or less the same operation, namely multiplication by a $4\times 4$-matrix. To achive this, we embed, as you write $\mathbb R^3$ into $\mathbb RP^3$, or the affine part of it, i. e. $\mathbb R^3 \times \{1\} \subseteq \mathbb R^4$. A scaling, or rotation, respresented in $\mathbb R^3$ by a matrix multiplication, $x \mapsto Ax$ for some $A \in {\rm Mat}_3(\mathbb R)$, is now represented by $$ \begin{pmatrix} A & 0 \\ 0 & 1 \end{pmatrix} \cdot \begin{pmatrix} x \\ 1\end{pmatrix} = \begin{pmatrix} Ax \\ 1 \end{pmatrix} $$ any affine map $x \mapsto Ax + b$ can now be represented as above, $$ \begin{pmatrix} A & b \\ 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ 1 \end{pmatrix} = \begin{pmatrix} Ax + b \\ 1 \end{pmatrix} $$ A key point is, that the composition of opertions is now just matrix multiplication, if you differentiate between linear operations and translation, computing compositions is harder.

0
On

As far as I know, calculating $T_vp$ in the way you described is not computationaly efficient. If you just want to calculate $v+p$, then it is simpler to calculate it by summing all of the coordinate scalars of $v$ and $p$.

The matrix $T_v$ shows only that the nonlinear mapping $x\mapsto x+v$ (which is not a linear mapping for $v\neq 0$ can be understood as a linear mapping, albeit in a higher dimensional space.