#include <revolution/mtx.h>
#define MTXRowCol(m,r,c) ((m)[(r)][(c)])
m |
Mtx to be accessed. |
r |
Row index of the element to be accessed. |
c |
Column index of the element to be accessed. |
None.
This macro provides storage-safe access to elements of Mtx and Mtx44. Matrix storage format is transparent to the programmer as long as matrices are initialized and manipulated exclusively with the MTX API. Since matrix storage format may change in the future, it is dangerous to access matrix elements explicitly. Do not initialize matrices when they are first declared and do not set values programmatically. To insulate code from changes to matrix storage format, you should use this macro instead of directly accessing individual matrix elements. If matrix storage format changes in the future, this macro will be redefined.
When using MTXRowCol, think of the matrix in row-major format.
MTXRowCol may be used in both 'get' and 'set' operations. For example, to get the value stored in row 2, column 1 of a matrix m:
val = MTXRowCol( m, 2, 1 );
To store a value in row 2, column 1 of a matrix m:
MTXRowCol( m, 2, 1 ) = val;
03/01/2006 Initial version.