Thursday, 23 March 2017

Matrix transformations (Anton)

Now when we have points in 3D space where the persons are referenced against origin point (camera) and we need to move them from camera reference to the lamps reference we could use matrix transforms:

http://www.codinglabs.net/article_world_view_projection_matrix.aspx

http://web.iitd.ac.in/~hegde/cad/lecture/L6_3dtrans.pdf

They might look intimidating, but they are actually very lovely, the magic is that you can rotate objects around their axis, around world (or other pivot points) move them, scale them you apply all these actions on single matrix and then when you done you can this matrix can be applied to many points, which saves computing power as well. What is lovely that the matrix supports unlimited amount of operations and still it will be just single matrix containing these operations and capable to execute them in a single pass. In our case the matrix would be calculated for each lamp separately but then we can apply it for all points.

The supplied links might look scary because they support lots of features, we might need only rotation and translation. Rotation is only rotation around the origin point, if you want to rotate the object around it's center you need to translate the origin into the center of the object temporary, apply rotation, then apply translation to move the origin back and yet still it will be only 1 matrix when applied will do all these actions.

I remember years ago when I was doing these for a game engine, it made huge difference and in the end added lot of simplicity, temporary complexity to have simpler and better design in a long run. Just I'm not 100% sure we will get there and might end up only with single lamp instead of the planned family, because when I interpolate the speed at which all teams are going I'm not sure we can deliver 3 lamps.

If this will be done in python there might be a library which will do all the dirty math for us:

https://pypi.python.org/pypi/transforms3d

Some python examples:

http://matthew-brett.github.io/transforms3d/gimbal_lock.html

If we will not find use for this I hope at least some future team will.



No comments:

Post a Comment