aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/doc/html/triangle3d_8h_source.html
blob: 1cca3cd9d90f1948d70ae2a82b8a7475663acd21 (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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Irrlicht 3D Engine: triangle3d.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Irrlicht 3D Engine
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('triangle3d_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">triangle3d.h</div>  </div>
</div>
<div class="contents">
<a href="triangle3d_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2002-2012 Nikolaus Gebhardt</span>
<a name="l00002"></a>00002 <span class="comment">// This file is part of the &quot;Irrlicht Engine&quot;.</span>
<a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_TRIANGLE_3D_H_INCLUDED__</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_TRIANGLE_3D_H_INCLUDED__</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="vector3d_8h.html">vector3d.h</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="line3d_8h.html">line3d.h</a>&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;<a class="code" href="plane3d_8h.html">plane3d.h</a>&quot;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="aabbox3d_8h.html">aabbox3d.h</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="keyword">namespace </span>irr
<a name="l00014"></a>00014 {
<a name="l00015"></a>00015 <span class="keyword">namespace </span>core
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017 
<a name="l00019"></a>00019     <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00020"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html">00020</a>     <span class="keyword">class </span><a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">triangle3d</a>
<a name="l00021"></a>00021     {
<a name="l00022"></a>00022     <span class="keyword">public</span>:
<a name="l00023"></a>00023 
<a name="l00025"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a4626559294771a8a2fb0cbbaedb6c5f9">00025</a>         <a class="code" href="classirr_1_1core_1_1triangle3d.html#a4626559294771a8a2fb0cbbaedb6c5f9" title="Constructor for an all 0 triangle.">triangle3d</a>() {}
<a name="l00027"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a489813c59bd130d256640ba4e2745505">00027</a>         <a class="code" href="classirr_1_1core_1_1triangle3d.html#a489813c59bd130d256640ba4e2745505" title="Constructor for triangle with given three vertices.">triangle3d</a>(<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> v1, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> v2, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> v3) : <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>(v1), <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>(v2), <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>(v3) {}
<a name="l00028"></a>00028 
<a name="l00030"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a1541eda9f2baabc1f23eecb520c6fef2">00030</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a1541eda9f2baabc1f23eecb520c6fef2" title="Equality operator.">operator==</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">triangle3d&lt;T&gt;</a>&amp; other)<span class="keyword"> const</span>
<a name="l00031"></a>00031 <span class="keyword">        </span>{
<a name="l00032"></a>00032             <span class="keywordflow">return</span> other.<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>==<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a> &amp;&amp; other.<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>==<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> &amp;&amp; other.<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>==<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>;
<a name="l00033"></a>00033         }
<a name="l00034"></a>00034 
<a name="l00036"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a5a3b0b9e0ae5bc1c4c9bf11c06e9d30d">00036</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a5a3b0b9e0ae5bc1c4c9bf11c06e9d30d" title="Inequality operator.">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">triangle3d&lt;T&gt;</a>&amp; other)<span class="keyword"> const</span>
<a name="l00037"></a>00037 <span class="keyword">        </span>{
<a name="l00038"></a>00038             <span class="keywordflow">return</span> !(*<span class="keyword">this</span>==other);
<a name="l00039"></a>00039         }
<a name="l00040"></a>00040 
<a name="l00042"></a>00042 
<a name="l00044"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a9e7a8bba12fb314da35a9c249761a170">00044</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a9e7a8bba12fb314da35a9c249761a170" title="Determines if the triangle is totally inside a bounding box.">isTotalInsideBox</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1aabbox3d.html" title="Axis aligned bounding box in 3d dimensional space.">aabbox3d&lt;T&gt;</a>&amp; box)<span class="keyword"> const</span>
<a name="l00045"></a>00045 <span class="keyword">        </span>{
<a name="l00046"></a>00046             <span class="keywordflow">return</span> (box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#aee439d703d121617c3bd6095c93e6852" title="Determines if a point is within this box.">isPointInside</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>) &amp;&amp;
<a name="l00047"></a>00047                 box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#aee439d703d121617c3bd6095c93e6852" title="Determines if a point is within this box.">isPointInside</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>) &amp;&amp;
<a name="l00048"></a>00048                 box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#aee439d703d121617c3bd6095c93e6852" title="Determines if a point is within this box.">isPointInside</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>));
<a name="l00049"></a>00049         }
<a name="l00050"></a>00050 
<a name="l00052"></a>00052 
<a name="l00054"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a37e1822a18d88b08b2f9de9ed7e4ff84">00054</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a37e1822a18d88b08b2f9de9ed7e4ff84" title="Determines if the triangle is totally outside a bounding box.">isTotalOutsideBox</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1aabbox3d.html" title="Axis aligned bounding box in 3d dimensional space.">aabbox3d&lt;T&gt;</a>&amp; box)<span class="keyword"> const</span>
<a name="l00055"></a>00055 <span class="keyword">        </span>{
<a name="l00056"></a>00056             <span class="keywordflow">return</span> ((<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.X &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X) ||
<a name="l00057"></a>00057 
<a name="l00058"></a>00058                 (<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Y &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y) ||
<a name="l00059"></a>00059                 (<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Z &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z &gt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z) ||
<a name="l00060"></a>00060                 (<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.X &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X) ||
<a name="l00061"></a>00061                 (<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Y &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y) ||
<a name="l00062"></a>00062                 (<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Z &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z &amp;&amp; <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z &lt; box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z));
<a name="l00063"></a>00063         }
<a name="l00064"></a>00064 
<a name="l00066"></a>00066 
<a name="l00068"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a0318b5951c702a306223b0dff7c83128">00068</a>         <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a0318b5951c702a306223b0dff7c83128" title="Get the closest point on a triangle to a point on the same plane.">closestPointOnTriangle</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a>&amp; p)<span class="keyword"> const</span>
<a name="l00069"></a>00069 <span class="keyword">        </span>{
<a name="l00070"></a>00070             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a> rab = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d&lt;T&gt;</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>, <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>).getClosestPoint(p);
<a name="l00071"></a>00071             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a> rbc = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d&lt;T&gt;</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>, <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>).getClosestPoint(p);
<a name="l00072"></a>00072             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a> rca = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d&lt;T&gt;</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>, <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>).getClosestPoint(p);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074             <span class="keyword">const</span> T d1 = rab.<a class="code" href="classirr_1_1core_1_1vector3d.html#afd81bdc7d165f0e2082155127c3005e2" title="Get distance from another point.">getDistanceFrom</a>(p);
<a name="l00075"></a>00075             <span class="keyword">const</span> T d2 = rbc.<a class="code" href="classirr_1_1core_1_1vector3d.html#afd81bdc7d165f0e2082155127c3005e2" title="Get distance from another point.">getDistanceFrom</a>(p);
<a name="l00076"></a>00076             <span class="keyword">const</span> T d3 = rca.<a class="code" href="classirr_1_1core_1_1vector3d.html#afd81bdc7d165f0e2082155127c3005e2" title="Get distance from another point.">getDistanceFrom</a>(p);
<a name="l00077"></a>00077 
<a name="l00078"></a>00078             <span class="keywordflow">if</span> (d1 &lt; d2)
<a name="l00079"></a>00079                 <span class="keywordflow">return</span> d1 &lt; d3 ? rab : rca;
<a name="l00080"></a>00080 
<a name="l00081"></a>00081             <span class="keywordflow">return</span> d2 &lt; d3 ? rbc : rca;
<a name="l00082"></a>00082         }
<a name="l00083"></a>00083 
<a name="l00085"></a>00085         <span class="comment">/*</span>
<a name="l00086"></a>00086 <span class="comment">        \param p Point to test. Assumes that this point is already</span>
<a name="l00087"></a>00087 <span class="comment">        on the plane of the triangle.</span>
<a name="l00088"></a>00088 <span class="comment">        \return True if the point is inside the triangle, otherwise false. */</span>
<a name="l00089"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a2a35b829f8389c5548e19e28157979c9">00089</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a2a35b829f8389c5548e19e28157979c9" title="Check if a point is inside the triangle (border-points count also as inside)">isPointInside</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; p)<span class="keyword"> const</span>
<a name="l00090"></a>00090 <span class="keyword">        </span>{
<a name="l00091"></a>00091             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> af64((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Z);
<a name="l00092"></a>00092             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> bf64((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z);
<a name="l00093"></a>00093             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> cf64((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z);
<a name="l00094"></a>00094             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> pf64((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)p.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a>, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)p.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a>, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)p.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a>);
<a name="l00095"></a>00095             <span class="keywordflow">return</span> (isOnSameSide(pf64, af64, bf64, cf64) &amp;&amp;
<a name="l00096"></a>00096                 isOnSameSide(pf64, bf64, af64, cf64) &amp;&amp;
<a name="l00097"></a>00097                 isOnSameSide(pf64, cf64, af64, bf64));
<a name="l00098"></a>00098         }
<a name="l00099"></a>00099 
<a name="l00101"></a>00101 
<a name="l00108"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a80986af43b5a104bef2c75f74fcf7465">00108</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a80986af43b5a104bef2c75f74fcf7465" title="Check if a point is inside the triangle (border-points count also as inside)">isPointInsideFast</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; p)<span class="keyword"> const</span>
<a name="l00109"></a>00109 <span class="keyword">        </span>{
<a name="l00110"></a>00110             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> a = <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>;
<a name="l00111"></a>00111             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> b = <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>;
<a name="l00112"></a>00112             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> c = p - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>;
<a name="l00113"></a>00113 
<a name="l00114"></a>00114             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> dotAA = a.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>( a);
<a name="l00115"></a>00115             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> dotAB = a.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>( b);
<a name="l00116"></a>00116             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> dotAC = a.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>( c);
<a name="l00117"></a>00117             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> dotBB = b.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>( b);
<a name="l00118"></a>00118             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> dotBC = b.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>( c);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120             <span class="comment">// get coordinates in barycentric coordinate system</span>
<a name="l00121"></a>00121             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> invDenom =  1/(dotAA * dotBB - dotAB * dotAB);
<a name="l00122"></a>00122             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> u = (dotBB * dotAC - dotAB * dotBC) * invDenom;
<a name="l00123"></a>00123             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> v = (dotAA * dotBC - dotAB * dotAC ) * invDenom;
<a name="l00124"></a>00124 
<a name="l00125"></a>00125             <span class="comment">// We count border-points as inside to keep downward compatibility.</span>
<a name="l00126"></a>00126             <span class="comment">// Rounding-error also needed for some test-cases.</span>
<a name="l00127"></a>00127             <span class="keywordflow">return</span> (u &gt; -<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) &amp;&amp; (v &gt;= 0) &amp;&amp; (u + v &lt; 1+<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>);
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         }
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
<a name="l00133"></a>00133 
<a name="l00136"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#ab29f327aac047e9984256b11ace27318">00136</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#ab29f327aac047e9984256b11ace27318" title="Get an intersection with a 3d line.">getIntersectionWithLimitedLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d&lt;T&gt;</a>&amp; line,
<a name="l00137"></a>00137             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outIntersection)<span class="keyword"> const</span>
<a name="l00138"></a>00138 <span class="keyword">        </span>{
<a name="l00139"></a>00139             <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a8507e3af8385b006ca026173fad33506" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(line.<a class="code" href="classirr_1_1core_1_1line3d.html#a8874f77324b6ef6632e66b22051a3251" title="Start point of line.">start</a>,
<a name="l00140"></a>00140                 line.<a class="code" href="classirr_1_1core_1_1line3d.html#a1394b59b713cec4044259d1999bbcc80" title="Get vector of line.">getVector</a>(), outIntersection) &amp;&amp;
<a name="l00141"></a>00141                 outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#ace05ee3b68b47c2ec6baff0d9d64de98" title="Returns if this vector interpreted as a point is on a line between two other points.">isBetweenPoints</a>(line.<a class="code" href="classirr_1_1core_1_1line3d.html#a8874f77324b6ef6632e66b22051a3251" title="Start point of line.">start</a>, line.<a class="code" href="classirr_1_1core_1_1line3d.html#aea19cb33971bb20e1d736facdae8a8f0" title="End point of line.">end</a>);
<a name="l00142"></a>00142         }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 
<a name="l00146"></a>00146 
<a name="l00154"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a8507e3af8385b006ca026173fad33506">00154</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a8507e3af8385b006ca026173fad33506" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint,
<a name="l00155"></a>00155             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; lineVect, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outIntersection)<span class="keyword"> const</span>
<a name="l00156"></a>00156 <span class="keyword">        </span>{
<a name="l00157"></a>00157             <span class="keywordflow">if</span> (<a class="code" href="classirr_1_1core_1_1triangle3d.html#a0ac5455e0215040cc93475baa543303a" title="Calculates the intersection between a 3d line and the plane the triangle is on.">getIntersectionOfPlaneWithLine</a>(linePoint, lineVect, outIntersection))
<a name="l00158"></a>00158                 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a2a35b829f8389c5548e19e28157979c9" title="Check if a point is inside the triangle (border-points count also as inside)">isPointInside</a>(outIntersection);
<a name="l00159"></a>00159 
<a name="l00160"></a>00160             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00161"></a>00161         }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 
<a name="l00165"></a>00165 
<a name="l00169"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a0ac5455e0215040cc93475baa543303a">00169</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a0ac5455e0215040cc93475baa543303a" title="Calculates the intersection between a 3d line and the plane the triangle is on.">getIntersectionOfPlaneWithLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint,
<a name="l00170"></a>00170             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; lineVect, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outIntersection)<span class="keyword"> const</span>
<a name="l00171"></a>00171 <span class="keyword">        </span>{
<a name="l00172"></a>00172             <span class="comment">// Work with f64 to get more precise results (makes enough difference to be worth the casts).</span>
<a name="l00173"></a>00173             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> linePointf64(linePoint.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a>, linePoint.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a>, linePoint.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a>);
<a name="l00174"></a>00174             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> lineVectf64(lineVect.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a>, lineVect.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a>, lineVect.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a>);
<a name="l00175"></a>00175             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> outIntersectionf64;
<a name="l00176"></a>00176 
<a name="l00177"></a>00177             <a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">core::triangle3d&lt;irr::f64&gt;</a> trianglef64(<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.Z)
<a name="l00178"></a>00178                                         ,<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z)
<a name="l00179"></a>00179                                         , <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z));
<a name="l00180"></a>00180             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;irr::f64&gt;</a> normalf64 = trianglef64.<a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2" title="Get the normal of the triangle.">getNormal</a>().normalize();
<a name="l00181"></a>00181             <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> t2;
<a name="l00182"></a>00182 
<a name="l00183"></a>00183             <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">core::iszero</a> ( t2 = normalf64.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(lineVectf64) ) )
<a name="l00184"></a>00184                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00185"></a>00185 
<a name="l00186"></a>00186             <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> d = trianglef64.<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>.dotProduct(normalf64);
<a name="l00187"></a>00187             <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> t = -(normalf64.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(linePointf64) - d) / t2;
<a name="l00188"></a>00188             outIntersectionf64 = linePointf64 + (lineVectf64 * t);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190             outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a> = (T)outIntersectionf64.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a>;
<a name="l00191"></a>00191             outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a> = (T)outIntersectionf64.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a>;
<a name="l00192"></a>00192             outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a> = (T)outIntersectionf64.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a>;
<a name="l00193"></a>00193             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00194"></a>00194         }
<a name="l00195"></a>00195 
<a name="l00196"></a>00196 
<a name="l00198"></a>00198 
<a name="l00199"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2">00199</a>         <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2" title="Get the normal of the triangle.">getNormal</a>()<span class="keyword"> const</span>
<a name="l00200"></a>00200 <span class="keyword">        </span>{
<a name="l00201"></a>00201             <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>).crossProduct(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>);
<a name="l00202"></a>00202         }
<a name="l00203"></a>00203 
<a name="l00205"></a>00205 
<a name="l00210"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#acec0805b8512d9c3b0d5fe4b2cdb8562">00210</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html#acec0805b8512d9c3b0d5fe4b2cdb8562" title="Test if the triangle would be front or backfacing from any point.">isFrontFacing</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; lookDirection)<span class="keyword"> const</span>
<a name="l00211"></a>00211 <span class="keyword">        </span>{
<a name="l00212"></a>00212             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> n = <a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2" title="Get the normal of the triangle.">getNormal</a>().normalize();
<a name="l00213"></a>00213             <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> d = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)n.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(lookDirection);
<a name="l00214"></a>00214             <span class="keywordflow">return</span> <a class="code" href="irr_math_8h.html#a26bc42a9cc1fc775bc588052c32ff9a0">F32_LOWER_EQUAL_0</a>(d);
<a name="l00215"></a>00215         }
<a name="l00216"></a>00216 
<a name="l00218"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a8cec7cdb0c9caa0b41f819eac2ad51aa">00218</a>         <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a8cec7cdb0c9caa0b41f819eac2ad51aa" title="Get the plane of this triangle.">getPlane</a>()<span class="keyword"> const</span>
<a name="l00219"></a>00219 <span class="keyword">        </span>{
<a name="l00220"></a>00220             <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>(<a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>, <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>, <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>);
<a name="l00221"></a>00221         }
<a name="l00222"></a>00222 
<a name="l00224"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a2394228f2da6063eb8fedf1f3da9facc">00224</a>         T <a class="code" href="classirr_1_1core_1_1triangle3d.html#a2394228f2da6063eb8fedf1f3da9facc" title="Get the area of the triangle.">getArea</a>()<span class="keyword"> const</span>
<a name="l00225"></a>00225 <span class="keyword">        </span>{
<a name="l00226"></a>00226             <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>).crossProduct(<a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a> - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>).getLength() * 0.5f;
<a name="l00227"></a>00227 
<a name="l00228"></a>00228         }
<a name="l00229"></a>00229 
<a name="l00231"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#aebcd3f29fcbf9008dac95810c81f152c">00231</a>         <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a>&amp; b, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">core::vector3d&lt;T&gt;</a>&amp; c)
<a name="l00232"></a>00232         {
<a name="l00233"></a>00233             <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a> = a;
<a name="l00234"></a>00234             <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> = b;
<a name="l00235"></a>00235             <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a> = c;
<a name="l00236"></a>00236         }
<a name="l00237"></a>00237 
<a name="l00239"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b">00239</a>         <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>;
<a name="l00240"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">00240</a>         <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>;
<a name="l00241"></a><a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">00241</a>         <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>;
<a name="l00242"></a>00242 
<a name="l00243"></a>00243     <span class="keyword">private</span>:
<a name="l00244"></a>00244         <span class="comment">// Using f64 instead of &lt;T&gt; to avoid integer overflows when T=int (maybe also less floating point troubles).</span>
<a name="l00245"></a>00245         <span class="keywordtype">bool</span> isOnSameSide(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>&amp; p1, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>&amp; p2,
<a name="l00246"></a>00246             <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a>&amp; b)<span class="keyword"> const</span>
<a name="l00247"></a>00247 <span class="keyword">        </span>{
<a name="l00248"></a>00248             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> bminusa = b - a;
<a name="l00249"></a>00249             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> cp1 = bminusa.<a class="code" href="classirr_1_1core_1_1vector3d.html#aa2470a12e1ef53f440c95df6249e9aa4" title="Calculates the cross product with another vector.">crossProduct</a>(p1 - a);
<a name="l00250"></a>00250             <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> cp2 = bminusa.<a class="code" href="classirr_1_1core_1_1vector3d.html#aa2470a12e1ef53f440c95df6249e9aa4" title="Calculates the cross product with another vector.">crossProduct</a>(p2 - a);
<a name="l00251"></a>00251             <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> res = cp1.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(cp2);
<a name="l00252"></a>00252             <span class="keywordflow">if</span> ( res &lt; 0 )
<a name="l00253"></a>00253             {
<a name="l00254"></a>00254                 <span class="comment">// This catches some floating point troubles.</span>
<a name="l00255"></a>00255                 <span class="comment">// Unfortunately slightly expensive and we don&#39;t really know the best epsilon for iszero.</span>
<a name="l00256"></a>00256                 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;f64&gt;</a> cp1 = bminusa.<a class="code" href="classirr_1_1core_1_1vector3d.html#a84a1861464ef70e6965c146732103c09" title="Normalizes the vector.">normalize</a>().crossProduct((p1 - a).normalize());
<a name="l00257"></a>00257                 <span class="keywordflow">if</span> (    <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">core::iszero</a>(cp1.<a class="code" href="classirr_1_1core_1_1vector3d.html#a8c9ed06774dc668112bcefacb6e7732b" title="X coordinate of the vector.">X</a>, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>)
<a name="l00258"></a>00258                     &amp;&amp;  <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">core::iszero</a>(cp1.<a class="code" href="classirr_1_1core_1_1vector3d.html#af8f87c2fe0ce717ade7c3d7419302fbd" title="Y coordinate of the vector.">Y</a>, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)ROUNDING_ERROR_f32)
<a name="l00259"></a>00259                     &amp;&amp;  <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">core::iszero</a>(cp1.<a class="code" href="classirr_1_1core_1_1vector3d.html#ac2beb702e718c3579971348981b220ed" title="Z coordinate of the vector.">Z</a>, (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)ROUNDING_ERROR_f32) )
<a name="l00260"></a>00260                 {
<a name="l00261"></a>00261                     res = 0.f;
<a name="l00262"></a>00262                 }
<a name="l00263"></a>00263             }
<a name="l00264"></a>00264             <span class="keywordflow">return</span> (res &gt;= 0.0f);
<a name="l00265"></a>00265         }
<a name="l00266"></a>00266     };
<a name="l00267"></a>00267 
<a name="l00268"></a>00268 
<a name="l00270"></a><a class="code" href="namespaceirr_1_1core.html#a1112835405bbec5dadf031dc7934e7d0">00270</a>     <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">triangle3d&lt;f32&gt;</a> <a class="code" href="namespaceirr_1_1core.html#a1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">triangle3df</a>;
<a name="l00271"></a>00271 
<a name="l00273"></a><a class="code" href="namespaceirr_1_1core.html#a72a3206800849803d401d34764c40c21">00273</a>     <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1triangle3d.html" title="3d triangle template class for doing collision detection and other things.">triangle3d&lt;s32&gt;</a> <a class="code" href="namespaceirr_1_1core.html#a72a3206800849803d401d34764c40c21" title="Typedef for an integer 3d triangle.">triangle3di</a>;
<a name="l00274"></a>00274 
<a name="l00275"></a>00275 } <span class="comment">// end namespace core</span>
<a name="l00276"></a>00276 } <span class="comment">// end namespace irr</span>
<a name="l00277"></a>00277 
<a name="l00278"></a>00278 <span class="preprocessor">#endif</span>
<a name="l00279"></a>00279 <span class="preprocessor"></span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="triangle3d_8h.html">triangle3d.h</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:40 for Irrlicht 3D Engine by
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>