This page was last modified 20101103 10:05:34 by Puchu.Net user Choco. (Show history)
[edit] Matrix RepresentationWhile working with libraries like OpenGL, matrices are represented as a 16element array. There are two representations, row or columnmajor and this indicates how elements are stored and manipulated. So if a translation matrix looks like this: For OpenGL, which uses columnmajor style, elements , , and are accessed with indices 13, 14, and 15. In a system that uses rowmajor style, these same elements will be accessed with indices 3, 7, and 11. The code fragments below uses columnmajor style. [edit] Matrix MultiplicationFinding matrix product of two matrices and involves calculating for each element: In C code this translates to a function like:
[edit] TransformsApply transforms is the same as multiplying with the corresponding transformation matrices. [edit] TranslateTo move by a translation vector : [edit] ScaleTo scale by a factor in each axis: [edit] RotateBasic rotations about the x, y, and z axes: rotates the yaxis towards the zaxis rotates the zaxis towards the xaxis rotates the xaxis towards the yaxis To rotate radians about an arbitrary, normalized axis : where and
[edit] ShearTo apply shear along x, y, or zaxis, modify the coefficients below: [edit] References
Categories: Media  Article  Graphic 

