1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 8<TITLE>Mtx44, Mtx44Ptr</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">Mtx44, Mtx44Ptr</H1> 12<H2 align="left">C Specification</H2> 13<BLOCKQUOTE><CODE><code>#include <revolution/mtx/GeoTypes.h></CODE></CODE><BR> <BR> <CODE><CODE>typedef f32 Mtx44[4][4];<BR> typedef f32 (*Mtx44Ptr)[4];</CODE></CODE><BR> <BR> <CODE>#define MTX44_PTR_OFFSET 4</CODE></BLOCKQUOTE> 14<H2 align="left">Arguments</H2> 15<P align="left">None.</P> 16<H2 align="left">Return Values</H2> 17<P align="left">None.</P> 18<H2 align="left">Description</H2> 19<P><strong><code><EM>Mtx44</EM></code></strong>is a four-row, four-column, two-dimensional array of 16 floating point values. <code><strong><EM>Mtx44</EM></strong></code> exists to provide a true 4x4 matrix for the routines that generate projection matrices: <a href="../Projection/MTXFrustum.html"><code>MTXFrustum</code></a>, <a href="../Projection/MTXPerspective.html"><code>MTXPerspective</code></a>, <a href="../Projection/MTXOrtho.html"><code>MTXOrtho</code></a>. Each of these requires a matrix with an explicit fourth row. <code><strong><EM>Mtx44</EM></strong></code> is not used by any other <code>MTX</code> functions. </P> 20<P><code><strong><EM>Mtx44</EM></strong></code> is stored and de-referenced C-style in row-major format. The table below summarizes the three ways of looking at a <strong><CODE><EM>Mtx44</EM></CODE></strong>: in memory, from a mathematical viewpoint, and as a C-style array.</P> 21<DIV align="center"> 22<CENTER> 23<TABLE border="1" cellspacing="1" cellpadding="7" width="400"> 24 <TBODY> 25 <TR> 26<TD width="29%" valign="TOP" bgcolor="#ffffff">address</TD> 27<TD width="31%" valign="TOP" bgcolor="#ffffff">Mathematical</TD> 28<TD width="40%" valign="TOP" bgcolor="#ffffff">C arrays</TD> 29 </TR> 30 <TR> 31<TD width="29%" valign="TOP">0x80200080</TD> 32<TD width="31%" valign="TOP"><I>m<SUB>00</SUB></I></TD> 33<TD width="40%" valign="TOP">m[0][0]</TD> 34 </TR> 35 <TR> 36<TD width="29%" valign="TOP">0x80200084</TD> 37<TD width="31%" valign="TOP"><I>m<SUB>01</SUB></I></TD> 38<TD width="40%" valign="TOP">m[0][1]</TD> 39 </TR> 40 <TR> 41<TD width="29%" valign="TOP">0x80200088</TD> 42<TD width="31%" valign="TOP"><I>m<SUB>02</SUB></I></TD> 43<TD width="40%" valign="TOP">m[0][2]</TD> 44 </TR> 45 <TR> 46<TD width="29%" valign="TOP">0x8020008c</TD> 47<TD width="31%" valign="TOP"><I>m<SUB>03</SUB></I></TD> 48<TD width="40%" valign="TOP">m[0][3]</TD> 49 </TR> 50 <TR> 51<TD width="29%" valign="TOP">0x80200090</TD> 52<TD width="31%" valign="TOP"><I>m<SUB>10</SUB></I></TD> 53<TD width="40%" valign="TOP">m[1][0]</TD> 54 </TR> 55 <TR> 56<TD width="29%" valign="TOP">0x80200094</TD> 57<TD width="31%" valign="TOP"><I>m<SUB>11</SUB></I></TD> 58<TD width="40%" valign="TOP">m[1][1]</TD> 59 </TR> 60 <TR> 61<TD width="29%" valign="TOP">0x80200098</TD> 62<TD width="31%" valign="TOP"><I>m<SUB>12</SUB></I></TD> 63<TD width="40%" valign="TOP">m[1][2]</TD> 64 </TR> 65 <TR> 66<TD width="29%" valign="TOP">0x8020009c</TD> 67<TD width="31%" valign="TOP"><I>m<SUB>13</SUB></I></TD> 68<TD width="40%" valign="TOP">m[1][3]</TD> 69 </TR> 70 <TR> 71<TD width="29%" valign="TOP">0x802000a0</TD> 72<TD width="31%" valign="TOP"><I>m<SUB>20</SUB></I></TD> 73<TD width="40%" valign="TOP">m[2][0]</TD> 74 </TR> 75 <TR> 76<TD width="29%" valign="TOP">0x802000a4</TD> 77<TD width="31%" valign="TOP"><I>m<SUB>21</SUB></I></TD> 78<TD width="40%" valign="TOP">m[2][1]</TD> 79 </TR> 80 <TR> 81<TD width="29%" valign="TOP">0x802000a8</TD> 82<TD width="31%" valign="TOP"><I>m<SUB>22</SUB></I></TD> 83<TD width="40%" valign="TOP">m[2][2]</TD> 84 </TR> 85 <TR> 86<TD width="29%" valign="TOP">0x802000ac</TD> 87<TD width="31%" valign="TOP"><I>m<SUB>23</SUB></I></TD> 88<TD width="40%" valign="TOP">m[2][3]</TD> 89 </TR> 90 <TR> 91<TD width="29%" valign="TOP">0x802000b0</TD> 92<TD width="31%" valign="TOP"><I>m<SUB>30</SUB></I></TD> 93<TD width="40%" valign="TOP">m[3][0]</TD> 94 </TR> 95 <TR> 96<TD width="29%" valign="TOP">0x802000b4</TD> 97<TD width="31%" valign="TOP"><SUB><I>m<SUB>31</SUB></I></SUB></TD> 98<TD width="40%" valign="TOP">m[3][1]</TD> 99 </TR> 100 <TR> 101<TD width="29%" valign="TOP">0x802000b8</TD> 102<TD width="31%" valign="TOP"><SUB><I>m<SUB>32</SUB></I></SUB></TD> 103<TD width="40%" valign="TOP">m[3][2]</TD> 104 </TR> 105 <TR> 106<TD width="29%" valign="TOP">0x802000bc</TD> 107<TD width="31%" valign="TOP"><SUB><I>m<SUB>33</SUB></I></SUB></TD> 108<TD width="40%" valign="TOP">m[3][3]</TD> 109 </TR> 110 </TBODY> 111</TABLE> 112</CENTER> 113</DIV> 114<P align="left"><B>Note:</B> Storage format is transparent to the programmer if matrices are set and manipulated exclusively by <code>MTX</code> functions, but is relevant if matrix elements are set individually. To insulate code from future changes to the storage format, do not set matrix values by hand, and do not initialize matrices when they are first declared. Instead, use the macro <a href="../general/MTXRowCol.html"><code>MTXRowCol(m,row,col)</code></a> defined in <code>mtx.h</code>.</P> 115<P><code><strong><EM>Mtx44Ptr</EM></strong></code> is a pointer to an array of four floats. <strong><CODE><EM>Mtx44Ptr</EM></CODE></STRONG> is also a pointer to <STRONG><CODE><EM>Mtx44</EM></CODE></STRONG> and can replace <STRONG><CODE><EM>Mtx44</EM></CODE></STRONG> as a function argument. It is even possible to use sub-scripts just as with <STRONG><CODE><EM>Mtx44</EM></CODE></STRONG>. However, it's really a pointer to an array of four floats. This has two implications. First, a <strong><CODE><EM>Mtx44Ptr</EM></CODE></strong> is assigned to a <strong><CODE><EM>Mtx44</EM></CODE></strong> without the use of the <CODE>&</CODE> operator. For example: </P> 116<BLOCKQUOTE><CODE>Mtx44 mProj;<BR> Mtx44Ptr m44Ptr;</CODE></BLOCKQUOTE> 117<BLOCKQUOTE><CODE>m44Ptr = mProj;</CODE></BLOCKQUOTE> 118<BLOCKQUOTE><CODE>MTXFrustum( mProj, 240, -240, -320, 320, 500, 2000 ); <BR></CODE></BLOCKQUOTE> 119<P>Second, you cannot just increment and decrement an <code><strong><EM>Mtx44Ptr</EM></strong></code>, because its size is 16, not 64. Therefore, we have defined a constant in <code>mtx.h</code> which provides the correct multiplier to offset a <code><strong><EM>Mtx44Ptr</EM></strong></code> by the size of one matrix:</P> 120<BLOCKQUOTE><CODE>#define MTX44_PTR_OFFSET 4</CODE></BLOCKQUOTE> 121<P>Use <code>MTX44_PTR_OFFSET</code> whenever you need to increment a <code><strong><EM>Mtx44Ptr</EM></strong></code> to the next matrix of an array. This will insulate your code from future changes to <code><strong><EM>Mtx44</EM></strong></code> storage format. For example: </P> 122<BLOCKQUOTE><CODE>Mtx44 m44Array[2];<BR> Mtx44Ptr m44Ptr;</CODE></BLOCKQUOTE> 123<BLOCKQUOTE><CODE>m44Ptr = (Mtx44Ptr)m44Array; // mPtr points to m44Array[0]</CODE></BLOCKQUOTE> 124<BLOCKQUOTE><CODE>MTXFrustum( m44Ptr, 240, -240, -320, 320, 500, 2000 ); </CODE></BLOCKQUOTE> 125<BLOCKQUOTE><CODE>m44Ptr += MTX44_PTR_OFFSET ; // m44Ptr points to m44Array[1]</CODE></BLOCKQUOTE> 126<BLOCKQUOTE><CODE>MTXOrtho( m44Ptr, 240, -240, -320, 320, 500, 2000 ); </CODE></BLOCKQUOTE> 127<P>A function cannot return a pointer to a two-dimensional array, but it can return a <code><strong><EM>Mtx44Ptr</EM></strong></code>. This makes <code><strong><EM>Mtx44Ptr</EM></strong></code> especially useful for functions that need to return a matrix. While the <code>MTX</code> library does not currently contain any functions that return a <code><strong><EM>Mtx44Ptr</EM></strong></code>, this feature may be useful in your own code.</P> 128 129 130<H2 align="left">See Also</H2> 131<P align="left"><CODE><A href="Mtx_MtxPtr.html">Mtx, MtxPtr</A>, 132<A href="../Projection/MTXFrustum.html"><CODE>MTXFrustum</CODE></A>, <A href="../Projection/MTXOrtho.html"><CODE>MTXOrtho</CODE></A>, <A href="../Projection/MTXPerspective.html"><CODE>MTXPerspective</CODE></A>, <A href="../general/MTXRowCol.html"><CODE>MTXRowCol</CODE></A></P> 133<H2>Revision History</H2> 134<P>2006/03/01 Initial version.</P> 135<hr> 136<P>CONFIDENTIAL</p> 137</BODY> 138</HTML>