Why is 4×4 matrices used to transform things in 3D?
Reason Behind The Use Of 4×4 matrices to Transform Things in 3D
For example, rotation is usually done using a matrix, so in order to deal with multiple transformations (rotation/translation/scaling/projection…etc) in a uniform way, you need to encode them in a matrix.
Well, more technically speaking; a transformation is mapping a point/vector to another point/vector.
p` = T(p);
where p` is the transformed point and T(p) is the transformation function.
Given that we don’t use a matrix we need to do this to combine multiple transformations:
p1= T(p);
pfinal = M(p1);
Not only can a matrix combine multiple types of transformations into a single matrix (e.g. affine, linear, projective).
Using a matrix gives us the opportunity to combine chains of transformations and then batch multiply them. This saves us a ton of cycles usually by the GPU (thanks to @ChristianRau for pointing it out).
Tfinal = T * R * P; // translaterotateproject
pfinal = Tfinal*p;
It’s also good to point out that GPUs and even some CPUs are optimized for vector operations; CPUs using SIMD and GPUs being data driven parallel processors by design, so using matrices fits perfectly with hardware acceleration (actually, GPUs were designed to fit matrix/vector operations).
CREDIT:
https://gamedev.stackexchange.com/questions/72044/why-do-we-use-4×4-matrices-to-transform-things-in-3d?answertab=active#tab-top
Leave an answer
You must login or register to add a new answer.