diff options
Diffstat (limited to 'docs/doxygen/nel/matrix_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/matrix_8cpp-source.html | 1639 |
1 files changed, 1639 insertions, 0 deletions
diff --git a/docs/doxygen/nel/matrix_8cpp-source.html b/docs/doxygen/nel/matrix_8cpp-source.html new file mode 100644 index 00000000..d9bde259 --- /dev/null +++ b/docs/doxygen/nel/matrix_8cpp-source.html @@ -0,0 +1,1639 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>matrix.cpp</h1><a href="matrix_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="matrix_8h.html">nel/misc/matrix.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="plane_8h.html">nel/misc/plane.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font> +00031 +00032 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00033 +00034 +00035 +00036 <font class="keyword">namespace </font>NLMISC +00037 { +00038 +00039 +00040 <font class="comment">// ======================================================================================================</font> +<a name="l00041"></a><a class="code" href="classNLMISC_1_1CMatrix.html#p0">00041</a> <font class="keyword">const</font> CMatrix CMatrix::Identity; +00042 +00043 +00044 <font class="comment">// ======================================================================================================</font> +00045 <font class="comment">// ======================================================================================================</font> +00046 <font class="comment">// ======================================================================================================</font> +00047 +00048 +00049 <font class="comment">// State Bits.</font> +<a name="l00050"></a><a class="code" href="matrix_8cpp.html#a0">00050</a> <font class="preprocessor">#define MAT_TRANS 1</font> +<a name="l00051"></a><a class="code" href="matrix_8cpp.html#a1">00051</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_ROT 2</font> +<a name="l00052"></a><a class="code" href="matrix_8cpp.html#a2">00052</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_SCALEUNI 4</font> +<a name="l00053"></a><a class="code" href="matrix_8cpp.html#a3">00053</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_SCALEANY 8</font> +<a name="l00054"></a><a class="code" href="matrix_8cpp.html#a4">00054</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_PROJ 16</font> +00055 <font class="preprocessor"></font><font class="comment">// Validity bits. These means that the part may be yet identity, but is valid in the floats.</font> +00056 <font class="comment">// NB: MAT_VALIDTRANS no more used for faster Pos access</font> +<a name="l00057"></a><a class="code" href="matrix_8cpp.html#a5">00057</a> <font class="preprocessor">#define MAT_VALIDROT 64</font> +<a name="l00058"></a><a class="code" href="matrix_8cpp.html#a6">00058</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_VALIDPROJ 128</font> +<a name="l00059"></a><a class="code" href="matrix_8cpp.html#a7">00059</a> <font class="preprocessor"></font><font class="preprocessor">#define MAT_VALIDALL (MAT_VALIDROT | MAT_VALIDPROJ)</font> +00060 <font class="preprocessor"></font><font class="comment">// The identity is nothing.</font> +<a name="l00061"></a><a class="code" href="matrix_8cpp.html#a8">00061</a> <font class="preprocessor">#define MAT_IDENTITY 0</font> +00062 <font class="preprocessor"></font> +00063 +00064 +00065 <font class="comment">// Matrix elements.</font> +<a name="l00066"></a><a class="code" href="matrix_8cpp.html#a9">00066</a> <font class="preprocessor">#define a11 M[0]</font> +<a name="l00067"></a><a class="code" href="matrix_8cpp.html#a10">00067</a> <font class="preprocessor"></font><font class="preprocessor">#define a21 M[1]</font> +<a name="l00068"></a><a class="code" href="matrix_8cpp.html#a11">00068</a> <font class="preprocessor"></font><font class="preprocessor">#define a31 M[2]</font> +<a name="l00069"></a><a class="code" href="matrix_8cpp.html#a12">00069</a> <font class="preprocessor"></font><font class="preprocessor">#define a41 M[3]</font> +<a name="l00070"></a><a class="code" href="matrix_8cpp.html#a13">00070</a> <font class="preprocessor"></font><font class="preprocessor">#define a12 M[4]</font> +<a name="l00071"></a><a class="code" href="matrix_8cpp.html#a14">00071</a> <font class="preprocessor"></font><font class="preprocessor">#define a22 M[5]</font> +<a name="l00072"></a><a class="code" href="matrix_8cpp.html#a15">00072</a> <font class="preprocessor"></font><font class="preprocessor">#define a32 M[6]</font> +<a name="l00073"></a><a class="code" href="matrix_8cpp.html#a16">00073</a> <font class="preprocessor"></font><font class="preprocessor">#define a42 M[7]</font> +<a name="l00074"></a><a class="code" href="matrix_8cpp.html#a17">00074</a> <font class="preprocessor"></font><font class="preprocessor">#define a13 M[8]</font> +<a name="l00075"></a><a class="code" href="matrix_8cpp.html#a18">00075</a> <font class="preprocessor"></font><font class="preprocessor">#define a23 M[9]</font> +<a name="l00076"></a><a class="code" href="matrix_8cpp.html#a19">00076</a> <font class="preprocessor"></font><font class="preprocessor">#define a33 M[10]</font> +<a name="l00077"></a><a class="code" href="matrix_8cpp.html#a20">00077</a> <font class="preprocessor"></font><font class="preprocessor">#define a43 M[11]</font> +<a name="l00078"></a><a class="code" href="matrix_8cpp.html#a21">00078</a> <font class="preprocessor"></font><font class="preprocessor">#define a14 M[12]</font> +<a name="l00079"></a><a class="code" href="matrix_8cpp.html#a22">00079</a> <font class="preprocessor"></font><font class="preprocessor">#define a24 M[13]</font> +<a name="l00080"></a><a class="code" href="matrix_8cpp.html#a23">00080</a> <font class="preprocessor"></font><font class="preprocessor">#define a34 M[14]</font> +<a name="l00081"></a><a class="code" href="matrix_8cpp.html#a24">00081</a> <font class="preprocessor"></font><font class="preprocessor">#define a44 M[15]</font> +00082 <font class="preprocessor"></font> +00083 +00084 +00085 <font class="comment">// ======================================================================================================</font> +00086 <font class="comment">// ======================================================================================================</font> +00087 <font class="comment">// ======================================================================================================</font> +00088 +00089 +00090 +00091 <font class="comment">// ======================================================================================================</font> +<a name="l00092"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z295_1">00092</a> <font class="keywordtype">bool</font> CMatrix::hasScalePart()<font class="keyword"> const</font> +00093 <font class="keyword"></font>{ +00094 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&(<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>))!=0; +00095 } +<a name="l00096"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z295_4">00096</a> <font class="keywordtype">bool</font> CMatrix::hasProjectionPart()<font class="keyword"> const</font> +00097 <font class="keyword"></font>{ +00098 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>)!=0; +00099 } +00100 +00101 +<a name="l00102"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z295_2">00102</a> <font class="keywordtype">bool</font> CMatrix::hasScaleUniform()<font class="keyword"> const</font> +00103 <font class="keyword"></font>{ +00104 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>)!=0 && (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>)==0; +00105 } +<a name="l00106"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z295_3">00106</a> <font class="keywordtype">float</font> CMatrix::getScaleUniform()<font class="keyword"> const</font> +00107 <font class="keyword"></font>{ +00108 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#z295_2">hasScaleUniform</a>()) +00109 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>; +00110 <font class="keywordflow">else</font> +00111 <font class="keywordflow">return</font> 1; +00112 } +00113 +00114 +00115 +00116 <font class="comment">// ======================================================================================================</font> +<a name="l00117"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c7">00117</a> <font class="keyword">inline</font> <font class="keywordtype">bool</font> CMatrix::hasRot()<font class="keyword"> const</font> +00118 <font class="keyword"></font>{ +00119 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&(<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>))!=0; +00120 } +<a name="l00121"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c6">00121</a> <font class="keyword">inline</font> <font class="keywordtype">bool</font> CMatrix::hasTrans()<font class="keyword"> const</font> +00122 <font class="keyword"></font>{ +00123 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>)!=0; +00124 } +<a name="l00125"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c8">00125</a> <font class="keyword">inline</font> <font class="keywordtype">bool</font> CMatrix::hasProj()<font class="keyword"> const</font> +00126 <font class="keyword"></font>{ +00127 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>)!=0; +00128 } +<a name="l00129"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c9">00129</a> <font class="keyword">inline</font> <font class="keywordtype">bool</font> CMatrix::hasAll()<font class="keyword"> const</font> +00130 <font class="keyword"></font>{ +00131 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() && <a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>() && <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()); +00132 } +00133 +00134 +<a name="l00135"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c10">00135</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMatrix::testExpandRot()<font class="keyword"> const</font> +00136 <font class="keyword"></font>{ +00137 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00138 <font class="keywordflow">return</font>; +00139 <font class="keywordflow">if</font>(!(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a5">MAT_VALIDROT</a>)) +00140 { +00141 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> *self= const_cast<CMatrix*>(this); +00142 self->StateBit|=<a class="code" href="matrix_8cpp.html#a5">MAT_VALIDROT</a>; +00143 self->a11= 1; self->a12=0; self->a13=0; +00144 self->a21= 0; self->a22=1; self->a23=0; +00145 self->a31= 0; self->a32=0; self->a33=1; +00146 self->Scale33= 1; +00147 } +00148 } +<a name="l00149"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c11">00149</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMatrix::testExpandProj()<font class="keyword"> const</font> +00150 <font class="keyword"></font>{ +00151 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()) +00152 <font class="keywordflow">return</font>; +00153 <font class="keywordflow">if</font>(!(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&<a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>)) +00154 { +00155 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> *self= const_cast<CMatrix*>(this); +00156 self->StateBit|=<a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>; +00157 self->a41=0; self->a42=0; self->a43=0; self->a44=1; +00158 } +00159 } +00160 +00161 +00162 <font class="comment">// ======================================================================================================</font> +<a name="l00163"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z289_1">00163</a> CMatrix::CMatrix(<font class="keyword">const</font> CMatrix &m) +00164 { +00165 (*this)= m; +00166 } +00167 <font class="comment">// ======================================================================================================</font> +<a name="l00168"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z289_2">00168</a> CMatrix &CMatrix::operator=(<font class="keyword">const</font> CMatrix &m) +00169 { +00170 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>= m.StateBit & ~<a class="code" href="matrix_8cpp.html#a7">MAT_VALIDALL</a>; +00171 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c9">hasAll</a>()) +00172 { +00173 memcpy(<a class="code" href="classNLMISC_1_1CMatrix.html#o0">M</a>, m.M, 16*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00174 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= m.Scale33; +00175 } +00176 <font class="keywordflow">else</font> +00177 { +00178 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00179 { +00180 memcpy(&<a class="code" href="matrix_8cpp.html#a9">a11</a>, &m.a11, 3*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00181 memcpy(&<a class="code" href="matrix_8cpp.html#a13">a12</a>, &m.a12, 3*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00182 memcpy(&<a class="code" href="matrix_8cpp.html#a17">a13</a>, &m.a13, 3*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00183 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= m.Scale33; +00184 } +00185 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()) +00186 { +00187 <a class="code" href="matrix_8cpp.html#a12">a41</a>= m.a41; +00188 <a class="code" href="matrix_8cpp.html#a16">a42</a>= m.a42; +00189 <a class="code" href="matrix_8cpp.html#a20">a43</a>= m.a43; +00190 <a class="code" href="matrix_8cpp.html#a24">a44</a>= m.a44; +00191 } +00192 <font class="comment">// Must always copy Trans part.</font> +00193 memcpy(&<a class="code" href="matrix_8cpp.html#a21">a14</a>, &m.a14, 3*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00194 } +00195 <font class="keywordflow">return</font> *<font class="keyword">this</font>; +00196 } +00197 +00198 +00199 <font class="comment">// ======================================================================================================</font> +<a name="l00200"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">00200</a> <font class="keywordtype">void</font> CMatrix::identity() +00201 { +00202 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>= <a class="code" href="matrix_8cpp.html#a8">MAT_IDENTITY</a>; +00203 <font class="comment">// Reset just Pos because must always be valid for faster getPos()</font> +00204 <a class="code" href="matrix_8cpp.html#a21">a14</a>= <a class="code" href="matrix_8cpp.html#a22">a24</a>= <a class="code" href="matrix_8cpp.html#a23">a34</a>= 0; +00205 <font class="comment">// For optimisation it would be usefull to keep MAT_VALID states.</font> +00206 <font class="comment">// But this slows identity(), and this may not be interesting...</font> +00207 } +00208 <font class="comment">// ======================================================================================================</font> +<a name="l00209"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">00209</a> <font class="keywordtype">void</font> CMatrix::setRot(<font class="keyword">const</font> CVector &i, <font class="keyword">const</font> CVector &j, <font class="keyword">const</font> CVector &k, <font class="keywordtype">bool</font> hintNoScale) +00210 { +00211 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>; +00212 <font class="keywordflow">if</font>(hintNoScale) +00213 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>); +00214 <a class="code" href="matrix_8cpp.html#a9">a11</a>= i.x; <a class="code" href="matrix_8cpp.html#a13">a12</a>= j.x; <a class="code" href="matrix_8cpp.html#a17">a13</a>= k.x; +00215 <a class="code" href="matrix_8cpp.html#a10">a21</a>= i.y; <a class="code" href="matrix_8cpp.html#a14">a22</a>= j.y; <a class="code" href="matrix_8cpp.html#a18">a23</a>= k.y; +00216 <a class="code" href="matrix_8cpp.html#a11">a31</a>= i.z; <a class="code" href="matrix_8cpp.html#a15">a32</a>= j.z; <a class="code" href="matrix_8cpp.html#a19">a33</a>= k.z; +00217 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= 1.0f; +00218 } +00219 <font class="comment">// ======================================================================================================</font> +<a name="l00220"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_2">00220</a> <font class="keywordtype">void</font> CMatrix::setRot(<font class="keyword">const</font> <font class="keywordtype">float</font> m33[9], <font class="keywordtype">bool</font> hintNoScale) +00221 { +00222 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>; +00223 <font class="keywordflow">if</font>(hintNoScale) +00224 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>); +00225 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m33[0]; <a class="code" href="matrix_8cpp.html#a13">a12</a>= m33[3]; <a class="code" href="matrix_8cpp.html#a17">a13</a>= m33[6]; +00226 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m33[1]; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m33[4]; <a class="code" href="matrix_8cpp.html#a18">a23</a>= m33[7]; +00227 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m33[2]; <a class="code" href="matrix_8cpp.html#a15">a32</a>= m33[5]; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m33[8]; +00228 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= 1.0f; +00229 } +00230 <font class="comment">// ======================================================================================================</font> +<a name="l00231"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_3">00231</a> <font class="keywordtype">void</font> CMatrix::setRot(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, TRotOrder ro) +00232 { +00233 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> rot; +00234 rot.identity(); +00235 rot.rotate(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, ro); +00236 <font class="keywordtype">float</font> m33[9]; +00237 rot.getRot(m33); +00238 <a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">setRot</a>(m33, <font class="keyword">true</font>); +00239 } +00240 +00241 +00242 <font class="comment">// ======================================================================================================</font> +<a name="l00243"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_5">00243</a> <font class="keywordtype">void</font> CMatrix::setRot(<font class="keyword">const</font> CMatrix &<a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>) +00244 { +00245 <font class="comment">// copy rotpart statebit from other.</font> +00246 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>); +00247 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.StateBit & (<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>); +00248 <font class="comment">// copy values.</font> +00249 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00250 { +00251 <a class="code" href="matrix_8cpp.html#a9">a11</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a12; <a class="code" href="matrix_8cpp.html#a17">a13</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a13; +00252 <a class="code" href="matrix_8cpp.html#a10">a21</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a21; <a class="code" href="matrix_8cpp.html#a14">a22</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a23; +00253 <a class="code" href="matrix_8cpp.html#a11">a31</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a31; <a class="code" href="matrix_8cpp.html#a15">a32</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a32; <a class="code" href="matrix_8cpp.html#a19">a33</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.a33; +00254 <font class="comment">// if has scale, copy from matrix.</font> +00255 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>) +00256 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a370">matrix</a>.Scale33; +00257 } +00258 <font class="keywordflow">else</font> +00259 { +00260 <font class="comment">// we are rot identity, with undefined values.</font> +00261 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a5">MAT_VALIDROT</a>; +00262 } +00263 } +00264 +00265 +00266 <font class="comment">// ======================================================================================================</font> +<a name="l00267"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_6">00267</a> <font class="keywordtype">void</font> CMatrix::setPos(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +00268 { +00269 <a class="code" href="matrix_8cpp.html#a21">a14</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00270 <a class="code" href="matrix_8cpp.html#a22">a24</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00271 <a class="code" href="matrix_8cpp.html#a23">a34</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00272 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a21">a14</a>!=0 || <a class="code" href="matrix_8cpp.html#a22">a24</a>!=0 || <a class="code" href="matrix_8cpp.html#a23">a34</a>!=0) +00273 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00274 <font class="keywordflow">else</font> +00275 <font class="comment">// The trans is identity</font> +00276 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00277 } +00278 <font class="comment">// ======================================================================================================</font> +<a name="l00279"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_7">00279</a> <font class="keywordtype">void</font> CMatrix::movePos(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +00280 { +00281 <a class="code" href="matrix_8cpp.html#a21">a14</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00282 <a class="code" href="matrix_8cpp.html#a22">a24</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00283 <a class="code" href="matrix_8cpp.html#a23">a34</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00284 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a21">a14</a>!=0 || <a class="code" href="matrix_8cpp.html#a22">a24</a>!=0 || <a class="code" href="matrix_8cpp.html#a23">a34</a>!=0) +00285 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00286 <font class="keywordflow">else</font> +00287 <font class="comment">// The trans is identity</font> +00288 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00289 } +00290 <font class="comment">// ======================================================================================================</font> +<a name="l00291"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_8">00291</a> <font class="keywordtype">void</font> CMatrix::setProj(<font class="keyword">const</font> <font class="keywordtype">float</font> proj[4]) +00292 { +00293 <a class="code" href="matrix_8cpp.html#a12">a41</a>= proj[0]; +00294 <a class="code" href="matrix_8cpp.html#a16">a42</a>= proj[1]; +00295 <a class="code" href="matrix_8cpp.html#a20">a43</a>= proj[2]; +00296 <a class="code" href="matrix_8cpp.html#a24">a44</a>= proj[3]; +00297 +00298 <font class="comment">// Check Proj state.</font> +00299 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a12">a41</a>!=0 || <a class="code" href="matrix_8cpp.html#a16">a42</a>!=0 || <a class="code" href="matrix_8cpp.html#a20">a43</a>!=0 || <a class="code" href="matrix_8cpp.html#a24">a44</a>!=1) +00300 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +00301 <font class="keywordflow">else</font> +00302 { +00303 <font class="comment">// The proj is identity, and is correcly setup!</font> +00304 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +00305 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>; +00306 } +00307 } +00308 <font class="comment">// ======================================================================================================</font> +<a name="l00309"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_9">00309</a> <font class="keywordtype">void</font> CMatrix::resetProj() +00310 { +00311 <a class="code" href="matrix_8cpp.html#a12">a41</a>= 0; +00312 <a class="code" href="matrix_8cpp.html#a16">a42</a>= 0; +00313 <a class="code" href="matrix_8cpp.html#a20">a43</a>= 0; +00314 <a class="code" href="matrix_8cpp.html#a24">a44</a>= 1; +00315 <font class="comment">// The proj is identity, and is correcly setup!</font> +00316 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +00317 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>; +00318 } +00319 <font class="comment">// ======================================================================================================</font> +<a name="l00320"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_10">00320</a> <font class="keywordtype">void</font> CMatrix::set(<font class="keyword">const</font> <font class="keywordtype">float</font> m44[16]) +00321 { +00322 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>= <a class="code" href="matrix_8cpp.html#a8">MAT_IDENTITY</a>; +00323 +00324 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>; +00325 memcpy(<a class="code" href="classNLMISC_1_1CMatrix.html#o0">M</a>, m44, 16*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00326 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= 1.0f; +00327 +00328 <font class="comment">// Check Trans state.</font> +00329 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a21">a14</a>!=0 || <a class="code" href="matrix_8cpp.html#a22">a24</a>!=0 || <a class="code" href="matrix_8cpp.html#a23">a34</a>!=0) +00330 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00331 <font class="keywordflow">else</font> +00332 <font class="comment">// The trans is identity</font> +00333 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00334 +00335 <font class="comment">// Check Proj state.</font> +00336 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a12">a41</a>!=0 || <a class="code" href="matrix_8cpp.html#a16">a42</a>!=0 || <a class="code" href="matrix_8cpp.html#a20">a43</a>!=0 || <a class="code" href="matrix_8cpp.html#a24">a44</a>!=1) +00337 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +00338 <font class="keywordflow">else</font> +00339 { +00340 <font class="comment">// The proj is identity, and is correcly setup!</font> +00341 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +00342 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>; +00343 } +00344 } +00345 +00346 +00347 <font class="comment">// ======================================================================================================</font> +00348 <font class="comment">// ======================================================================================================</font> +00349 <font class="comment">// ======================================================================================================</font> +00350 +00351 +00352 <font class="comment">// ======================================================================================================</font> +<a name="l00353"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_0">00353</a> <font class="keywordtype">void</font> CMatrix::getRot(CVector &i, CVector &j, CVector &k)<font class="keyword"> const</font> +00354 <font class="keyword"></font>{ +00355 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00356 { +00357 i.set(<a class="code" href="matrix_8cpp.html#a9">a11</a>, <a class="code" href="matrix_8cpp.html#a10">a21</a>, <a class="code" href="matrix_8cpp.html#a11">a31</a>); +00358 j.set(<a class="code" href="matrix_8cpp.html#a13">a12</a>, <a class="code" href="matrix_8cpp.html#a14">a22</a>, <a class="code" href="matrix_8cpp.html#a15">a32</a>); +00359 k.set(<a class="code" href="matrix_8cpp.html#a17">a13</a>, <a class="code" href="matrix_8cpp.html#a18">a23</a>, <a class="code" href="matrix_8cpp.html#a19">a33</a>); +00360 } +00361 <font class="keywordflow">else</font> +00362 { +00363 i.set(1, 0, 0); +00364 j.set(0, 1, 0); +00365 k.set(0, 0, 1); +00366 } +00367 } +00368 <font class="comment">// ======================================================================================================</font> +<a name="l00369"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_1">00369</a> <font class="keywordtype">void</font> CMatrix::getRot(<font class="keywordtype">float</font> m33[9])<font class="keyword"> const</font> +00370 <font class="keyword"></font>{ +00371 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00372 { +00373 m33[0]= <a class="code" href="matrix_8cpp.html#a9">a11</a>; +00374 m33[1]= <a class="code" href="matrix_8cpp.html#a10">a21</a>; +00375 m33[2]= <a class="code" href="matrix_8cpp.html#a11">a31</a>; +00376 +00377 m33[3]= <a class="code" href="matrix_8cpp.html#a13">a12</a>; +00378 m33[4]= <a class="code" href="matrix_8cpp.html#a14">a22</a>; +00379 m33[5]= <a class="code" href="matrix_8cpp.html#a15">a32</a>; +00380 +00381 m33[6]= <a class="code" href="matrix_8cpp.html#a17">a13</a>; +00382 m33[7]= <a class="code" href="matrix_8cpp.html#a18">a23</a>; +00383 m33[8]= <a class="code" href="matrix_8cpp.html#a19">a33</a>; +00384 } +00385 <font class="keywordflow">else</font> +00386 { +00387 m33[0]= 1; +00388 m33[1]= 0; +00389 m33[2]= 0; +00390 +00391 m33[3]= 0; +00392 m33[4]= 1; +00393 m33[5]= 0; +00394 +00395 m33[6]= 0; +00396 m33[7]= 0; +00397 m33[8]= 1; +00398 } +00399 } +00400 <font class="comment">// ======================================================================================================</font> +<a name="l00401"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_6">00401</a> <font class="keywordtype">void</font> CMatrix::getProj(<font class="keywordtype">float</font> proj[4])<font class="keyword"> const</font> +00402 <font class="keyword"></font>{ +00403 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()) +00404 { +00405 proj[0]= <a class="code" href="matrix_8cpp.html#a12">a41</a>; +00406 proj[1]= <a class="code" href="matrix_8cpp.html#a16">a42</a>; +00407 proj[2]= <a class="code" href="matrix_8cpp.html#a20">a43</a>; +00408 proj[3]= <a class="code" href="matrix_8cpp.html#a24">a44</a>; +00409 } +00410 <font class="keywordflow">else</font> +00411 { +00412 proj[0]= 0; +00413 proj[1]= 0; +00414 proj[2]= 0; +00415 proj[3]= 1; +00416 } +00417 } +00418 <font class="comment">// ======================================================================================================</font> +<a name="l00419"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">00419</a> CVector CMatrix::getI()<font class="keyword"> const</font> +00420 <font class="keyword"></font>{ +00421 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00422 <font class="keywordflow">return</font> CVector(<a class="code" href="matrix_8cpp.html#a9">a11</a>, <a class="code" href="matrix_8cpp.html#a10">a21</a>, <a class="code" href="matrix_8cpp.html#a11">a31</a>); +00423 <font class="keywordflow">else</font> +00424 <font class="keywordflow">return</font> CVector(1, 0, 0); +00425 } +00426 <font class="comment">// ======================================================================================================</font> +<a name="l00427"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">00427</a> CVector CMatrix::getJ()<font class="keyword"> const</font> +00428 <font class="keyword"></font>{ +00429 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00430 <font class="keywordflow">return</font> CVector(<a class="code" href="matrix_8cpp.html#a13">a12</a>, <a class="code" href="matrix_8cpp.html#a14">a22</a>, <a class="code" href="matrix_8cpp.html#a15">a32</a>); +00431 <font class="keywordflow">else</font> +00432 <font class="keywordflow">return</font> CVector(0, 1, 0); +00433 } +00434 <font class="comment">// ======================================================================================================</font> +<a name="l00435"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">00435</a> CVector CMatrix::getK()<font class="keyword"> const</font> +00436 <font class="keyword"></font>{ +00437 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +00438 <font class="keywordflow">return</font> CVector(<a class="code" href="matrix_8cpp.html#a17">a13</a>, <a class="code" href="matrix_8cpp.html#a18">a23</a>, <a class="code" href="matrix_8cpp.html#a19">a33</a>); +00439 <font class="keywordflow">else</font> +00440 <font class="keywordflow">return</font> CVector(0, 0, 1); +00441 } +00442 <font class="comment">// ======================================================================================================</font> +<a name="l00443"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_10">00443</a> <font class="keywordtype">void</font> CMatrix::get(<font class="keywordtype">float</font> m44[16])<font class="keyword"> const</font> +00444 <font class="keyword"></font>{ +00445 <font class="comment">// \todo yoyo: TODO_OPTIMIZE_it.</font> +00446 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00447 <a class="code" href="classNLMISC_1_1CMatrix.html#c11">testExpandProj</a>(); +00448 memcpy(m44, <a class="code" href="classNLMISC_1_1CMatrix.html#o0">M</a>, 16*<font class="keyword">sizeof</font>(<font class="keywordtype">float</font>)); +00449 } +00450 <font class="comment">// ======================================================================================================</font> +<a name="l00451"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_11">00451</a> <font class="keyword">const</font> <font class="keywordtype">float</font> *CMatrix::get()<font class="keyword"> const</font> +00452 <font class="keyword"></font>{ +00453 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00454 <a class="code" href="classNLMISC_1_1CMatrix.html#c11">testExpandProj</a>(); +00455 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMatrix.html#o0">M</a>; +00456 } +00457 <font class="comment">/*// ======================================================================================================</font> +00458 <font class="comment">CVector CMatrix::toEuler(TRotOrder ro) const</font> +00459 <font class="comment">{</font> +00460 <font class="comment"></font> +00461 <font class="comment">}*/</font> +00462 +00463 +00464 <font class="comment">// ======================================================================================================</font> +00465 <font class="comment">// ======================================================================================================</font> +00466 <font class="comment">// ======================================================================================================</font> +00467 +00468 +00469 <font class="comment">// ======================================================================================================</font> +<a name="l00470"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_0">00470</a> <font class="keywordtype">void</font> CMatrix::translate(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +00471 { +00472 <font class="comment">// SetTrans.</font> +00473 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +00474 { +00475 <a class="code" href="matrix_8cpp.html#a21">a14</a>+= <a class="code" href="matrix_8cpp.html#a9">a11</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a13">a12</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a17">a13</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00476 <a class="code" href="matrix_8cpp.html#a22">a24</a>+= <a class="code" href="matrix_8cpp.html#a10">a21</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a14">a22</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a18">a23</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00477 <a class="code" href="matrix_8cpp.html#a23">a34</a>+= <a class="code" href="matrix_8cpp.html#a11">a31</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a15">a32</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a19">a33</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00478 } +00479 <font class="keywordflow">else</font> +00480 { +00481 <a class="code" href="matrix_8cpp.html#a21">a14</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00482 <a class="code" href="matrix_8cpp.html#a22">a24</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00483 <a class="code" href="matrix_8cpp.html#a23">a34</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00484 } +00485 +00486 <font class="comment">// SetProj.</font> +00487 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00488 <a class="code" href="matrix_8cpp.html#a24">a44</a>+= <a class="code" href="matrix_8cpp.html#a12">a41</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a16">a42</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a20">a43</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00489 +00490 <font class="comment">// Check Trans.</font> +00491 <font class="keywordflow">if</font>(<a class="code" href="matrix_8cpp.html#a21">a14</a>!=0 || <a class="code" href="matrix_8cpp.html#a22">a24</a>!=0 || <a class="code" href="matrix_8cpp.html#a23">a34</a>!=0) +00492 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00493 <font class="keywordflow">else</font> +00494 <font class="comment">// The trans is identity, and is correcly setup!</font> +00495 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +00496 } +00497 <font class="comment">// ======================================================================================================</font> +<a name="l00498"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_1">00498</a> <font class="keywordtype">void</font> CMatrix::rotateX(<font class="keywordtype">float</font> a) +00499 { +00500 +00501 <font class="keywordflow">if</font>(a==0) +00502 <font class="keywordflow">return</font>; +00503 <font class="keywordtype">double</font> ca,sa; +00504 ca=cos(a); +00505 sa=sin(a); +00506 +00507 <font class="comment">// SetRot.</font> +00508 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +00509 { +00510 <font class="keywordtype">float</font> b12=<a class="code" href="matrix_8cpp.html#a13">a12</a>, b22=<a class="code" href="matrix_8cpp.html#a14">a22</a>, b32=<a class="code" href="matrix_8cpp.html#a15">a32</a>; +00511 <font class="keywordtype">float</font> b13=<a class="code" href="matrix_8cpp.html#a17">a13</a>, b23=<a class="code" href="matrix_8cpp.html#a18">a23</a>, b33=<a class="code" href="matrix_8cpp.html#a19">a33</a>; +00512 <a class="code" href="matrix_8cpp.html#a13">a12</a>= (float)(b12*ca + b13*sa); +00513 <a class="code" href="matrix_8cpp.html#a14">a22</a>= (float)(b22*ca + b23*sa); +00514 <a class="code" href="matrix_8cpp.html#a15">a32</a>= (float)(b32*ca + b33*sa); +00515 <a class="code" href="matrix_8cpp.html#a17">a13</a>= (float)(b13*ca - b12*sa); +00516 <a class="code" href="matrix_8cpp.html#a18">a23</a>= (float)(b23*ca - b22*sa); +00517 <a class="code" href="matrix_8cpp.html#a19">a33</a>= (float)(b33*ca - b32*sa); +00518 } +00519 <font class="keywordflow">else</font> +00520 { +00521 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00522 <a class="code" href="matrix_8cpp.html#a13">a12</a>= 0.0f; <a class="code" href="matrix_8cpp.html#a14">a22</a>= (float)ca; <a class="code" href="matrix_8cpp.html#a15">a32</a>= (float)sa; +00523 <a class="code" href="matrix_8cpp.html#a17">a13</a>= 0.0f; <a class="code" href="matrix_8cpp.html#a18">a23</a>= (float)-sa; <a class="code" href="matrix_8cpp.html#a19">a33</a>= (float)ca; +00524 } +00525 +00526 <font class="comment">// SetProj.</font> +00527 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00528 { +00529 <font class="keywordtype">float</font> b42=<a class="code" href="matrix_8cpp.html#a16">a42</a>, b43=<a class="code" href="matrix_8cpp.html#a20">a43</a>; +00530 <a class="code" href="matrix_8cpp.html#a16">a42</a>= (float)(b42*ca + b43*sa); +00531 <a class="code" href="matrix_8cpp.html#a20">a43</a>= (float)(b43*ca - b42*sa); +00532 } +00533 +00534 <font class="comment">// set Rot.</font> +00535 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>; +00536 } +00537 <font class="comment">// ======================================================================================================</font> +<a name="l00538"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_2">00538</a> <font class="keywordtype">void</font> CMatrix::rotateY(<font class="keywordtype">float</font> a) +00539 { +00540 +00541 <font class="keywordflow">if</font>(a==0) +00542 <font class="keywordflow">return</font>; +00543 <font class="keywordtype">double</font> ca,sa; +00544 ca=cos(a); +00545 sa=sin(a); +00546 +00547 <font class="comment">// SetRot.</font> +00548 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +00549 { +00550 <font class="keywordtype">float</font> b11=<a class="code" href="matrix_8cpp.html#a9">a11</a>, b21=<a class="code" href="matrix_8cpp.html#a10">a21</a>, b31=<a class="code" href="matrix_8cpp.html#a11">a31</a>; +00551 <font class="keywordtype">float</font> b13=<a class="code" href="matrix_8cpp.html#a17">a13</a>, b23=<a class="code" href="matrix_8cpp.html#a18">a23</a>, b33=<a class="code" href="matrix_8cpp.html#a19">a33</a>; +00552 <a class="code" href="matrix_8cpp.html#a9">a11</a>= (float)(b11*ca - b13*sa); +00553 <a class="code" href="matrix_8cpp.html#a10">a21</a>= (float)(b21*ca - b23*sa); +00554 <a class="code" href="matrix_8cpp.html#a11">a31</a>= (float)(b31*ca - b33*sa); +00555 <a class="code" href="matrix_8cpp.html#a17">a13</a>= (float)(b13*ca + b11*sa); +00556 <a class="code" href="matrix_8cpp.html#a18">a23</a>= (float)(b23*ca + b21*sa); +00557 <a class="code" href="matrix_8cpp.html#a19">a33</a>= (float)(b33*ca + b31*sa); +00558 } +00559 <font class="keywordflow">else</font> +00560 { +00561 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00562 <a class="code" href="matrix_8cpp.html#a9">a11</a>= (float)ca; <a class="code" href="matrix_8cpp.html#a10">a21</a>=0.0f; <a class="code" href="matrix_8cpp.html#a11">a31</a>= (float)-sa; +00563 <a class="code" href="matrix_8cpp.html#a17">a13</a>= (float)sa; <a class="code" href="matrix_8cpp.html#a18">a23</a>=0.0f; <a class="code" href="matrix_8cpp.html#a19">a33</a>= (float)ca; +00564 } +00565 +00566 <font class="comment">// SetProj.</font> +00567 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00568 { +00569 <font class="keywordtype">float</font> b41=<a class="code" href="matrix_8cpp.html#a12">a41</a>, b43=<a class="code" href="matrix_8cpp.html#a20">a43</a>; +00570 <a class="code" href="matrix_8cpp.html#a12">a41</a>= (float)(b41*ca - b43*sa); +00571 <a class="code" href="matrix_8cpp.html#a20">a43</a>= (float)(b43*ca + b41*sa); +00572 } +00573 +00574 <font class="comment">// set Rot.</font> +00575 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>; +00576 } +00577 <font class="comment">// ======================================================================================================</font> +<a name="l00578"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_3">00578</a> <font class="keywordtype">void</font> CMatrix::rotateZ(<font class="keywordtype">float</font> a) +00579 { +00580 +00581 <font class="keywordflow">if</font>(a==0) +00582 <font class="keywordflow">return</font>; +00583 <font class="keywordtype">double</font> ca,sa; +00584 ca=cos(a); +00585 sa=sin(a); +00586 +00587 <font class="comment">// SetRot.</font> +00588 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & (<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) ) +00589 { +00590 <font class="keywordtype">float</font> b11=<a class="code" href="matrix_8cpp.html#a9">a11</a>, b21=<a class="code" href="matrix_8cpp.html#a10">a21</a>, b31=<a class="code" href="matrix_8cpp.html#a11">a31</a>; +00591 <font class="keywordtype">float</font> b12=<a class="code" href="matrix_8cpp.html#a13">a12</a>, b22=<a class="code" href="matrix_8cpp.html#a14">a22</a>, b32=<a class="code" href="matrix_8cpp.html#a15">a32</a>; +00592 <a class="code" href="matrix_8cpp.html#a9">a11</a>= (float)(b11*ca + b12*sa); +00593 <a class="code" href="matrix_8cpp.html#a10">a21</a>= (float)(b21*ca + b22*sa); +00594 <a class="code" href="matrix_8cpp.html#a11">a31</a>= (float)(b31*ca + b32*sa); +00595 <a class="code" href="matrix_8cpp.html#a13">a12</a>= (float)(b12*ca - b11*sa); +00596 <a class="code" href="matrix_8cpp.html#a14">a22</a>= (float)(b22*ca - b21*sa); +00597 <a class="code" href="matrix_8cpp.html#a15">a32</a>= (float)(b32*ca - b31*sa); +00598 } +00599 <font class="keywordflow">else</font> +00600 { +00601 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00602 <a class="code" href="matrix_8cpp.html#a9">a11</a>= (float)ca; <a class="code" href="matrix_8cpp.html#a10">a21</a>= (float)sa; <a class="code" href="matrix_8cpp.html#a11">a31</a>=0.0f; +00603 <a class="code" href="matrix_8cpp.html#a13">a12</a>= (float)-sa; <a class="code" href="matrix_8cpp.html#a14">a22</a>= (float)ca; <a class="code" href="matrix_8cpp.html#a15">a32</a>=0.0f; +00604 } +00605 +00606 <font class="comment">// SetProj.</font> +00607 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00608 { +00609 <font class="keywordtype">float</font> b41=<a class="code" href="matrix_8cpp.html#a12">a41</a>, b42=<a class="code" href="matrix_8cpp.html#a16">a42</a>; +00610 <a class="code" href="matrix_8cpp.html#a12">a41</a>= (float)(b41*ca + b42*sa); +00611 <a class="code" href="matrix_8cpp.html#a16">a42</a>= (float)(b42*ca - b41*sa); +00612 } +00613 +00614 <font class="comment">// set Rot.</font> +00615 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>; +00616 } +00617 <font class="comment">// ======================================================================================================</font> +<a name="l00618"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_4">00618</a> <font class="keywordtype">void</font> CMatrix::rotate(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, TRotOrder ro) +00619 { +00620 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> rot; +00621 rot.identity(); +00622 <font class="keywordflow">switch</font>(ro) +00623 { +00624 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s0">XYZ</a>: rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); <font class="keywordflow">break</font>; +00625 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s1">XZY</a>: rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); <font class="keywordflow">break</font>; +00626 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s2">YXZ</a>: rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); <font class="keywordflow">break</font>; +00627 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s3">YZX</a>: rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); <font class="keywordflow">break</font>; +00628 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s4">ZXY</a>: rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); <font class="keywordflow">break</font>; +00629 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s5">ZYX</a>: rot.rotateZ(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z); rot.rotateY(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y); rot.rotateX(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); <font class="keywordflow">break</font>; +00630 } +00631 +00632 (*this)*= rot; +00633 } +00634 +00635 <font class="comment">// ======================================================================================================</font> +<a name="l00636"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_5">00636</a> <font class="keywordtype">void</font> CMatrix::rotate(<font class="keyword">const</font> CQuat &quat) +00637 { +00638 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> rot; +00639 rot.setRot(quat); +00640 (*this)*= rot; +00641 } +00642 +00643 <font class="comment">// ======================================================================================================</font> +<a name="l00644"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_6">00644</a> <font class="keywordtype">void</font> CMatrix::scale(<font class="keywordtype">float</font> f) +00645 { +00646 +00647 <font class="keywordflow">if</font>(f==1.0f) <font class="keywordflow">return</font>; +00648 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) +00649 { +00650 <a class="code" href="classNLMISC_1_1CMatrix.html#z292_6">scale</a>(CVector(f,f,f)); +00651 } +00652 <font class="keywordflow">else</font> +00653 { +00654 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00655 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>; +00656 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>*=f; +00657 <a class="code" href="matrix_8cpp.html#a9">a11</a>*= f; <a class="code" href="matrix_8cpp.html#a13">a12</a>*=f; <a class="code" href="matrix_8cpp.html#a17">a13</a>*=f; +00658 <a class="code" href="matrix_8cpp.html#a10">a21</a>*= f; <a class="code" href="matrix_8cpp.html#a14">a22</a>*=f; <a class="code" href="matrix_8cpp.html#a18">a23</a>*=f; +00659 <a class="code" href="matrix_8cpp.html#a11">a31</a>*= f; <a class="code" href="matrix_8cpp.html#a15">a32</a>*=f; <a class="code" href="matrix_8cpp.html#a19">a33</a>*=f; +00660 +00661 <font class="comment">// SetProj.</font> +00662 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00663 { +00664 <a class="code" href="matrix_8cpp.html#a12">a41</a>*=f; <a class="code" href="matrix_8cpp.html#a16">a42</a>*=f; <a class="code" href="matrix_8cpp.html#a20">a43</a>*=f; +00665 } +00666 } +00667 } +00668 <font class="comment">// ======================================================================================================</font> +<a name="l00669"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z292_7">00669</a> <font class="keywordtype">void</font> CMatrix::scale(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +00670 { +00671 +00672 <font class="keywordflow">if</font>( <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>==CVector(1,1,1) ) <font class="keywordflow">return</font>; +00673 <font class="keywordflow">if</font>( !(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) && <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x==<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y && <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x==<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z) +00674 { +00675 <a class="code" href="classNLMISC_1_1CMatrix.html#z292_6">scale</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x); +00676 } +00677 <font class="keywordflow">else</font> +00678 { +00679 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00680 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|=<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>; +00681 <a class="code" href="matrix_8cpp.html#a9">a11</a>*= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; <a class="code" href="matrix_8cpp.html#a13">a12</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; <a class="code" href="matrix_8cpp.html#a17">a13</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00682 <a class="code" href="matrix_8cpp.html#a10">a21</a>*= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; <a class="code" href="matrix_8cpp.html#a14">a22</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; <a class="code" href="matrix_8cpp.html#a18">a23</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00683 <a class="code" href="matrix_8cpp.html#a11">a31</a>*= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; <a class="code" href="matrix_8cpp.html#a15">a32</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; <a class="code" href="matrix_8cpp.html#a19">a33</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00684 +00685 <font class="comment">// SetProj.</font> +00686 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +00687 { +00688 <a class="code" href="matrix_8cpp.html#a12">a41</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00689 <a class="code" href="matrix_8cpp.html#a16">a42</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00690 <a class="code" href="matrix_8cpp.html#a20">a43</a>*=<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00691 } +00692 } +00693 } +00694 +00695 +00696 <font class="comment">// ======================================================================================================</font> +00697 <font class="comment">// ======================================================================================================</font> +00698 <font class="comment">// ======================================================================================================</font> +00699 +00700 +00701 <font class="comment">// ***************************************************************************</font> +<a name="l00702"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_3">00702</a> <font class="keywordtype">void</font> CMatrix::setMulMatrixNoProj(<font class="keyword">const</font> CMatrix &m1, <font class="keyword">const</font> CMatrix &m2) +00703 { +00704 <font class="comment">// Do *this= m1*m2</font> +00705 <a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>(); +00706 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>= (m1.StateBit | m2.StateBit) & (~MAT_PROJ); +00707 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a7">MAT_VALIDALL</a>; +00708 +00709 +00710 <font class="comment">// Build Rot part.</font> +00711 <font class="comment">//===============</font> +00712 <font class="keywordtype">bool</font> M1Identity= ! m1.hasRot(); +00713 <font class="keywordtype">bool</font> M2Identity= ! m2.hasRot(); +00714 <font class="keywordtype">bool</font> M1ScaleOnly= ! (m1.StateBit & <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>); +00715 <font class="keywordtype">bool</font> M2ScaleOnly= ! (m2.StateBit & <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>); +00716 <font class="keywordtype">bool</font> MGeneralCase= !M1Identity && !M2Identity && !M1ScaleOnly && !M2ScaleOnly; +00717 +00718 +00719 <font class="comment">// Manage the most common general case first (optim the if ): blending of two rotations.</font> +00720 <font class="keywordflow">if</font>( MGeneralCase ) +00721 { +00722 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11 + m1.a12*m2.a21 + m1.a13*m2.a31; +00723 <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a11*m2.a12 + m1.a12*m2.a22 + m1.a13*m2.a32; +00724 <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a11*m2.a13 + m1.a12*m2.a23 + m1.a13*m2.a33; +00725 +00726 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a21*m2.a11 + m1.a22*m2.a21 + m1.a23*m2.a31; +00727 <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a21*m2.a12 + m1.a22*m2.a22 + m1.a23*m2.a32; +00728 <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a21*m2.a13 + m1.a22*m2.a23 + m1.a23*m2.a33; +00729 +00730 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a31*m2.a11 + m1.a32*m2.a21 + m1.a33*m2.a31; +00731 <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a31*m2.a12 + m1.a32*m2.a22 + m1.a33*m2.a32; +00732 <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a31*m2.a13 + m1.a32*m2.a23 + m1.a33*m2.a33; +00733 } +00734 <font class="comment">// If one of the 3x3 matrix is an identity, just do a copy</font> +00735 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1Identity || M2Identity ) +00736 { +00737 <font class="comment">// If both identity, then me too.</font> +00738 <font class="keywordflow">if</font>( M1Identity && M2Identity ) +00739 { +00740 <font class="comment">// just expand me (important because validated below)</font> +00741 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00742 } +00743 <font class="keywordflow">else</font> +00744 { +00745 <font class="comment">// Copy the non identity matrix.</font> +00746 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> *c= M2Identity? &m1 : &m2; +00747 <a class="code" href="matrix_8cpp.html#a9">a11</a>= c->a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= c->a12; <a class="code" href="matrix_8cpp.html#a17">a13</a>= c->a13; +00748 <a class="code" href="matrix_8cpp.html#a10">a21</a>= c->a21; <a class="code" href="matrix_8cpp.html#a14">a22</a>= c->a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= c->a23; +00749 <a class="code" href="matrix_8cpp.html#a11">a31</a>= c->a31; <a class="code" href="matrix_8cpp.html#a15">a32</a>= c->a32; <a class="code" href="matrix_8cpp.html#a19">a33</a>= c->a33; +00750 } +00751 } +00752 <font class="comment">// If two 3x3 matrix are just scaleOnly matrix, do a scaleFact.</font> +00753 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1ScaleOnly && M2ScaleOnly ) +00754 { +00755 <font class="comment">// same process for scaleUni or scaleAny.</font> +00756 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= 0; <a class="code" href="matrix_8cpp.html#a17">a13</a>= 0; +00757 <a class="code" href="matrix_8cpp.html#a10">a21</a>= 0; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= 0; +00758 <a class="code" href="matrix_8cpp.html#a11">a31</a>= 0; <a class="code" href="matrix_8cpp.html#a15">a32</a>= 0; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00759 } +00760 <font class="comment">// If one of the matrix is a scaleOnly matrix, do a scale*Rot.</font> +00761 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1ScaleOnly && !M2ScaleOnly ) +00762 { +00763 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a11*m2.a12; <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a11*m2.a13; +00764 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a22*m2.a21; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a22*m2.a23; +00765 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a33*m2.a31; <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a33*m2.a32; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00766 } +00767 <font class="keywordflow">else</font> +00768 { +00769 <font class="comment">// This must be this case</font> +00770 <a class="code" href="debug_8h.html#a6">nlassert</a>(!M1ScaleOnly && M2ScaleOnly); +00771 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a12*m2.a22; <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a13*m2.a33; +00772 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a21*m2.a11; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a23*m2.a33; +00773 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a31*m2.a11; <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a32*m2.a22; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00774 } +00775 +00776 <font class="comment">// Modify Scale.</font> +00777 <font class="keywordflow">if</font>( (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>) && !(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) ) +00778 { +00779 <font class="comment">// Must have correct Scale33</font> +00780 m1.testExpandRot(); +00781 m2.testExpandRot(); +00782 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= m1.Scale33*m2.Scale33; +00783 } +00784 <font class="keywordflow">else</font> +00785 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>=1; +00786 +00787 <font class="comment">// In every case, I am valid now!</font> +00788 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|=<a class="code" href="matrix_8cpp.html#a5">MAT_VALIDROT</a>; +00789 +00790 +00791 <font class="comment">// Build Trans part.</font> +00792 <font class="comment">//=================</font> +00793 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a> ) +00794 { +00795 <font class="comment">// Compose M2 part. NB: always suppose MAT_TRANS, for optim consideration.</font> +00796 <font class="comment">// NB: the translation part is always valid, even if identity()</font> +00797 <font class="keywordflow">if</font>( M1Identity ) +00798 { +00799 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m2.a14 + m1.a14; +00800 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m2.a24 + m1.a24; +00801 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m2.a34 + m1.a34; +00802 } +00803 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (M1ScaleOnly ) +00804 { +00805 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m1.a11*m2.a14 + m1.a14; +00806 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m1.a22*m2.a24 + m1.a24; +00807 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m1.a33*m2.a34 + m1.a34; +00808 } +00809 <font class="keywordflow">else</font> +00810 { +00811 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m1.a11*m2.a14 + m1.a12*m2.a24 + m1.a13*m2.a34 + m1.a14; +00812 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m1.a21*m2.a14 + m1.a22*m2.a24 + m1.a23*m2.a34 + m1.a24; +00813 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m1.a31*m2.a14 + m1.a32*m2.a24 + m1.a33*m2.a34 + m1.a34; +00814 } +00815 } +00816 +00817 } +00818 +00819 +00820 <font class="comment">// ***************************************************************************</font> +<a name="l00821"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_0">00821</a> <font class="keywordtype">void</font> CMatrix::setMulMatrix(<font class="keyword">const</font> CMatrix &m1, <font class="keyword">const</font> CMatrix &m2) +00822 { +00823 <font class="comment">// Do *this= m1*m2</font> +00824 <a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>(); +00825 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>= m1.StateBit | m2.StateBit; +00826 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a7">MAT_VALIDALL</a>; +00827 +00828 <font class="comment">// Build Rot part.</font> +00829 <font class="comment">//===============</font> +00830 <font class="keywordtype">bool</font> M1Identity= ! m1.hasRot(); +00831 <font class="keywordtype">bool</font> M2Identity= ! m2.hasRot(); +00832 <font class="keywordtype">bool</font> M1ScaleOnly= ! (m1.StateBit & <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>); +00833 <font class="keywordtype">bool</font> M2ScaleOnly= ! (m2.StateBit & <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>); +00834 <font class="keywordtype">bool</font> MGeneralCase= !M1Identity && !M2Identity && !M1ScaleOnly && !M2ScaleOnly; +00835 +00836 +00837 <font class="comment">// Manage the most common general case first (optim the if ): blending of two rotations.</font> +00838 <font class="keywordflow">if</font>( MGeneralCase ) +00839 { +00840 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11 + m1.a12*m2.a21 + m1.a13*m2.a31; +00841 <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a11*m2.a12 + m1.a12*m2.a22 + m1.a13*m2.a32; +00842 <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a11*m2.a13 + m1.a12*m2.a23 + m1.a13*m2.a33; +00843 +00844 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a21*m2.a11 + m1.a22*m2.a21 + m1.a23*m2.a31; +00845 <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a21*m2.a12 + m1.a22*m2.a22 + m1.a23*m2.a32; +00846 <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a21*m2.a13 + m1.a22*m2.a23 + m1.a23*m2.a33; +00847 +00848 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a31*m2.a11 + m1.a32*m2.a21 + m1.a33*m2.a31; +00849 <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a31*m2.a12 + m1.a32*m2.a22 + m1.a33*m2.a32; +00850 <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a31*m2.a13 + m1.a32*m2.a23 + m1.a33*m2.a33; +00851 } +00852 <font class="comment">// If one of the 3x3 matrix is an identity, just do a copy</font> +00853 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1Identity || M2Identity ) +00854 { +00855 <font class="comment">// If both identity, then me too.</font> +00856 <font class="keywordflow">if</font>( M1Identity && M2Identity ) +00857 { +00858 <font class="comment">// just expand me (important because validated below)</font> +00859 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +00860 } +00861 <font class="keywordflow">else</font> +00862 { +00863 <font class="comment">// Copy the non identity matrix.</font> +00864 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> *c= M2Identity? &m1 : &m2; +00865 <a class="code" href="matrix_8cpp.html#a9">a11</a>= c->a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= c->a12; <a class="code" href="matrix_8cpp.html#a17">a13</a>= c->a13; +00866 <a class="code" href="matrix_8cpp.html#a10">a21</a>= c->a21; <a class="code" href="matrix_8cpp.html#a14">a22</a>= c->a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= c->a23; +00867 <a class="code" href="matrix_8cpp.html#a11">a31</a>= c->a31; <a class="code" href="matrix_8cpp.html#a15">a32</a>= c->a32; <a class="code" href="matrix_8cpp.html#a19">a33</a>= c->a33; +00868 } +00869 } +00870 <font class="comment">// If two 3x3 matrix are just scaleOnly matrix, do a scaleFact.</font> +00871 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1ScaleOnly && M2ScaleOnly ) +00872 { +00873 <font class="comment">// same process for scaleUni or scaleAny.</font> +00874 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= 0; <a class="code" href="matrix_8cpp.html#a17">a13</a>= 0; +00875 <a class="code" href="matrix_8cpp.html#a10">a21</a>= 0; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= 0; +00876 <a class="code" href="matrix_8cpp.html#a11">a31</a>= 0; <a class="code" href="matrix_8cpp.html#a15">a32</a>= 0; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00877 } +00878 <font class="comment">// If one of the matrix is a scaleOnly matrix, do a scale*Rot.</font> +00879 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( M1ScaleOnly && !M2ScaleOnly ) +00880 { +00881 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a11*m2.a12; <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a11*m2.a13; +00882 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a22*m2.a21; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a22*m2.a23; +00883 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a33*m2.a31; <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a33*m2.a32; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00884 } +00885 <font class="keywordflow">else</font> +00886 { +00887 <font class="comment">// This must be this case</font> +00888 <a class="code" href="debug_8h.html#a6">nlassert</a>(!M1ScaleOnly && M2ScaleOnly); +00889 <a class="code" href="matrix_8cpp.html#a9">a11</a>= m1.a11*m2.a11; <a class="code" href="matrix_8cpp.html#a13">a12</a>= m1.a12*m2.a22; <a class="code" href="matrix_8cpp.html#a17">a13</a>= m1.a13*m2.a33; +00890 <a class="code" href="matrix_8cpp.html#a10">a21</a>= m1.a21*m2.a11; <a class="code" href="matrix_8cpp.html#a14">a22</a>= m1.a22*m2.a22; <a class="code" href="matrix_8cpp.html#a18">a23</a>= m1.a23*m2.a33; +00891 <a class="code" href="matrix_8cpp.html#a11">a31</a>= m1.a31*m2.a11; <a class="code" href="matrix_8cpp.html#a15">a32</a>= m1.a32*m2.a22; <a class="code" href="matrix_8cpp.html#a19">a33</a>= m1.a33*m2.a33; +00892 } +00893 +00894 <font class="comment">// If M1 has translate and M2 has projective, rotation is modified.</font> +00895 <font class="keywordflow">if</font>( m1.hasTrans() && m2.hasProj()) +00896 { +00897 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>; +00898 +00899 <a class="code" href="matrix_8cpp.html#a9">a11</a>+= m1.a14*m2.a41; +00900 <a class="code" href="matrix_8cpp.html#a13">a12</a>+= m1.a14*m2.a42; +00901 <a class="code" href="matrix_8cpp.html#a17">a13</a>+= m1.a14*m2.a43; +00902 +00903 <a class="code" href="matrix_8cpp.html#a10">a21</a>+= m1.a24*m2.a41; +00904 <a class="code" href="matrix_8cpp.html#a14">a22</a>+= m1.a24*m2.a42; +00905 <a class="code" href="matrix_8cpp.html#a18">a23</a>+= m1.a24*m2.a43; +00906 +00907 <a class="code" href="matrix_8cpp.html#a11">a31</a>+= m1.a34*m2.a41; +00908 <a class="code" href="matrix_8cpp.html#a15">a32</a>+= m1.a34*m2.a42; +00909 <a class="code" href="matrix_8cpp.html#a19">a33</a>+= m1.a34*m2.a43; +00910 } +00911 +00912 <font class="comment">// Modify Scale.</font> +00913 <font class="keywordflow">if</font>( (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>) && !(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) ) +00914 { +00915 <font class="comment">// Must have correct Scale33</font> +00916 m1.testExpandRot(); +00917 m2.testExpandRot(); +00918 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= m1.Scale33*m2.Scale33; +00919 } +00920 <font class="keywordflow">else</font> +00921 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>=1; +00922 +00923 <font class="comment">// In every case, I am valid now!</font> +00924 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|=<a class="code" href="matrix_8cpp.html#a5">MAT_VALIDROT</a>; +00925 +00926 +00927 <font class="comment">// Build Trans part.</font> +00928 <font class="comment">//=================</font> +00929 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a> ) +00930 { +00931 <font class="comment">// Compose M2 part.</font> +00932 <font class="keywordflow">if</font>( M1Identity ) +00933 { +00934 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m2.a14; +00935 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m2.a24; +00936 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m2.a34; +00937 } +00938 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (M1ScaleOnly ) +00939 { +00940 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m1.a11*m2.a14; +00941 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m1.a22*m2.a24; +00942 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m1.a33*m2.a34; +00943 } +00944 <font class="keywordflow">else</font> +00945 { +00946 <a class="code" href="matrix_8cpp.html#a21">a14</a>= m1.a11*m2.a14 + m1.a12*m2.a24 + m1.a13*m2.a34; +00947 <a class="code" href="matrix_8cpp.html#a22">a24</a>= m1.a21*m2.a14 + m1.a22*m2.a24 + m1.a23*m2.a34; +00948 <a class="code" href="matrix_8cpp.html#a23">a34</a>= m1.a31*m2.a14 + m1.a32*m2.a24 + m1.a33*m2.a34; +00949 } +00950 <font class="comment">// Compose M1 part.</font> +00951 <font class="keywordflow">if</font>(m1.StateBit & <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>) +00952 { +00953 <font class="keywordflow">if</font>(m2.StateBit & <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>) +00954 { +00955 <a class="code" href="matrix_8cpp.html#a21">a14</a>+= m1.a14*m2.a44; +00956 <a class="code" href="matrix_8cpp.html#a22">a24</a>+= m1.a24*m2.a44; +00957 <a class="code" href="matrix_8cpp.html#a23">a34</a>+= m1.a34*m2.a44; +00958 } +00959 <font class="keywordflow">else</font> +00960 { +00961 <a class="code" href="matrix_8cpp.html#a21">a14</a>+= m1.a14; +00962 <a class="code" href="matrix_8cpp.html#a22">a24</a>+= m1.a24; +00963 <a class="code" href="matrix_8cpp.html#a23">a34</a>+= m1.a34; +00964 } +00965 } +00966 } +00967 +00968 +00969 <font class="comment">// Build Proj part.</font> +00970 <font class="comment">//=================</font> +00971 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a> ) +00972 { +00973 <font class="comment">// optimise nothing... (projection matrix are rare).</font> +00974 m1.testExpandRot(); +00975 m1.testExpandProj(); +00976 m2.testExpandRot(); +00977 m2.testExpandProj(); +00978 <a class="code" href="matrix_8cpp.html#a12">a41</a>= m1.a41*m2.a11 + m1.a42*m2.a21 + m1.a43*m2.a31 + m1.a44*m2.a41; +00979 <a class="code" href="matrix_8cpp.html#a16">a42</a>= m1.a41*m2.a12 + m1.a42*m2.a22 + m1.a43*m2.a32 + m1.a44*m2.a42; +00980 <a class="code" href="matrix_8cpp.html#a20">a43</a>= m1.a41*m2.a13 + m1.a42*m2.a23 + m1.a43*m2.a33 + m1.a44*m2.a43; +00981 <a class="code" href="matrix_8cpp.html#a24">a44</a>= m1.a41*m2.a14 + m1.a42*m2.a24 + m1.a43*m2.a34 + m1.a44*m2.a44; +00982 <font class="comment">// The proj is valid now</font> +00983 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a6">MAT_VALIDPROJ</a>; +00984 } +00985 <font class="keywordflow">else</font> +00986 { +00987 <font class="comment">// Don't copy proj part, and leave MAT_VALIDPROJ not set</font> +00988 } +00989 } +00990 <font class="comment">// ======================================================================================================</font> +<a name="l00991"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_6">00991</a> <font class="keywordtype">void</font> CMatrix::invert() +00992 { +00993 +00994 *<font class="keyword">this</font>= <a class="code" href="classNLMISC_1_1CMatrix.html#z293_7">inverted</a>(); +00995 } +00996 +00997 +00998 <font class="comment">// ======================================================================================================</font> +<a name="l00999"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_4">00999</a> <font class="keywordtype">void</font> CMatrix::transpose3x3() +01000 { +01001 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>()) +01002 { +01003 <font class="comment">// swap values.</font> +01004 swap(<a class="code" href="matrix_8cpp.html#a13">a12</a>, <a class="code" href="matrix_8cpp.html#a10">a21</a>); +01005 swap(<a class="code" href="matrix_8cpp.html#a17">a13</a>, <a class="code" href="matrix_8cpp.html#a11">a31</a>); +01006 swap(<a class="code" href="matrix_8cpp.html#a15">a32</a>, <a class="code" href="matrix_8cpp.html#a18">a23</a>); +01007 <font class="comment">// Scale mode (none, uni, or any) is conserved. Scale33 too...</font> +01008 } +01009 } +01010 +01011 <font class="comment">// ======================================================================================================</font> +<a name="l01012"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_5">01012</a> <font class="keywordtype">void</font> CMatrix::transpose() +01013 { +01014 <a class="code" href="classNLMISC_1_1CMatrix.html#z293_4">transpose3x3</a>(); +01015 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>() || <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()) +01016 { +01017 <font class="comment">// if necessary, Get valid 0 on proj part.</font> +01018 <a class="code" href="classNLMISC_1_1CMatrix.html#c11">testExpandProj</a>(); +01019 <font class="comment">// swap values</font> +01020 swap(<a class="code" href="matrix_8cpp.html#a12">a41</a>, <a class="code" href="matrix_8cpp.html#a21">a14</a>); +01021 swap(<a class="code" href="matrix_8cpp.html#a16">a42</a>, <a class="code" href="matrix_8cpp.html#a22">a24</a>); +01022 swap(<a class="code" href="matrix_8cpp.html#a20">a43</a>, <a class="code" href="matrix_8cpp.html#a23">a34</a>); +01023 <font class="comment">// swap StateBit flags, if not both were sets...</font> +01024 <font class="keywordflow">if</font>(!<a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>() || !<a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>()) +01025 { +01026 <font class="comment">// swap StateBit flags (swap trans with proj).</font> +01027 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>()) +01028 { +01029 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +01030 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +01031 } +01032 <font class="keywordflow">else</font> +01033 { +01034 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +01035 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +01036 } +01037 } +01038 <font class="comment">// reset validity. NB, maybe not usefull, but simpler, and bugfree.</font> +01039 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(MAT_VALIDPROJ); +01040 } +01041 <font class="comment">// NB: if no Trans or no Proj, do nothing, so don't need to modify VALIDTRANS and VALIDPROJ too.</font> +01042 } +01043 +01044 +01045 <font class="comment">// ======================================================================================================</font> +<a name="l01046"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c0">01046</a> <font class="keywordtype">void</font> CMatrix::fastInvert33(CMatrix &ret)<font class="keyword"> const</font> +01047 <font class="keyword"></font>{ +01048 <font class="comment">// Fast invert of 3x3 rot matrix.</font> +01049 <font class="comment">// Work if no scale and if MAT_SCALEUNI. doesn't work if MAT_SCALEANY.</font> +01050 +01051 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>) +01052 { +01053 <font class="keywordtype">double</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,S; <font class="comment">// important for precision.</font> +01054 <font class="comment">// Must divide the matrix by 1/Scale 2 times, to set unit, and to have a Scale=1/Scale.</font> +01055 S=1.0/<a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>; +01056 ret.Scale33= (float)S; +01057 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=S*S; +01058 <font class="comment">// The matrix is a base, so just transpose it.</font> +01059 ret.a11= (float)(<a class="code" href="matrix_8cpp.html#a9">a11</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a12= (float)(<a class="code" href="matrix_8cpp.html#a10">a21</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a13= (float)(<a class="code" href="matrix_8cpp.html#a11">a31</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01060 ret.a21= (float)(<a class="code" href="matrix_8cpp.html#a13">a12</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a22= (float)(<a class="code" href="matrix_8cpp.html#a14">a22</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a23= (float)(<a class="code" href="matrix_8cpp.html#a15">a32</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01061 ret.a31= (float)(<a class="code" href="matrix_8cpp.html#a17">a13</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a32= (float)(<a class="code" href="matrix_8cpp.html#a18">a23</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a33= (float)(<a class="code" href="matrix_8cpp.html#a19">a33</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01062 } +01063 <font class="keywordflow">else</font> +01064 { +01065 ret.Scale33=1; +01066 <font class="comment">// The matrix is a base, so just transpose it.</font> +01067 ret.a11= <a class="code" href="matrix_8cpp.html#a9">a11</a>; ret.a12= <a class="code" href="matrix_8cpp.html#a10">a21</a>; ret.a13=<a class="code" href="matrix_8cpp.html#a11">a31</a>; +01068 ret.a21= <a class="code" href="matrix_8cpp.html#a13">a12</a>; ret.a22= <a class="code" href="matrix_8cpp.html#a14">a22</a>; ret.a23=<a class="code" href="matrix_8cpp.html#a15">a32</a>; +01069 ret.a31= <a class="code" href="matrix_8cpp.html#a17">a13</a>; ret.a32= <a class="code" href="matrix_8cpp.html#a18">a23</a>; ret.a33=<a class="code" href="matrix_8cpp.html#a19">a33</a>; +01070 } +01071 +01072 <font class="comment">// 15 cycles if no scale.</font> +01073 <font class="comment">// 35 cycles if scale.</font> +01074 } +01075 <font class="comment">// ======================================================================================================</font> +<a name="l01076"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c1">01076</a> <font class="keywordtype">bool</font> CMatrix::slowInvert33(CMatrix &ret)<font class="keyword"> const</font> +01077 <font class="keyword"></font>{ +01078 CVector invi,invj,invk; +01079 CVector i,j,k; +01080 <font class="keywordtype">double</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01081 +01082 i= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>(); +01083 j= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(); +01084 k= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(); +01085 <font class="comment">// Compute cofactors (minors *(-1)^(i+j)).</font> +01086 invi.x= j.y*k.z - k.y*j.z; +01087 invi.y= j.z*k.x - k.z*j.x; +01088 invi.z= j.x*k.y - k.x*j.y; +01089 invj.x= k.y*i.z - i.y*k.z; +01090 invj.y= k.z*i.x - i.z*k.x; +01091 invj.z= k.x*i.y - i.x*k.y; +01092 invk.x= i.y*j.z - j.y*i.z; +01093 invk.y= i.z*j.x - j.z*i.x; +01094 invk.z= i.x*j.y - j.x*i.y; +01095 <font class="comment">// compute determinant.</font> +01096 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>= invi.x*i.x + invj.x*j.x + invk.x*k.x; +01097 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==0) +01098 <font class="keywordflow">return</font> <font class="keyword">false</font>; +01099 <font class="comment">// Transpose the Comatrice, and divide by determinant.</font> +01100 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=1.0/<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01101 ret.a11= (float)(invi.x*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a12= (float)(invi.y*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a13= (float)(invi.z*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01102 ret.a21= (float)(invj.x*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a22= (float)(invj.y*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a23= (float)(invj.z*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01103 ret.a31= (float)(invk.x*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a32= (float)(invk.y*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); ret.a33= (float)(invk.z*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01104 +01105 <font class="keywordflow">return</font> <font class="keyword">true</font>; +01106 <font class="comment">// Roundly 82 cycles. (1Div=10 cycles).</font> +01107 } +01108 <font class="comment">// ======================================================================================================</font> +<a name="l01109"></a><a class="code" href="classNLMISC_1_1CMatrix.html#c2">01109</a> <font class="keywordtype">bool</font> CMatrix::slowInvert44(CMatrix &ret)<font class="keyword"> const</font> +01110 <font class="keyword"></font>{ +01111 sint i,j; +01112 <font class="keywordtype">double</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01113 +01114 <font class="comment">// Compute Cofactors</font> +01115 <font class="comment">//==================</font> +01116 <font class="keywordflow">for</font>(i=0;i<=3;i++) +01117 { +01118 <font class="keywordflow">for</font>(j=0;j<=3;j++) +01119 { +01120 sint l1,l2,l3; +01121 sint c1,c2,c3; +01122 <a class="code" href="classNLMISC_1_1CMatrix.html#c5">getCofactIndex</a>(i,l1,l2,l3); +01123 <a class="code" href="classNLMISC_1_1CMatrix.html#c5">getCofactIndex</a>(j,c1,c2,c3); +01124 +01125 ret.mat(i,j)= 0; +01126 ret.mat(i,j)+= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c1) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c2) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c3); +01127 ret.mat(i,j)+= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c2) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c3) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c1); +01128 ret.mat(i,j)+= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c3) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c1) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c2); +01129 +01130 ret.mat(i,j)-= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c1) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c3) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c2); +01131 ret.mat(i,j)-= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c2) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c1) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c3); +01132 ret.mat(i,j)-= <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l1,c3) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l2,c2) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(l3,c1); +01133 +01134 <font class="keywordflow">if</font>( (i+j)&1 ) +01135 ret.mat(i,j)=-ret.mat(i,j); +01136 } +01137 } +01138 +01139 <font class="comment">// Compute determinant.</font> +01140 <font class="comment">//=====================</font> +01141 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>= ret.mat(0,0) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(0,0) + ret.mat(0,1) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(0,1) + ret.mat(0,2) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(0,2) + ret.mat(0,3) * <a class="code" href="classNLMISC_1_1CMatrix.html#c3">mat</a>(0,3); +01142 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>==0) +01143 <font class="keywordflow">return</font> <font class="keyword">false</font>; +01144 +01145 <font class="comment">// Divide by determinant.</font> +01146 <font class="comment">//=======================</font> +01147 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=1.0/<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01148 <font class="keywordflow">for</font>(i=0;i<=3;i++) +01149 { +01150 <font class="keywordflow">for</font>(j=0;j<=3;j++) +01151 ret.mat(i,j)= (float)(ret.mat(i,j)*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +01152 } +01153 +01154 <font class="comment">// Transpose the comatrice.</font> +01155 <font class="comment">//=========================</font> +01156 <font class="keywordflow">for</font>(i=0;i<=3;i++) +01157 { +01158 <font class="keywordflow">for</font>(j=i+1;j<=3;j++) +01159 { +01160 swap(ret.mat(i,j), ret.mat(j,i)); +01161 } +01162 } +01163 +01164 <font class="keywordflow">return</font> <font class="keyword">true</font>; +01165 } +01166 <font class="comment">// ======================================================================================================</font> +<a name="l01167"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_7">01167</a> CMatrix CMatrix::inverted()<font class="keyword"> const</font> +01168 <font class="keyword"></font>{ +01169 +01170 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> ret; +01171 +01172 <font class="comment">// \todo yoyo: TODO_OPTIMIZE it...</font> +01173 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +01174 <a class="code" href="classNLMISC_1_1CMatrix.html#c11">testExpandProj</a>(); +01175 +01176 <font class="comment">// Do a conventionnal 44 inversion.</font> +01177 <font class="comment">//=================================</font> +01178 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>) +01179 { +01180 <font class="keywordflow">if</font>(!<a class="code" href="classNLMISC_1_1CMatrix.html#c2">slowInvert44</a>(ret)) +01181 { +01182 ret.identity(); +01183 <font class="keywordflow">return</font> ret; +01184 } +01185 +01186 <font class="comment">// Well, don't know what happens to matrix, so set all StateBit :).</font> +01187 ret.StateBit= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>|<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>|<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +01188 +01189 <font class="comment">// Check Trans state.</font> +01190 <font class="keywordflow">if</font>(ret.a14!=0 || ret.a24!=0 || ret.a34!=0) +01191 ret.StateBit|= <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +01192 <font class="keywordflow">else</font> +01193 ret.StateBit&= ~<a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>; +01194 +01195 <font class="comment">// Check Proj state.</font> +01196 <font class="keywordflow">if</font>(ret.a41!=0 || ret.a42!=0 || ret.a43!=0 || ret.a44!=1) +01197 ret.StateBit|= <a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +01198 <font class="keywordflow">else</font> +01199 ret.StateBit&= ~<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>; +01200 } +01201 +01202 <font class="comment">// Do a speed 34 inversion.</font> +01203 <font class="comment">//=========================</font> +01204 <font class="keywordflow">else</font> +01205 { +01206 <font class="comment">// Invert the rotation part.</font> +01207 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) +01208 { +01209 <font class="keywordflow">if</font>(!<a class="code" href="classNLMISC_1_1CMatrix.html#c1">slowInvert33</a>(ret)) +01210 { +01211 ret.identity(); +01212 <font class="keywordflow">return</font> ret; +01213 } +01214 } +01215 <font class="keywordflow">else</font> +01216 <a class="code" href="classNLMISC_1_1CMatrix.html#c0">fastInvert33</a>(ret); +01217 <font class="comment">// Scale33 is updated in fastInvert33().</font> +01218 +01219 <font class="comment">// Invert the translation part.</font> +01220 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a>) +01221 { +01222 <font class="comment">// Invert the translation part.</font> +01223 <font class="comment">// This can only work if 4th line is 0 0 0 1.</font> +01224 <font class="comment">// formula: InvVp= InvVi*(-Vp.x) + InvVj*(-Vp.y) + InvVk*(-Vp.z)</font> +01225 ret.a14= ret.a11*(-<a class="code" href="matrix_8cpp.html#a21">a14</a>) + ret.a12*(-<a class="code" href="matrix_8cpp.html#a22">a24</a>) + ret.a13*(-<a class="code" href="matrix_8cpp.html#a23">a34</a>); +01226 ret.a24= ret.a21*(-<a class="code" href="matrix_8cpp.html#a21">a14</a>) + ret.a22*(-<a class="code" href="matrix_8cpp.html#a22">a24</a>) + ret.a23*(-<a class="code" href="matrix_8cpp.html#a23">a34</a>); +01227 ret.a34= ret.a31*(-<a class="code" href="matrix_8cpp.html#a21">a14</a>) + ret.a32*(-<a class="code" href="matrix_8cpp.html#a22">a24</a>) + ret.a33*(-<a class="code" href="matrix_8cpp.html#a23">a34</a>); +01228 } +01229 <font class="keywordflow">else</font> +01230 { +01231 ret.a14= 0; +01232 ret.a24= 0; +01233 ret.a34= 0; +01234 } +01235 +01236 <font class="comment">// The projection part is unmodified.</font> +01237 ret.a41= 0; ret.a42= 0; ret.a43= 0; ret.a44= 1; +01238 +01239 <font class="comment">// The matrix inverted keep the same state bits.</font> +01240 ret.StateBit= <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>; +01241 } +01242 +01243 +01244 <font class="keywordflow">return</font> ret; +01245 } +01246 <font class="comment">// ======================================================================================================</font> +<a name="l01247"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z293_8">01247</a> <font class="keywordtype">bool</font> CMatrix::normalize(TRotOrder ro) +01248 { +01249 +01250 CVector ti,tj,tk; +01251 ti= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>(); +01252 tj= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(); +01253 tk= <a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(); +01254 +01255 <font class="comment">// \todo yoyo: TODO_OPTIMIZE it...</font> +01256 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +01257 +01258 <font class="comment">// Normalize with help of ro</font> +01259 <font class="keywordflow">switch</font>(ro) +01260 { +01261 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s0">XYZ</a>: +01262 ti.normalize(); +01263 tk= ti^tj; +01264 tk.normalize(); +01265 tj= tk^ti; +01266 <font class="keywordflow">break</font>; +01267 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s1">XZY</a>: +01268 ti.normalize(); +01269 tj= tk^ti; +01270 tj.normalize(); +01271 tk= ti^tj; +01272 <font class="keywordflow">break</font>; +01273 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s2">YXZ</a>: +01274 tj.normalize(); +01275 tk= ti^tj; +01276 tk.normalize(); +01277 ti= tj^tk; +01278 <font class="keywordflow">break</font>; +01279 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s3">YZX</a>: +01280 tj.normalize(); +01281 ti= tj^tk; +01282 ti.normalize(); +01283 tk= ti^tj; +01284 <font class="keywordflow">break</font>; +01285 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s4">ZXY</a>: +01286 tk.normalize(); +01287 tj= tk^ti; +01288 tj.normalize(); +01289 ti= tj^tk; +01290 <font class="keywordflow">break</font>; +01291 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CMatrix.html#s6s5">ZYX</a>: +01292 tk.normalize(); +01293 ti= tj^tk; +01294 ti.normalize(); +01295 tj= tk^ti; +01296 <font class="keywordflow">break</font>; +01297 } +01298 +01299 <font class="comment">// Check, and set result.</font> +01300 <font class="keywordflow">if</font>( ti.isNull() || tj.isNull() || tk.isNull() ) +01301 <font class="keywordflow">return</font> <font class="keyword">false</font>; +01302 <a class="code" href="matrix_8cpp.html#a9">a11</a>= ti.x; <a class="code" href="matrix_8cpp.html#a13">a12</a>= tj.x; <a class="code" href="matrix_8cpp.html#a17">a13</a>= tk.x; +01303 <a class="code" href="matrix_8cpp.html#a10">a21</a>= ti.y; <a class="code" href="matrix_8cpp.html#a14">a22</a>= tj.y; <a class="code" href="matrix_8cpp.html#a18">a23</a>= tk.y; +01304 <a class="code" href="matrix_8cpp.html#a11">a31</a>= ti.z; <a class="code" href="matrix_8cpp.html#a15">a32</a>= tj.z; <a class="code" href="matrix_8cpp.html#a19">a33</a>= tk.z; +01305 <font class="comment">// Scale is reseted.</font> +01306 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>); +01307 <font class="comment">// Rot is setup...</font> +01308 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>; +01309 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>=1; +01310 +01311 <font class="keywordflow">return</font> <font class="keyword">true</font>; +01312 } +01313 +01314 +01315 <font class="comment">// ======================================================================================================</font> +01316 <font class="comment">// ======================================================================================================</font> +01317 <font class="comment">// ======================================================================================================</font> +01318 +01319 +01320 <font class="comment">// ======================================================================================================</font> +<a name="l01321"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z294_0">01321</a> CVector CMatrix::mulVector(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)<font class="keyword"> const</font> +01322 <font class="keyword"></font>{ +01323 +01324 CVector ret; +01325 +01326 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +01327 { +01328 ret.x= <a class="code" href="matrix_8cpp.html#a9">a11</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a13">a12</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a17">a13</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01329 ret.y= <a class="code" href="matrix_8cpp.html#a10">a21</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a14">a22</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a18">a23</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01330 ret.z= <a class="code" href="matrix_8cpp.html#a11">a31</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a15">a32</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a19">a33</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01331 <font class="keywordflow">return</font> ret; +01332 } +01333 <font class="keywordflow">else</font> +01334 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +01335 } +01336 +01337 <font class="comment">// ======================================================================================================</font> +<a name="l01338"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z294_1">01338</a> CVector CMatrix::mulPoint(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)<font class="keyword"> const</font> +01339 <font class="keyword"></font>{ +01340 +01341 CVector ret; +01342 +01343 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +01344 { +01345 ret.x= <a class="code" href="matrix_8cpp.html#a9">a11</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a13">a12</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a17">a13</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01346 ret.y= <a class="code" href="matrix_8cpp.html#a10">a21</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a14">a22</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a18">a23</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01347 ret.z= <a class="code" href="matrix_8cpp.html#a11">a31</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a15">a32</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a19">a33</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +01348 } +01349 <font class="keywordflow">else</font> +01350 { +01351 ret= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +01352 } +01353 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>() ) +01354 { +01355 ret.x+= <a class="code" href="matrix_8cpp.html#a21">a14</a>; +01356 ret.y+= <a class="code" href="matrix_8cpp.html#a22">a24</a>; +01357 ret.z+= <a class="code" href="matrix_8cpp.html#a23">a34</a>; +01358 } +01359 +01360 <font class="keywordflow">return</font> ret; +01361 } +01362 +01363 +01364 <font class="comment">/*</font> +01365 <font class="comment"> * Multiply</font> +01366 <font class="comment"> */</font> +<a name="l01367"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z294_3">01367</a> CVectorH CMatrix::operator*(<font class="keyword">const</font> CVectorH& <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)<font class="keyword"> const</font> +01368 <font class="keyword"></font>{ +01369 +01370 CVectorH ret; +01371 +01372 <font class="comment">// \todo yoyo: TODO_OPTIMIZE it...</font> +01373 <a class="code" href="classNLMISC_1_1CMatrix.html#c10">testExpandRot</a>(); +01374 <a class="code" href="classNLMISC_1_1CMatrix.html#c11">testExpandProj</a>(); +01375 +01376 ret.x= <a class="code" href="matrix_8cpp.html#a9">a11</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a13">a12</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a17">a13</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z + <a class="code" href="matrix_8cpp.html#a21">a14</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.w; +01377 ret.y= <a class="code" href="matrix_8cpp.html#a10">a21</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a14">a22</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a18">a23</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z + <a class="code" href="matrix_8cpp.html#a22">a24</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.w; +01378 ret.z= <a class="code" href="matrix_8cpp.html#a11">a31</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a15">a32</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a19">a33</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z + <a class="code" href="matrix_8cpp.html#a23">a34</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.w; +01379 ret.w= <a class="code" href="matrix_8cpp.html#a12">a41</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + <a class="code" href="matrix_8cpp.html#a16">a42</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + <a class="code" href="matrix_8cpp.html#a20">a43</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z + <a class="code" href="matrix_8cpp.html#a24">a44</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.w; +01380 <font class="keywordflow">return</font> ret; +01381 } +01382 +01383 +01384 <font class="comment">// ======================================================================================================</font> +<a name="l01385"></a><a class="code" href="classNLMISC_1_1CMatrix.html#a301">01385</a> CPlane <a class="code" href="namespaceNLMISC.html#a273">operator*</a>(<font class="keyword">const</font> CPlane &p, <font class="keyword">const</font> CMatrix &m) +01386 { +01387 <font class="comment">// \todo yoyo: TODO_OPTIMIZE it...</font> +01388 m.testExpandRot(); +01389 m.testExpandProj(); +01390 +01391 +01392 CPlane ret; +01393 +01394 <font class="keywordflow">if</font>( m.StateBit & (<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>|<a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>|<a class="code" href="matrix_8cpp.html#a4">MAT_PROJ</a>) ) +01395 { +01396 <font class="comment">// Compose with translation too.</font> +01397 ret.a= p.a*m.a11 + p.b*m.a21 + p.c*m.a31 + p.d*m.a41; +01398 ret.b= p.a*m.a12 + p.b*m.a22 + p.c*m.a32 + p.d*m.a42; +01399 ret.c= p.a*m.a13 + p.b*m.a23 + p.c*m.a33 + p.d*m.a43; +01400 ret.d= p.a*m.a14 + p.b*m.a24 + p.c*m.a34 + p.d*m.a44; +01401 <font class="keywordflow">return</font> ret; +01402 } +01403 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( m.StateBit & <a class="code" href="matrix_8cpp.html#a0">MAT_TRANS</a> ) +01404 { +01405 +01406 <font class="comment">// Compose just with a translation.</font> +01407 ret.a= p.a; +01408 ret.b= p.b; +01409 ret.c= p.c; +01410 ret.d= p.a*m.a14 + p.b*m.a24 + p.c*m.a34 + p.d*m.a44; +01411 <font class="keywordflow">return</font> ret; +01412 } +01413 <font class="keywordflow">else</font> <font class="comment">// Identity!!</font> +01414 <font class="keywordflow">return</font> p; +01415 } +01416 +01417 +01418 <font class="comment">// ======================================================================================================</font> +01419 <font class="comment">// ======================================================================================================</font> +01420 <font class="comment">// ======================================================================================================</font> +01421 +01422 +01423 <font class="comment">// ======================================================================================================</font> +<a name="l01424"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z290_4">01424</a> <font class="keywordtype">void</font> CMatrix::setRot(<font class="keyword">const</font> CQuat &quat) +01425 { +01426 <font class="comment">// A quaternion do not have scale.</font> +01427 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>&= ~(<a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>|<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a>); +01428 <a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>= 1.0f; +01429 <font class="keywordflow">if</font>(quat.isIdentity()) +01430 { +01431 <a class="code" href="matrix_8cpp.html#a9">a11</a>= 1; <a class="code" href="matrix_8cpp.html#a13">a12</a>= 0; <a class="code" href="matrix_8cpp.html#a17">a13</a>= 0; +01432 <a class="code" href="matrix_8cpp.html#a10">a21</a>= 0; <a class="code" href="matrix_8cpp.html#a14">a22</a>= 1; <a class="code" href="matrix_8cpp.html#a18">a23</a>= 0; +01433 <a class="code" href="matrix_8cpp.html#a11">a31</a>= 0; <a class="code" href="matrix_8cpp.html#a15">a32</a>= 0; <a class="code" href="matrix_8cpp.html#a19">a33</a>= 1; +01434 } +01435 <font class="keywordflow">else</font> +01436 { +01437 <a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>|= <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>; +01438 <font class="keywordtype">float</font> wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; +01439 +01440 <font class="comment">// calculate coefficients</font> +01441 x2 = quat.x + quat.x; y2 = quat.y + quat.y; +01442 z2 = quat.z + quat.z; +01443 xx = quat.x * x2; xy = quat.x * y2; xz = quat.x * z2; +01444 yy = quat.y * y2; yz = quat.y * z2; zz = quat.z * z2; +01445 wx = quat.w * x2; wy = quat.w * y2; wz = quat.w * z2; +01446 +01447 <a class="code" href="matrix_8cpp.html#a9">a11</a> = 1.0f - (yy + zz); +01448 <a class="code" href="matrix_8cpp.html#a13">a12</a> = xy - wz; +01449 <a class="code" href="matrix_8cpp.html#a17">a13</a> = xz + wy; +01450 +01451 <a class="code" href="matrix_8cpp.html#a10">a21</a> = xy + wz; +01452 <a class="code" href="matrix_8cpp.html#a14">a22</a> = 1.0f - (xx + zz); +01453 <a class="code" href="matrix_8cpp.html#a18">a23</a> = yz - wx; +01454 +01455 <a class="code" href="matrix_8cpp.html#a11">a31</a> = xz - wy; +01456 <a class="code" href="matrix_8cpp.html#a15">a32</a> = yz + wx; +01457 <a class="code" href="matrix_8cpp.html#a19">a33</a> = 1.0f - (xx + yy); +01458 } +01459 } +01460 +01461 +01462 <font class="comment">// ======================================================================================================</font> +<a name="l01463"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z291_2">01463</a> <font class="keywordtype">void</font> CMatrix::getRot(CQuat &quat)<font class="keyword"> const</font> +01464 <font class="keyword"></font>{ +01465 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> *pmat= <font class="keyword">this</font>; +01466 <a class="code" href="classNLMISC_1_1CMatrix.html#z289_0">CMatrix</a> MatNormed; +01467 +01468 +01469 <font class="comment">// Rot Indentity?</font> +01470 <font class="keywordflow">if</font>(! (<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & <a class="code" href="matrix_8cpp.html#a1">MAT_ROT</a>)) +01471 { +01472 quat= CQuat::Identity; +01473 <font class="keywordflow">return</font>; +01474 } +01475 +01476 <font class="comment">// Must normalize the matrix??</font> +01477 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a> & (<a class="code" href="matrix_8cpp.html#a2">MAT_SCALEUNI</a> | <a class="code" href="matrix_8cpp.html#a3">MAT_SCALEANY</a>) ) +01478 { +01479 MatNormed= *<font class="keyword">this</font>; +01480 MatNormed.normalize(<a class="code" href="classNLMISC_1_1CMatrix.html#s6s5">ZYX</a>); +01481 pmat= &MatNormed; +01482 } +01483 +01484 <font class="comment">// Compute quaternion.</font> +01485 <font class="keywordtype">float</font> tr, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[4]; +01486 +01487 tr = pmat->a11 + pmat->a22 + pmat->a33; +01488 +01489 <font class="comment">// check the diagonal</font> +01490 <font class="keywordflow">if</font> (tr > 0.0) +01491 { +01492 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = (float)sqrt (tr + 1.0f); +01493 quat.w = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> / 2.0f; +01494 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = 0.5f / <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01495 quat.x = (pmat->a32 - pmat->a23) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01496 quat.y = (pmat->a13 - pmat->a31) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01497 quat.z = (pmat->a21 - pmat->a12) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01498 } +01499 <font class="keywordflow">else</font> +01500 { +01501 sint i, j, k; +01502 sint nxt[3] = {1, 2, 0}; +01503 +01504 <font class="comment">// diagonal is negative</font> +01505 i = 0; +01506 <font class="keywordflow">if</font> (pmat->a22 > pmat->a11) i = 1; +01507 <font class="keywordflow">if</font> (pmat->a33 > pmat->mat(i,i) ) i = 2; +01508 j = nxt[i]; +01509 k = nxt[j]; +01510 +01511 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = (float) sqrt ( (pmat->mat(i,i) - (pmat->mat(j,j) + pmat->mat(k,k)) ) + 1.0); +01512 +01513 <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[i] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> * 0.5f; +01514 +01515 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> != 0.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = 0.5f / <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01516 +01517 <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[j] = (pmat->mat(j,i) + pmat->mat(i,j)) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01518 <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[k] = (pmat->mat(k,i) + pmat->mat(i,k)) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01519 <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[3] = (pmat->mat(k,j) - pmat->mat(j,k)) * <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +01520 +01521 quat.x = <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[0]; +01522 quat.y = <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[1]; +01523 quat.z = <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[2]; +01524 quat.w = <a class="code" href="driver__opengl__extension__def_8h.html#a386">q</a>[3]; +01525 } +01526 +01527 } +01528 +01529 +01530 <font class="comment">// ======================================================================================================</font> +01531 <font class="comment">// ======================================================================================================</font> +01532 <font class="comment">// ======================================================================================================</font> +01533 +01534 +01535 <font class="comment">// ======================================================================================================</font> +<a name="l01536"></a><a class="code" href="classNLMISC_1_1CMatrix.html#z295_0">01536</a> <font class="keywordtype">void</font> CMatrix::serial(IStream &f) +01537 { +01538 <font class="comment">// Use versionning, maybe for futur improvement.</font> +01539 (void)f.serialVersion(0); +01540 +01541 <font class="keywordflow">if</font>(f.isReading()) +01542 <a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>(); +01543 f.serial(<a class="code" href="classNLMISC_1_1CMatrix.html#o2">StateBit</a>); +01544 f.serial(<a class="code" href="classNLMISC_1_1CMatrix.html#o1">Scale33</a>); +01545 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c7">hasRot</a>() ) +01546 { +01547 f.serial(<a class="code" href="matrix_8cpp.html#a9">a11</a>, <a class="code" href="matrix_8cpp.html#a13">a12</a>, <a class="code" href="matrix_8cpp.html#a17">a13</a>); +01548 f.serial(<a class="code" href="matrix_8cpp.html#a10">a21</a>, <a class="code" href="matrix_8cpp.html#a14">a22</a>, <a class="code" href="matrix_8cpp.html#a18">a23</a>); +01549 f.serial(<a class="code" href="matrix_8cpp.html#a11">a31</a>, <a class="code" href="matrix_8cpp.html#a15">a32</a>, <a class="code" href="matrix_8cpp.html#a19">a33</a>); +01550 } +01551 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c6">hasTrans</a>() ) +01552 { +01553 f.serial(<a class="code" href="matrix_8cpp.html#a21">a14</a>, <a class="code" href="matrix_8cpp.html#a22">a24</a>, <a class="code" href="matrix_8cpp.html#a23">a34</a>); +01554 } +01555 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(f.isReading()) +01556 { +01557 <font class="comment">// must reset because Pos must always be valid</font> +01558 <a class="code" href="matrix_8cpp.html#a21">a14</a>= <a class="code" href="matrix_8cpp.html#a22">a24</a>= <a class="code" href="matrix_8cpp.html#a23">a34</a>= 0; +01559 } +01560 <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CMatrix.html#c8">hasProj</a>() ) +01561 { +01562 f.serial(<a class="code" href="matrix_8cpp.html#a12">a41</a>, <a class="code" href="matrix_8cpp.html#a16">a42</a>, <a class="code" href="matrix_8cpp.html#a20">a43</a>, <a class="code" href="matrix_8cpp.html#a24">a44</a>); +01563 } +01564 } +01565 +01566 +01567 +01568 +01569 } +01570 +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |