Makman2 / CE3D

A terminal 3D engine
GNU General Public License v3.0
4 stars 0 forks source link

Fast transformation chains. #148

Open Makman2 opened 10 years ago

Makman2 commented 10 years ago

I'm just learning for the math exams and see that you can save matrix calculation overhead if you just don't calculate the full matrix. For example the Householder matrix: H = I - 2*vv^T/v^T v multiply with a vector to apply transformation: H*x This can be transformed into: _Hx = x - 2v v^T_x/v^Tv Here you only need to calculate two scalar products, a matrix scalar product and a vector subtraction. Especially for high dimensional vectors this could be a great speed improvement.

The idea: We make new transformations, prefix them maybe with 'Fast' or something like that, that contain a transformation chain inside where we push the vectors and not the complete calculated matrix. If you want you can call GetMatrix() and get it anyway, but when we add a 'Multiply(vector)' function to the transformation chains, that multiplies each step with the vector, we have this fast thing. This won't work completely for Householder matrices (because you subtract the vector itself), but for linear systems this would work. For non-linear systems we can make a new transformation class that applies such functions. We could then mix both systems together.