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>Mtx44, Mtx44Ptr</H1> 12 13<H2>Syntax</H2> 14<dl><dd><pre class="construction"> 15#include <revolution/mtx/GeoTypes.h> 16 17typedef f32 Mtx44[4][4]; 18typedef f32 (*Mtx44Ptr)[4]; 19 20#define MTX44_PTR_OFFSET 4 21</pre></dd></dl> 22 23<H2>Arguments</H2> 24<P>None.</P> 25 26<H2>Return Values</H2> 27<P>None.</P> 28 29<H2>Description</H2> 30<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>, and <a href="../Projection/MTXOrtho.html"><code>MTXOrtho</code></a>. Each of these requires a matrix with an explicit fourth row. <STRONG>Mtx44</STRONG> is not used by any other <code>MTX</code> functions.</P> 31<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>Mtx44</STRONG>: in memory, from a mathematical viewpoint, and as a C-style array.</P> 32<DIV align="center"> 33<TABLE border="1" cellspacing="1" cellpadding="7" width="400"> 34 <TBODY> 35 <TR> 36 <TD width="29%" bgcolor="#ffffff">Address</TD> 37 <TD width="31%" bgcolor="#ffffff">Mathematical</TD> 38 <TD width="40%" bgcolor="#ffffff">C arrays</TD> 39 </TR> 40 <TR> 41 <TD width="29%">0x80200080</TD> 42 <TD width="31%"><I>m<SUB>00</SUB></I></TD> 43 <TD width="40%">m[0][0]</TD> 44 </TR> 45 <TR> 46 <TD width="29%">0x80200084</TD> 47 <TD width="31%"><I>m<SUB>01</SUB></I></TD> 48 <TD width="40%">m[0][1]</TD> 49 </TR> 50 <TR> 51 <TD width="29%">0x80200088</TD> 52 <TD width="31%"><I>m<SUB>02</SUB></I></TD> 53 <TD width="40%">m[0][2]</TD> 54 </TR> 55 <TR> 56 <TD width="29%">0x8020008c</TD> 57 <TD width="31%"><I>m<SUB>03</SUB></I></TD> 58 <TD width="40%">m[0][3]</TD> 59 </TR> 60 <TR> 61 <TD width="29%">0x80200090</TD> 62 <TD width="31%"><I>m<SUB>10</SUB></I></TD> 63 <TD width="40%">m[1][0]</TD> 64 </TR> 65 <TR> 66 <TD width="29%">0x80200094</TD> 67 <TD width="31%"><I>m<SUB>11</SUB></I></TD> 68 <TD width="40%">m[1][1]</TD> 69 </TR> 70 <TR> 71 <TD width="29%">0x80200098</TD> 72 <TD width="31%"><I>m<SUB>12</SUB></I></TD> 73 <TD width="40%">m[1][2]</TD> 74 </TR> 75 <TR> 76 <TD width="29%">0x8020009c</TD> 77 <TD width="31%"><I>m<SUB>13</SUB></I></TD> 78 <TD width="40%">m[1][3]</TD> 79 </TR> 80 <TR> 81 <TD width="29%">0x802000a0</TD> 82 <TD width="31%"><I>m<SUB>20</SUB></I></TD> 83 <TD width="40%">m[2][0]</TD> 84 </TR> 85 <TR> 86 <TD width="29%">0x802000a4</TD> 87 <TD width="31%"><I>m<SUB>21</SUB></I></TD> 88 <TD width="40%">m[2][1]</TD> 89 </TR> 90 <TR> 91 <TD width="29%">0x802000a8</TD> 92 <TD width="31%"><I>m<SUB>22</SUB></I></TD> 93 <TD width="40%">m[2][2]</TD> 94 </TR> 95 <TR> 96 <TD width="29%">0x802000ac</TD> 97 <TD width="31%"><I>m<SUB>23</SUB></I></TD> 98 <TD width="40%">m[2][3]</TD> 99 </TR> 100 <TR> 101 <TD width="29%">0x802000b0</TD> 102 <TD width="31%"><I>m<SUB>30</SUB></I></TD> 103 <TD width="40%">m[3][0]</TD> 104 </TR> 105 <TR> 106 <TD width="29%">0x802000b4</TD> 107 <TD width="31%"><SUB><I>m<SUB>31</SUB></I></SUB></TD> 108 <TD width="40%">m[3][1]</TD> 109 </TR> 110 <TR> 111 <TD width="29%">0x802000b8</TD> 112 <TD width="31%"><SUB><I>m<SUB>32</SUB></I></SUB></TD> 113 <TD width="40%">m[3][2]</TD> 114 </TR> 115 <TR> 116 <TD width="29%">0x802000bc</TD> 117 <TD width="31%"><SUB><I>m<SUB>33</SUB></I></SUB></TD> 118 <TD width="40%">m[3][3]</TD> 119 </TR> 120 </TBODY> 121</TABLE> 122</DIV> 123 124<P><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 <a href="../General/MTXRowCol.html"><code>MTXRowCol(m,row,col)</code></a> macro defined in <code>mtx.h</code>.</P> 125<P><code><strong>Mtx44Ptr</strong></code> is a pointer to an array of 4 floats. <strong>Mtx44Ptr</STRONG> is also a pointer to <STRONG>Mtx44</STRONG> and can replace <STRONG>Mtx44</STRONG> as a function argument. It is even possible to use sub-scripts just as with <STRONG>Mtx44</STRONG>. However, it is 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> 126<dl><dd><pre class="construction"> 127Mtx44 mProj; 128Mtx44Ptr m44Ptr; 129 130m44Ptr = mProj; 131 132MTXFrustum( mProj, 240, -240, -320, 320, 500, 2000 ); 133</pre></dd></dl> 134 135<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> 136<dl><dd><pre class="construction"> 137#define MTX44_PTR_OFFSET 4 138</pre></dd></dl> 139<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 the <STRONG>Mtx44</STRONG> storage format. For example:</P> 140<dl><dd><pre class="construction"> 141Mtx44 m44Array[2]; 142Mtx44Ptr m44Ptr; 143 144 m44Ptr = (Mtx44Ptr)m44Array; // mPtr points to m44Array[0] 145 146 MTXFrustum( m44Ptr, 240, -240, -320, 320, 500, 2000 ); 147 148 m44Ptr += MTX44_PTR_OFFSET ; // m44Ptr points to m44Array[1] 149 150 MTXOrtho( m44Ptr, 240, -240, -320, 320, 500, 2000 ); 151</pre></dd></dl> 152 153<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 <STRONG>Mtx44Ptr</STRONG> especially useful for functions that need to return a matrix. While the MTX library does not currently contain any functions that return a <STRONG>Mtx44Ptr</STRONG>, this feature may be useful in your own code.</P> 154 155<H2>See Also</H2> 156<P class="reference"> 157<A href="Mtx_MtxPtr.html">Mtx, MtxPtr</A>, 158<A href="../Projection/MTXFrustum.html">MTXFrustum</A>, 159<A href="../Projection/MTXOrtho.html">MTXOrtho</A>, 160<A href="../Projection/MTXPerspective.html">MTXPerspective</A>, 161<A href="../general/MTXRowCol.html">MTXRowCol</A> 162</P> 163 164<H2>Revision History</H2> 165<P> 1662006/03/01 Initial version.<br> 167</P> 168 169<hr><p>CONFIDENTIAL</p></body> 170</HTML>