This page was last modified 2010-11-03 10:05:34 by Puchu.Net user Choco. (Show history)
[edit] Matrix RepresentationWhile working with libraries like OpenGL, matrices are represented as a 16-element array. There are two representations, row- or column-major and this indicates how elements are stored and manipulated. So if a translation matrix looks like this: For OpenGL, which uses column-major style, elements , , and are accessed with indices 13, 14, and 15. In a system that uses row-major style, these same elements will be accessed with indices 3, 7, and 11. The code fragments below uses column-major 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 y-axis towards the z-axis rotates the z-axis towards the x-axis rotates the x-axis towards the y-axis To rotate radians about an arbitrary, normalized axis : where and
[edit] ShearTo apply shear along x-, y-, or z-axis, modify the coefficients below: [edit] References
Categories: Media | Article | Graphic |
|
||||