aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/quat_8h-source.html
blob: ed29b5c9c7e5d6420226f4bd41a7792e6faebead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<!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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- 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="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>quat.h</h1><a href="quat_8h.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">#ifndef NL_QUAT_H </font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_QUAT_H </font>
00028 <font class="preprocessor"></font>
00029 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="vector_8h.html">nel/misc/vector.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00032 <font class="preprocessor">#include &lt;math.h&gt;</font>
00033 
00034 <font class="keyword">namespace       </font>NLMISC
00035 {
00036 
00037 
00038 <font class="comment">// ***************************************************************************</font>
00039 <font class="keyword">const</font>   <font class="keywordtype">double</font>  <a class="code" href="namespaceNLMISC.html#a171">QuatEpsilon</a>= 0.000001;
00040 
00041 
00042 
00043 <font class="comment">// ***************************************************************************</font>
<a name="l00050"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html">00050</a> <font class="comment"></font><font class="keyword">struct  </font>CAngleAxis
00051 {
<a name="l00052"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html#m0">00052</a>         CVector         <a class="code" href="structNLMISC_1_1CAngleAxis.html#m0">Axis</a>;           
<a name="l00053"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html#m1">00053</a>         <font class="keywordtype">float</font>           <a class="code" href="structNLMISC_1_1CAngleAxis.html#m1">Angle</a>;          
00054 
<a name="l00055"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html#a0">00055</a>         <a class="code" href="structNLMISC_1_1CAngleAxis.html#a0">CAngleAxis</a>() {}
<a name="l00056"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html#a1">00056</a>         <a class="code" href="structNLMISC_1_1CAngleAxis.html#a0">CAngleAxis</a>(CVector axis, <font class="keywordtype">float</font> ang) : <a class="code" href="structNLMISC_1_1CAngleAxis.html#m0">Axis</a>(axis), <a class="code" href="structNLMISC_1_1CAngleAxis.html#m1">Angle</a>(ang) {}
00057 
<a name="l00059"></a><a class="code" href="structNLMISC_1_1CAngleAxis.html#a2">00059</a>         <font class="keywordtype">void</font>    <a class="code" href="structNLMISC_1_1CAngleAxis.html#a2">serial</a>(IStream &amp;f)
00060         {
00061                 f.serial(<a class="code" href="structNLMISC_1_1CAngleAxis.html#m0">Axis</a>);
00062                 f.serial(<a class="code" href="structNLMISC_1_1CAngleAxis.html#m1">Angle</a>);
00063         }
00064 };
00065 
00066 
00067 <font class="comment">// ***************************************************************************</font>
<a name="l00074"></a><a class="code" href="classNLMISC_1_1CQuatT.html">00074</a> <font class="comment"></font><font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; <font class="keyword">class </font>CQuatT
00075 {
00076 <font class="keyword">public</font>:
<a name="l00077"></a><a class="code" href="classNLMISC_1_1CQuatT.html#m2">00077</a>         T <a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>;
00078 
00079 
00080 <font class="keyword">public</font>:
00081 
00083         <font class="comment">// @{</font>
<a name="l00084"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">00084</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>() : <a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>((T)0.0),<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>((T)0.0),<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>((T)0.0),<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>((T)1.0) {}
<a name="l00085"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z310_1">00085</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(T X, T Y, T Z, T W) : <a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>(X), <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>(Y), <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>(Z), <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>(W) {}
<a name="l00087"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z310_2">00087</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<font class="keyword">const</font> CVector &amp;axis, <font class="keywordtype">float</font> angle) {<a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">setAngleAxis</a>(axis, angle);}
<a name="l00089"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z310_3">00089</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<font class="keyword">const</font> CAngleAxis &amp;aa) {<a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">setAngleAxis</a>(aa);}
00090         <font class="comment">// @}</font>
00091 
00092     
00094         <font class="comment">// @{</font>
<a name="l00095"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z311_0">00095</a>         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z311_0">set</a>(T X, T Y, T Z, T W)         {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>= X; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>= Y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>= Z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>= W;}
00096         <font class="comment">// @}</font>
00097 
00099         <font class="comment">// @{</font>
<a name="l00100"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z312_0">00100</a>         <font class="keywordtype">bool</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z312_0">operator==</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; a)<font class="keyword"> const               </font>{<font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>==0 &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>==0 &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>==0 &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>==1.0f);}
00101         <font class="keywordtype">bool</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z312_1">equal</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; a, <font class="keywordtype">float</font> epsilon = 1E-6f) <font class="keyword">const</font>;
<a name="l00102"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z312_2">00102</a>         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z312_2">identity</a>()                                              {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a> = <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a> = <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a> = 0.0f ;     <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a> = 1.0f; }
<a name="l00103"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z312_3">00103</a>         <font class="keywordtype">bool</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z312_3">isIdentity</a>()<font class="keyword"> const                              </font>{<font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>==0.0f &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>==0.0f &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>==0.0f &amp;&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>==1.0f);}
00104         <font class="comment">// @}</font>
00105 
00107         <font class="comment">// @{</font>
<a name="l00108"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_0">00108</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#z313_0">operator+=</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp;o)              {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>+=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>+=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>+=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>+=o.w; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00109"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_1">00109</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#z313_1">operator-=</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp;o)              {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>-=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>-=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>-=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>-=o.w; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00110"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_2">00110</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#z313_2">operator*=</a>(T f)                                 {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*=f;<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*=f;<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*=f;<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*=f; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00111"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_3">00111</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#z313_3">operator/=</a>(T f)                                 {<font class="keywordtype">double</font> oof= 1.0/f; <a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>=(T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*oof); <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>=(T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*oof); <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>= (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*oof); <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>=(T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*oof); <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00112"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_4">00112</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_9">operator+</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp;o)<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>+o.x,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>+o.y,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>+o.z,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>+o.w);}
<a name="l00113"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_5">00113</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_8">operator-</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp;o)<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>-o.x,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>-o.y,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>-o.z,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>-o.w);}
<a name="l00114"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_6">00114</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_6">operator*</a>(T f)<font class="keyword"> const                    </font>{<font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*f,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*f,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*f,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*f);}
<a name="l00115"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_7">00115</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_7">operator/</a>(T f)<font class="keyword"> const                    </font>{<font class="keywordtype">double</font> oof= 1.0/f; <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*oof,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*oof,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*oof,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*oof);}
<a name="l00116"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_8">00116</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_8">operator-</a>()<font class="keyword"> const                               </font>{<font class="keywordflow">return</font>(<a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(-<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>,-<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>,-<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>,-<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>)); }
<a name="l00117"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_9">00117</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_9">operator+</a>()<font class="keyword"> const                               </font>{<font class="keywordflow">return</font> *<font class="keyword">this</font>; }
<a name="l00119"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_10">00119</a>         T               <a class="code" href="classNLMISC_1_1CQuatT.html#z313_10">sqrnorm</a>()<font class="keyword"> const                                 </font>{<font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>);}
<a name="l00121"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_11">00121</a>         T               <a class="code" href="classNLMISC_1_1CQuatT.html#z313_11">norm</a>()<font class="keyword"> const                                    </font>{<font class="keywordflow">return</font> (T)sqrt(<a class="code" href="classNLMISC_1_1CQuatT.html#z313_10">sqrnorm</a>());}
00123         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z313_12">normalize</a>();
<a name="l00125"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_13">00125</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z313_13">normed</a>()<font class="keyword"> const                                  </font>{<a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a> ret= *<font class="keyword">this</font>; ret.normalize(); <font class="keywordflow">return</font> ret;}
00126         <font class="comment">// @}</font>
00127 
00128 
00130         <font class="comment">// @{</font>
00132 <font class="comment">        CQuatT  operator*(const CQuatT&amp;) const; </font>
00133         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp; <a class="code" href="classNLMISC_1_1CQuatT.html#z313_2">operator*=</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&amp;);
00135         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z314_2">invert</a>();
<a name="l00137"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z314_3">00137</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z314_3">inverted</a>()<font class="keyword"> const                                </font>{<a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a> ret= *<font class="keyword">this</font>; ret.invert(); <font class="keywordflow">return</font> ret;}
<a name="l00139"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z314_4">00139</a>         <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z314_4">conjugate</a>()<font class="keyword"> const                               </font>{<font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>(-<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>, -<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>, -<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>, <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>);}
00140         <font class="comment">// @}</font>
00141 
00142 
00144         <font class="comment">// @{</font>
<a name="l00146"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z315_0">00146</a> <font class="comment">        CVector getAxis() const {CVector ret((float)x,(float)y,(float)z); return ret.normed();}</font>
<a name="l00148"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z315_1">00148</a> <font class="comment">        float   getAngle() const {return (float)(2*acos(w/norm()));}</font>
<a name="l00150"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z315_2">00150</a> <font class="comment">        CAngleAxis      getAngleAxis() const {return CAngleAxis(getAxis(), getAngle());}</font>
00151 
00153         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">setAngleAxis</a>(<font class="keyword">const</font> CVector &amp;axis, <font class="keywordtype">float</font> angle);
<a name="l00155"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z315_4">00155</a>         <font class="keywordtype">void</font>    <a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">setAngleAxis</a>(<font class="keyword">const</font> CAngleAxis &amp;angAxis) {<a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">setAngleAxis</a>(angAxis.Axis, angAxis.Angle);}
00156         <font class="comment">// @}</font>
00157 
00158 
00160         <font class="comment">// @{</font>
00162 <font class="comment">        CQuatT  log();</font>
00164 <font class="comment">        CQuatT  exp();</font>
00166 <font class="comment">        void    makeClosest(const CQuatT &amp;o);</font>
<a name="l00168"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z316_3">00168</a> <font class="comment">        void    serial(IStream &amp;f)</font>
00169         {
00170                 f.serial(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>,<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>);
00171         }
00172         <font class="comment">// @}</font>
00173 
00174 
00175 <font class="keyword">public</font>:
00176 
00178         <font class="comment">// @{</font>
00180 <font class="comment">        static  T               dotProduct(const CQuatT&lt;T&gt; &amp;q0, const CQuatT&lt;T&gt; &amp;q1);</font>
00184 <font class="comment"></font>        <font class="keyword">static</font>  <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z317_1">slerp</a>(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00188         <font class="keyword">static</font>  <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z317_2">squad</a>(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ1, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00191         <font class="keyword">static</font>  <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z317_3">squadrev</a>(<font class="keyword">const</font> CAngleAxis &amp;rot, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ1, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00192 
00194         <font class="keyword">static</font>  <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>  <a class="code" href="classNLMISC_1_1CQuatT.html#z317_4">lnDif</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a> &amp;q0, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a> &amp;q1);
00195 
00196         <font class="comment">// @}</font>
00197 
00198 
00199 };
00200 
00201 
00202 
00203 <font class="comment">// ***************************************************************************</font>
00204 
00205 
00207 <font class="comment">// @{</font>
00208 
00210 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
00211 <font class="keyword">inline</font>  CQuatT&lt;T&gt;       <a class="code" href="namespaceNLMISC.html#a273">operator*</a>(T f, <font class="keyword">const</font> CQuatT&lt;T&gt; &amp;o) {<font class="keywordflow">return</font> o*f;}
00212 
00213 <font class="comment">// @}</font>
00214 
00215 
00216 
00217 <font class="comment">// ***************************************************************************</font>
00218 <font class="comment">// ***************************************************************************</font>
00219 <font class="comment">// Template implementation.</font>
00220 <font class="comment">// ***************************************************************************</font>
00221 <font class="comment">// ***************************************************************************</font>
00222 
00223 
00224 
00225 <font class="comment">// ***************************************************************************</font>
00226 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00227"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z312_1">00227</a> <font class="keyword">inline</font> <font class="keywordtype">bool</font>     CQuatT&lt;T&gt;::equal(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; a, <font class="keywordtype">float</font> epsilon)<font class="keyword"> const</font>
00228 <font class="keyword"></font>{
00229         <font class="keywordflow">if</font> (fabs(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>-a.x)&lt;epsilon &amp;&amp;
00230                 fabs(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>-a.y)&lt;epsilon &amp;&amp;
00231                 fabs(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>-a.z)&lt;epsilon &amp;&amp;
00232                 fabs(<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>-a.w)&lt;epsilon )
00233         {
00234                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00235         }
00236         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00237 }
00238 
00239 
00240 <font class="comment">// ***************************************************************************</font>
00241 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00242"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z314_0">00242</a> <font class="keyword">inline</font> CQuatT&lt;T&gt;        CQuatT&lt;T&gt;::operator*(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; o)<font class="keyword"> const</font>
00243 <font class="keyword"></font>{
00244         <font class="comment">// wres= ww� - v�v�</font>
00245         <font class="comment">// vres= wv� + w�v + v^v� ] </font>
00246         <font class="keywordflow">return</font>  CQuatT&lt;T&gt;(
00247                                         (<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*o.x) +(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*o.w) + (<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*o.z)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*o.y),
00248                                         (<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*o.y) +(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*o.w) + (<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*o.x)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*o.z),
00249                                         (<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*o.z) +(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*o.w) + (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*o.y)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*o.x),
00250                                         (<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>*o.w)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*o.x)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*o.y)-(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*o.z) );
00251 
00252 }
00253 
00254 <font class="comment">// ***************************************************************************</font>
00255 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00256"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z314_1">00256</a> <font class="keyword">inline</font> CQuatT&lt;T&gt;&amp;       CQuatT&lt;T&gt;::operator*=(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; o)
00257 {
00258         *<font class="keyword">this</font>= *<font class="keyword">this</font> * o;
00259         <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00260 }
00261 
00262 
00263 <font class="comment">// ***************************************************************************</font>
00264 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00265"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z314_2">00265</a> <font class="keyword">inline</font> <font class="keywordtype">void</font>     CQuatT&lt;T&gt;::invert()
00266 {
00267         <font class="comment">// Must invert the norm.</font>
00268         T       f= <a class="code" href="classNLMISC_1_1CQuatT.html#z313_10">sqrnorm</a>();
00269         <font class="keywordflow">if</font>(f!=0)
00270         {
00271                 *<font class="keyword">this</font>/=f;
00272         }
00273 
00274         *<font class="keyword">this</font>= <a class="code" href="classNLMISC_1_1CQuatT.html#z314_4">conjugate</a>();
00275 }
00276 
00277 
00278 <font class="comment">// ***************************************************************************</font>
00279 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00280"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z313_12">00280</a> <font class="keyword">inline</font> <font class="keywordtype">void</font>     CQuatT&lt;T&gt;::normalize()
00281 {
00282         T       f= <a class="code" href="classNLMISC_1_1CQuatT.html#z313_11">norm</a>();
00283         <font class="keywordflow">if</font>(f==0)
00284                 <a class="code" href="classNLMISC_1_1CQuatT.html#z312_2">identity</a>();
00285         <font class="keywordflow">else</font>
00286         {
00287                 *<font class="keyword">this</font>/=f;
00288         }
00289 }
00290 
00291 
00292 <font class="comment">// ***************************************************************************</font>
00293 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00294"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z315_3">00294</a> <font class="keyword">inline</font> <font class="keywordtype">void</font>     CQuatT&lt;T&gt;::setAngleAxis(<font class="keyword">const</font> CVector &amp;axis, <font class="keywordtype">float</font> angle)
00295 {
00296         CVector         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= axis;
00297         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.normalize();
00298         <font class="keywordtype">double</font>  ca= cos(angle/2);
00299         <font class="keywordtype">double</font>  sa= sin(angle/2);
00300         <a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>= (T)(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x*sa);
00301         <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>= (T)(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y*sa);
00302         <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>= (T)(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z*sa);
00303         <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>= (T)(ca);
00304 }
00305 
00306 
00307 <font class="comment">// ***************************************************************************</font>
00308 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00309"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z317_0">00309</a> T       CQuatT&lt;T&gt;::dotProduct(<font class="keyword">const</font> CQuatT&lt;T&gt; &amp;q0, <font class="keyword">const</font> CQuatT&lt;T&gt; &amp;q1)
00310 {
00311         <font class="keywordflow">return</font> q0.x*q1.x + q0.y*q1.y + q0.z*q1.z + q0.w*q1.w;
00312 }
00313 
00314 
00315 <font class="comment">// ***************************************************************************</font>
00316 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00317"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z317_1">00317</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::slerp(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)
00318 {
00319         <font class="comment">// omega is the 4D angle between q0 and q1.</font>
00320         <font class="keywordtype">double</font>  omega, cosom,sinom;
00321         T       factq0= 1;
00322         T       s0,s1;
00323 
00324         cosom = CQuatT&lt;T&gt;::dotProduct(q0, q1);
00325 
00326         <font class="comment">// Make q0 and q1 on the same hemisphere.</font>
00327         <font class="comment">/*if(cosom&lt;0)</font>
00328 <font class="comment">        {</font>
00329 <font class="comment">                cosom= -cosom;</font>
00330 <font class="comment">                factq0= -1;</font>
00331 <font class="comment">        }*/</font>
00332         <font class="comment">// ????</font>
00333 
00334         <font class="keywordflow">if</font> ( cosom &lt; 1.0 - NLMISC::QuatEpsilon)
00335         { 
00336                 omega = acos(cosom);
00337                 sinom = sin(omega);
00338                 s0 = (T) (sin((1.0f - <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)*omega) / sinom);
00339                 s1 = (T) (sin(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*omega) / sinom);
00340         }
00341         <font class="keywordflow">else</font>
00342         {       <font class="comment">// q0 and q1 are nearly the same =&gt; sinom nearly 0. We can't slerp.</font>
00343                 <font class="comment">// just linear interpolate.</font>
00344                 s0 = (T)(1.0 - <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00345                 s1 = <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
00346         }
00347 
00348         <font class="keywordflow">return</font>  q0*(factq0*s0) + q1*s1;
00349 
00350 }
00351 
00352 
00353 <font class="comment">// ***************************************************************************</font>
00354 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00355"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z317_2">00355</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::squad(<font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ1, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)
00356 {
00357         <font class="keywordflow">return</font> CQuatT&lt;T&gt;::slerp(
00358                 CQuatT&lt;T&gt;::<a class="code" href="classNLMISC_1_1CQuatT.html#z317_1">slerp</a>(q0, q1, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>),
00359                 CQuatT&lt;T&gt;::<a class="code" href="classNLMISC_1_1CQuatT.html#z317_1">slerp</a>(tgtQ0, tgtQ1, <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>),
00360                 2.f*(1.f-<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)*<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00361 }
00362 
00363 
00364 <font class="comment">// ***************************************************************************</font>
00365 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00366"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z317_3">00366</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::squadrev(<font class="keyword">const</font> CAngleAxis &amp;rot, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ0, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; tgtQ1, <font class="keyword">const</font> CQuatT&lt;T&gt;&amp; q1, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)
00367 {
00368         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00369         <font class="keywordtype">float</font> omega = rot.Angle* 0.5f;
00370         <font class="keywordtype">float</font> nrevs = 0.0f;
00371         CQuatT&lt;T&gt;       ret,qaxis,pp,qq;
00372 
00373         <font class="comment">// just one rev?</font>
00374         <font class="comment">//==============</font>
00375         <font class="keywordflow">if</font> (omega&lt;<a class="code" href="namespaceNLMISC.html#a7">Pi</a>-<a class="code" href="namespaceNLMISC.html#a171">QuatEpsilon</a>)
00376         {
00377                 ret = CQuatT&lt;T&gt;::squad(q0,tgtQ0,tgtQ1,q1,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>);
00378                 <font class="keywordflow">return</font> ret; 
00379         }
00380 
00381 
00382         <font class="comment">// multirev.</font>
00383         <font class="comment">//==============</font>
00384 
00385         <font class="comment">// rotation of 180� around rot.Axis.  (=&gt; sin(a/2)==sin(Pi/2)==1, and c(a/2)=0).</font>
00386         qaxis.set(rot.Axis.x, rot.Axis.y, rot.Axis.z, 0);
00387 
00388         <font class="comment">// the number of revisions (float!)</font>
00389         nrevs= (float)(omega/<a class="code" href="namespaceNLMISC.html#a7">Pi</a>);
00390         <font class="comment">// Angle&gt;2Pi. squad from 0 to Pi, slerp from Pi to Angle-Pi, squad from Angle-Pi to Angle.</font>
00391         <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*2*nrevs;
00392         
00393 
00394         <font class="comment">// So for s, squad from 0 to 1, slerp from 1 to 2*nrevs-1, squad from 2*nrevs-1 to 2*nrevs.</font>
00395         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> &lt; 1.0f)
00396         {
00397                 <font class="comment">// first part.</font>
00398                 pp = q0*qaxis;
00399                 ret = CQuatT&lt;T&gt;::squad(q0,tgtQ0,pp,pp,<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>);
00400         }
00401         <font class="keywordflow">else</font>
00402         {
00403                 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> - (2.0f*nrevs - 1.0f);
00404                 <font class="keywordflow">if</font>( <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> &lt;= 0.0f)
00405                 {
00406                         <font class="comment">// middle part</font>
00407                         <font class="keywordflow">while</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> &gt;= 2.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> -= 2.0f;
00408                         pp = q0*qaxis;
00409                         <font class="comment">// s vary from 1 to 2. This is still correct for slerp().</font>
00410                         ret = CQuatT&lt;T&gt;::slerp(q0,pp,<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>);
00411                 }
00412                 <font class="keywordflow">else</font>
00413                 {
00414                         <font class="comment">// Last part.</font>
00415                         qq = - q1*qaxis;
00416                         ret= CQuatT&lt;T&gt;::squad(qq,qq,tgtQ1,q1,<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00417                 }
00418         }
00419 
00420         <font class="keywordflow">return</font> ret;
00421 }
00422 
00423 
00424 
00425 <font class="comment">// ***************************************************************************</font>
00426 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00427"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z316_0">00427</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::log()
00428 {
00429         <font class="keywordtype">double</font>  len;
00430         len = sqrt (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>);
00431 
00432         <font class="keywordflow">if</font> (len &lt; <a class="code" href="namespaceNLMISC.html#a171">QuatEpsilon</a>)
00433                 <font class="keywordflow">return</font> CQuatT&lt;T&gt;(0.f, 0.f, 0.f, 0.f);
00434         <font class="keywordflow">else</font>
00435         {
00436                 <font class="keywordtype">double</font> div = (float) acos (<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>) / len;
00437                 <font class="keywordflow">return</font> CQuatT&lt;T&gt;( (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*div), (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*div), (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*div), 0.f);
00438         }
00439 
00440 }
00441 
00442 
00443 <font class="comment">// ***************************************************************************</font>
00444 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00445"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z316_1">00445</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::exp()
00446 {
00447         <font class="keywordtype">double</font>  len;
00448         len = sqrt (<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a> + <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>);
00449 
00450         <font class="keywordflow">if</font> (len &lt; <a class="code" href="namespaceNLMISC.html#a171">QuatEpsilon</a>)
00451                 <font class="keywordflow">return</font> CQuatT&lt;T&gt;(0.f, 0.f, 0.f, 1.f);
00452         <font class="keywordflow">else</font>
00453         {
00454                 <font class="keywordtype">double</font> len1 = sin(len) / len; 
00455                 <font class="keywordflow">return</font> CQuatT&lt;T&gt;( (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>*len1), (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>*len1), (T)(<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>*len1), (T)cos(len));
00456         }
00457 }
00458 
00459 
00460 <font class="comment">// ***************************************************************************</font>
00461 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00462"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z317_4">00462</a> CQuatT&lt;T&gt;       CQuatT&lt;T&gt;::lnDif(<font class="keyword">const</font> CQuatT&lt;T&gt; &amp;q0, <font class="keyword">const</font> CQuatT&lt;T&gt; &amp;q1)
00463 {
00464         CQuatT&lt;T&gt;       dif = q0.inverted()*q1;
00465         dif.normalize();
00466 
00467         <font class="keywordflow">return</font> dif.log();
00468 }
00469 
00470 
00471 <font class="comment">// ***************************************************************************</font>
00472 <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; 
<a name="l00473"></a><a class="code" href="classNLMISC_1_1CQuatT.html#z316_2">00473</a> <font class="keywordtype">void</font>    CQuatT&lt;T&gt;::makeClosest(<font class="keyword">const</font> CQuatT&lt;T&gt; &amp;o)
00474 {
00475         <font class="keywordflow">if</font>( <a class="code" href="classNLMISC_1_1CQuatT.html#z317_0">dotProduct</a>(*<font class="keyword">this</font>, o) &lt; 0 )
00476                 *<font class="keyword">this</font>= -(*this);
00477 }
00478 
00479 
00480 
00481 <font class="comment">// ***************************************************************************</font>
00482 <font class="comment">// ***************************************************************************</font>
00483 <font class="comment">// CQuat/CQuatD</font>
00484 <font class="comment">// ***************************************************************************</font>
00485 <font class="comment">// ***************************************************************************</font>
00486 
00487 
00488 
00489 <font class="comment">// ***************************************************************************</font>
<a name="l00496"></a><a class="code" href="classNLMISC_1_1CQuat.html">00496</a> <font class="comment"></font><font class="keyword">class   </font>CQuat : <font class="keyword">public</font> CQuatT&lt;float&gt;
00497 {
00498 <font class="keyword">public</font>:
00499         <font class="keyword">static</font> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuat.html#z318_1">CQuat</a>              <a class="code" href="classNLMISC_1_1CQuat.html#p0">Identity</a>;
00500 
00502         <font class="comment">// @{</font>
<a name="l00503"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_0">00503</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_1">CQuat</a>   &amp;<a class="code" href="classNLMISC_1_1CQuat.html#z318_0">operator=</a>(<font class="keyword">const</font> CQuatT&lt;float&gt; &amp;o) {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>=o.w; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00504"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_1">00504</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_2">CQuat</a>(<font class="keyword">const</font> CQuatT&lt;float&gt; &amp;o) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;float&gt;(o) {}
<a name="l00505"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_2">00505</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_2">CQuat</a>() {}
<a name="l00506"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_3">00506</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_2">CQuat</a>(<font class="keywordtype">float</font> X, <font class="keywordtype">float</font> Y, <font class="keywordtype">float</font> Z, <font class="keywordtype">float</font> W) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;float&gt;(X,Y,Z,W) {}
<a name="l00508"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_4">00508</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_2">CQuat</a>(<font class="keyword">const</font> CVector &amp;axis, <font class="keywordtype">float</font> angle) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;float&gt;(axis, angle) {}
<a name="l00510"></a><a class="code" href="classNLMISC_1_1CQuat.html#z318_5">00510</a>         <a class="code" href="classNLMISC_1_1CQuat.html#z318_2">CQuat</a>(<font class="keyword">const</font> CAngleAxis &amp;aa) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;float&gt;(aa) {}
00511         <font class="comment">// @}</font>
00512 
00513 };
00514 
00515 
00516 <font class="comment">// ***************************************************************************</font>
<a name="l00523"></a><a class="code" href="classNLMISC_1_1CQuatD.html">00523</a> <font class="comment"></font><font class="keyword">class   </font>CQuatD : <font class="keyword">public</font> CQuatT&lt;double&gt;
00524 {
00525 <font class="keyword">public</font>:
00526         <font class="keyword">static</font> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CQuatD.html#z319_1">CQuatD</a>             <a class="code" href="classNLMISC_1_1CQuatD.html#p0">Identity</a>;
00527 
00529         <font class="comment">// @{</font>
<a name="l00530"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_0">00530</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_1">CQuatD</a>  &amp;<a class="code" href="classNLMISC_1_1CQuatD.html#z319_0">operator=</a>(<font class="keyword">const</font> CQuatT&lt;double&gt; &amp;o) {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>=o.w; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00531"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_1">00531</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>(<font class="keyword">const</font> CQuatT&lt;double&gt; &amp;o) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;double&gt;(o) {}
<a name="l00532"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">00532</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>() {}
<a name="l00533"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_3">00533</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>(<font class="keywordtype">double</font> X, <font class="keywordtype">double</font> Y, <font class="keywordtype">double</font> Z, <font class="keywordtype">double</font> W) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;double&gt;(X,Y,Z,W) {}
<a name="l00535"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_4">00535</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>(<font class="keyword">const</font> CVector &amp;axis, <font class="keywordtype">float</font> angle) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;double&gt;(axis, angle) {}
<a name="l00537"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z319_5">00537</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>(<font class="keyword">const</font> CAngleAxis &amp;aa) : <a class="code" href="classNLMISC_1_1CQuatT.html#z310_0">CQuatT</a>&lt;double&gt;(aa) {}
00538         <font class="comment">// @}</font>
00539 
00540         
00542         <font class="comment">// @{</font>
<a name="l00543"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z320_0">00543</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_2">CQuatD</a>(<font class="keyword">const</font> CQuat &amp;o) {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>=o.w;}
<a name="l00544"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z320_1">00544</a>         <a class="code" href="classNLMISC_1_1CQuatD.html#z319_1">CQuatD</a>  &amp;<a class="code" href="classNLMISC_1_1CQuatD.html#z319_0">operator=</a>(<font class="keyword">const</font> CQuatT&lt;float&gt; &amp;o) {<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>=o.x; <a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>=o.y; <a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>=o.z; <a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>=o.w; <font class="keywordflow">return</font> *<font class="keyword">this</font>;}
<a name="l00545"></a><a class="code" href="classNLMISC_1_1CQuatD.html#z320_2">00545</a>         operator        CQuat()<font class="keyword"> const </font>{<font class="keywordflow">return</font> CQuat((<font class="keywordtype">float</font>)<a class="code" href="classNLMISC_1_1CQuatT.html#m0">x</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNLMISC_1_1CQuatT.html#m1">y</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNLMISC_1_1CQuatT.html#m2">z</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNLMISC_1_1CQuatT.html#m3">w</a>);} 
00546         <font class="comment">// @}</font>
00547 
00548 };
00549 
00550 
00551 
00552 
00553 
00554 } <font class="comment">// NLMISC</font>
00555 
00556 <font class="preprocessor">#endif // NL_QUAT_H </font>
00557 <font class="preprocessor"></font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>