diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/doc/html/triangle3d_8h_source.html | 353 |
1 files changed, 353 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/triangle3d_8h_source.html b/libraries/irrlicht-1.8/doc/html/triangle3d_8h_source.html new file mode 100644 index 0000000..04dec68 --- /dev/null +++ b/libraries/irrlicht-1.8/doc/html/triangle3d_8h_source.html | |||
@@ -0,0 +1,353 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
2 | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | ||
5 | <title>Irrlicht 3D Engine: triangle3d.h Source File</title> | ||
6 | |||
7 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | ||
9 | <link href="navtree.css" rel="stylesheet" type="text/css"/> | ||
10 | <script type="text/javascript" src="jquery.js"></script> | ||
11 | <script type="text/javascript" src="resize.js"></script> | ||
12 | <script type="text/javascript" src="navtree.js"></script> | ||
13 | <script type="text/javascript"> | ||
14 | $(document).ready(initResizable); | ||
15 | </script> | ||
16 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | ||
17 | <script type="text/javascript" src="search/search.js"></script> | ||
18 | <script type="text/javascript"> | ||
19 | $(document).ready(function() { searchBox.OnSelectItem(0); }); | ||
20 | </script> | ||
21 | |||
22 | </head> | ||
23 | <body> | ||
24 | <div id="top"><!-- do not remove this div! --> | ||
25 | |||
26 | |||
27 | <div id="titlearea"> | ||
28 | <table cellspacing="0" cellpadding="0"> | ||
29 | <tbody> | ||
30 | <tr style="height: 56px;"> | ||
31 | |||
32 | <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td> | ||
33 | |||
34 | |||
35 | <td style="padding-left: 0.5em;"> | ||
36 | <div id="projectname">Irrlicht 3D Engine | ||
37 | |||
38 | </div> | ||
39 | |||
40 | </td> | ||
41 | |||
42 | |||
43 | |||
44 | |||
45 | <td> <div id="MSearchBox" class="MSearchBoxInactive"> | ||
46 | <span class="left"> | ||
47 | <img id="MSearchSelect" src="search/mag_sel.png" | ||
48 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
49 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
50 | alt=""/> | ||
51 | <input type="text" id="MSearchField" value="Search" accesskey="S" | ||
52 | onfocus="searchBox.OnSearchFieldFocus(true)" | ||
53 | onblur="searchBox.OnSearchFieldFocus(false)" | ||
54 | onkeyup="searchBox.OnSearchFieldChange(event)"/> | ||
55 | </span><span class="right"> | ||
56 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> | ||
57 | </span> | ||
58 | </div> | ||
59 | </td> | ||
60 | |||
61 | |||
62 | </tr> | ||
63 | </tbody> | ||
64 | </table> | ||
65 | </div> | ||
66 | |||
67 | <!-- Generated by Doxygen 1.7.5.1 --> | ||
68 | <script type="text/javascript"> | ||
69 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | ||
70 | </script> | ||
71 | <script type="text/javascript" src="dynsections.js"></script> | ||
72 | </div> | ||
73 | <div id="side-nav" class="ui-resizable side-nav-resizable"> | ||
74 | <div id="nav-tree"> | ||
75 | <div id="nav-tree-contents"> | ||
76 | </div> | ||
77 | </div> | ||
78 | <div id="splitbar" style="-moz-user-select:none;" | ||
79 | class="ui-resizable-handle"> | ||
80 | </div> | ||
81 | </div> | ||
82 | <script type="text/javascript"> | ||
83 | initNavTree('triangle3d_8h.html',''); | ||
84 | </script> | ||
85 | <div id="doc-content"> | ||
86 | <div class="header"> | ||
87 | <div class="headertitle"> | ||
88 | <div class="title">triangle3d.h</div> </div> | ||
89 | </div> | ||
90 | <div class="contents"> | ||
91 | <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> | ||
92 | <a name="l00002"></a>00002 <span class="comment">// This file is part of the "Irrlicht Engine".</span> | ||
93 | <a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span> | ||
94 | <a name="l00004"></a>00004 | ||
95 | <a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_TRIANGLE_3D_H_INCLUDED__</span> | ||
96 | <a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_TRIANGLE_3D_H_INCLUDED__</span> | ||
97 | <a name="l00007"></a>00007 <span class="preprocessor"></span> | ||
98 | <a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="vector3d_8h.html">vector3d.h</a>"</span> | ||
99 | <a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="line3d_8h.html">line3d.h</a>"</span> | ||
100 | <a name="l00010"></a>00010 <span class="preprocessor">#include "<a class="code" href="plane3d_8h.html">plane3d.h</a>"</span> | ||
101 | <a name="l00011"></a>00011 <span class="preprocessor">#include "<a class="code" href="aabbox3d_8h.html">aabbox3d.h</a>"</span> | ||
102 | <a name="l00012"></a>00012 | ||
103 | <a name="l00013"></a>00013 <span class="keyword">namespace </span>irr | ||
104 | <a name="l00014"></a>00014 { | ||
105 | <a name="l00015"></a>00015 <span class="keyword">namespace </span>core | ||
106 | <a name="l00016"></a>00016 { | ||
107 | <a name="l00017"></a>00017 | ||
108 | <a name="l00019"></a>00019 <span class="keyword">template</span> <<span class="keyword">class</span> T> | ||
109 | <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> | ||
110 | <a name="l00021"></a>00021 { | ||
111 | <a name="l00022"></a>00022 <span class="keyword">public</span>: | ||
112 | <a name="l00023"></a>00023 | ||
113 | <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>() {} | ||
114 | <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<T></a> v1, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> v2, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></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) {} | ||
115 | <a name="l00028"></a>00028 | ||
116 | <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<T></a>& other)<span class="keyword"> const</span> | ||
117 | <a name="l00031"></a>00031 <span class="keyword"> </span>{ | ||
118 | <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> && 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> && 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>; | ||
119 | <a name="l00033"></a>00033 } | ||
120 | <a name="l00034"></a>00034 | ||
121 | <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<T></a>& other)<span class="keyword"> const</span> | ||
122 | <a name="l00037"></a>00037 <span class="keyword"> </span>{ | ||
123 | <a name="l00038"></a>00038 <span class="keywordflow">return</span> !(*<span class="keyword">this</span>==other); | ||
124 | <a name="l00039"></a>00039 } | ||
125 | <a name="l00040"></a>00040 | ||
126 | <a name="l00042"></a>00042 | ||
127 | <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<T></a>& box)<span class="keyword"> const</span> | ||
128 | <a name="l00045"></a>00045 <span class="keyword"> </span>{ | ||
129 | <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>) && | ||
130 | <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>) && | ||
131 | <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>)); | ||
132 | <a name="l00049"></a>00049 } | ||
133 | <a name="l00050"></a>00050 | ||
134 | <a name="l00052"></a>00052 | ||
135 | <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<T></a>& box)<span class="keyword"> const</span> | ||
136 | <a name="l00055"></a>00055 <span class="keyword"> </span>{ | ||
137 | <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 > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.X) || | ||
138 | <a name="l00057"></a>00057 | ||
139 | <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 > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Y) || | ||
140 | <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 > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z > box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a5aad7217e8189f09dde3ec4a69e4ac92" title="The far edge.">MaxEdge</a>.Z) || | ||
141 | <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 < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.X < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.X < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.X) || | ||
142 | <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 < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Y < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Y < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Y) || | ||
143 | <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 < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>.Z < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z && <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>.Z < box.<a class="code" href="classirr_1_1core_1_1aabbox3d.html#a7501c7df834939fa25e5f70b8527e7b5" title="The near edge.">MinEdge</a>.Z)); | ||
144 | <a name="l00063"></a>00063 } | ||
145 | <a name="l00064"></a>00064 | ||
146 | <a name="l00066"></a>00066 | ||
147 | <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<T></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<T></a>& p)<span class="keyword"> const</span> | ||
148 | <a name="l00069"></a>00069 <span class="keyword"> </span>{ | ||
149 | <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<T></a> rab = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d<T></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); | ||
150 | <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<T></a> rbc = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d<T></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); | ||
151 | <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<T></a> rca = <a class="code" href="classirr_1_1core_1_1line3d.html" title="3D line between two points with intersection methods.">line3d<T></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); | ||
152 | <a name="l00073"></a>00073 | ||
153 | <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); | ||
154 | <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); | ||
155 | <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); | ||
156 | <a name="l00077"></a>00077 | ||
157 | <a name="l00078"></a>00078 <span class="keywordflow">if</span> (d1 < d2) | ||
158 | <a name="l00079"></a>00079 <span class="keywordflow">return</span> d1 < d3 ? rab : rca; | ||
159 | <a name="l00080"></a>00080 | ||
160 | <a name="l00081"></a>00081 <span class="keywordflow">return</span> d2 < d3 ? rbc : rca; | ||
161 | <a name="l00082"></a>00082 } | ||
162 | <a name="l00083"></a>00083 | ||
163 | <a name="l00085"></a>00085 <span class="comment">/*</span> | ||
164 | <a name="l00086"></a>00086 <span class="comment"> \param p Point to test. Assumes that this point is already</span> | ||
165 | <a name="l00087"></a>00087 <span class="comment"> on the plane of the triangle.</span> | ||
166 | <a name="l00088"></a>00088 <span class="comment"> \return True if the point is inside the triangle, otherwise false. */</span> | ||
167 | <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<T></a>& p)<span class="keyword"> const</span> | ||
168 | <a name="l00090"></a>00090 <span class="keyword"> </span>{ | ||
169 | <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<f64></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); | ||
170 | <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<f64></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); | ||
171 | <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<f64></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); | ||
172 | <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<f64></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>); | ||
173 | <a name="l00095"></a>00095 <span class="keywordflow">return</span> (isOnSameSide(pf64, af64, bf64, cf64) && | ||
174 | <a name="l00096"></a>00096 isOnSameSide(pf64, bf64, af64, cf64) && | ||
175 | <a name="l00097"></a>00097 isOnSameSide(pf64, cf64, af64, bf64)); | ||
176 | <a name="l00098"></a>00098 } | ||
177 | <a name="l00099"></a>00099 | ||
178 | <a name="l00101"></a>00101 | ||
179 | <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<T></a>& p)<span class="keyword"> const</span> | ||
180 | <a name="l00109"></a>00109 <span class="keyword"> </span>{ | ||
181 | <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<T></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>; | ||
182 | <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<T></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>; | ||
183 | <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<T></a> c = p - <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>; | ||
184 | <a name="l00113"></a>00113 | ||
185 | <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); | ||
186 | <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); | ||
187 | <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); | ||
188 | <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); | ||
189 | <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); | ||
190 | <a name="l00119"></a>00119 | ||
191 | <a name="l00120"></a>00120 <span class="comment">// get coordinates in barycentric coordinate system</span> | ||
192 | <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); | ||
193 | <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; | ||
194 | <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; | ||
195 | <a name="l00124"></a>00124 | ||
196 | <a name="l00125"></a>00125 <span class="comment">// We count border-points as inside to keep downward compatibility.</span> | ||
197 | <a name="l00126"></a>00126 <span class="comment">// Rounding-error also needed for some test-cases.</span> | ||
198 | <a name="l00127"></a>00127 <span class="keywordflow">return</span> (u > -<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) && (v >= 0) && (u + v < 1+<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>); | ||
199 | <a name="l00128"></a>00128 | ||
200 | <a name="l00129"></a>00129 } | ||
201 | <a name="l00130"></a>00130 | ||
202 | <a name="l00131"></a>00131 | ||
203 | <a name="l00133"></a>00133 | ||
204 | <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<T></a>& line, | ||
205 | <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<T></a>& outIntersection)<span class="keyword"> const</span> | ||
206 | <a name="l00138"></a>00138 <span class="keyword"> </span>{ | ||
207 | <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>, | ||
208 | <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) && | ||
209 | <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>); | ||
210 | <a name="l00142"></a>00142 } | ||
211 | <a name="l00143"></a>00143 | ||
212 | <a name="l00144"></a>00144 | ||
213 | <a name="l00146"></a>00146 | ||
214 | <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<T></a>& linePoint, | ||
215 | <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<T></a>& lineVect, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outIntersection)<span class="keyword"> const</span> | ||
216 | <a name="l00156"></a>00156 <span class="keyword"> </span>{ | ||
217 | <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)) | ||
218 | <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); | ||
219 | <a name="l00159"></a>00159 | ||
220 | <a name="l00160"></a>00160 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
221 | <a name="l00161"></a>00161 } | ||
222 | <a name="l00162"></a>00162 | ||
223 | <a name="l00163"></a>00163 | ||
224 | <a name="l00165"></a>00165 | ||
225 | <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<T></a>& linePoint, | ||
226 | <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<T></a>& lineVect, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outIntersection)<span class="keyword"> const</span> | ||
227 | <a name="l00171"></a>00171 <span class="keyword"> </span>{ | ||
228 | <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> | ||
229 | <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<f64></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>); | ||
230 | <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<f64></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>); | ||
231 | <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<f64></a> outIntersectionf64; | ||
232 | <a name="l00176"></a>00176 | ||
233 | <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<irr::f64></a> trianglef64(<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<f64></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) | ||
234 | <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<f64></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) | ||
235 | <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<f64></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)); | ||
236 | <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<irr::f64></a> normalf64 = trianglef64.<a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2" title="Get the normal of the triangle.">getNormal</a>().normalize(); | ||
237 | <a name="l00181"></a>00181 <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> t2; | ||
238 | <a name="l00182"></a>00182 | ||
239 | <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) ) ) | ||
240 | <a name="l00184"></a>00184 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
241 | <a name="l00185"></a>00185 | ||
242 | <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); | ||
243 | <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; | ||
244 | <a name="l00188"></a>00188 outIntersectionf64 = linePointf64 + (lineVectf64 * t); | ||
245 | <a name="l00189"></a>00189 | ||
246 | <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>; | ||
247 | <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>; | ||
248 | <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>; | ||
249 | <a name="l00193"></a>00193 <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
250 | <a name="l00194"></a>00194 } | ||
251 | <a name="l00195"></a>00195 | ||
252 | <a name="l00196"></a>00196 | ||
253 | <a name="l00198"></a>00198 | ||
254 | <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<T></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> | ||
255 | <a name="l00200"></a>00200 <span class="keyword"> </span>{ | ||
256 | <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>); | ||
257 | <a name="l00202"></a>00202 } | ||
258 | <a name="l00203"></a>00203 | ||
259 | <a name="l00205"></a>00205 | ||
260 | <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<T></a>& lookDirection)<span class="keyword"> const</span> | ||
261 | <a name="l00211"></a>00211 <span class="keyword"> </span>{ | ||
262 | <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<T></a> n = <a class="code" href="classirr_1_1core_1_1triangle3d.html#a14298103d89ba5eae37d82d8556f07e2" title="Get the normal of the triangle.">getNormal</a>().normalize(); | ||
263 | <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); | ||
264 | <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); | ||
265 | <a name="l00215"></a>00215 } | ||
266 | <a name="l00216"></a>00216 | ||
267 | <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<T></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> | ||
268 | <a name="l00219"></a>00219 <span class="keyword"> </span>{ | ||
269 | <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<T></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>); | ||
270 | <a name="l00221"></a>00221 } | ||
271 | <a name="l00222"></a>00222 | ||
272 | <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> | ||
273 | <a name="l00225"></a>00225 <span class="keyword"> </span>{ | ||
274 | <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; | ||
275 | <a name="l00227"></a>00227 | ||
276 | <a name="l00228"></a>00228 } | ||
277 | <a name="l00229"></a>00229 | ||
278 | <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<T></a>& 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<T></a>& 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<T></a>& c) | ||
279 | <a name="l00232"></a>00232 { | ||
280 | <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; | ||
281 | <a name="l00234"></a>00234 <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a> = b; | ||
282 | <a name="l00235"></a>00235 <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a> = c; | ||
283 | <a name="l00236"></a>00236 } | ||
284 | <a name="l00237"></a>00237 | ||
285 | <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<T></a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#ad4113299162b5855bccf8465b31ff78b" title="the three points of the triangle">pointA</a>; | ||
286 | <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<T></a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a3ed5276e50f3d3b6a1e2483dffa822ac">pointB</a>; | ||
287 | <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<T></a> <a class="code" href="classirr_1_1core_1_1triangle3d.html#a08e65517102b6d04f0537b876e152466">pointC</a>; | ||
288 | <a name="l00242"></a>00242 | ||
289 | <a name="l00243"></a>00243 <span class="keyword">private</span>: | ||
290 | <a name="l00244"></a>00244 <span class="comment">// Using f64 instead of <T> to avoid integer overflows when T=int (maybe also less floating point troubles).</span> | ||
291 | <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<f64></a>& 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<f64></a>& p2, | ||
292 | <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<f64></a>& 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<f64></a>& b)<span class="keyword"> const</span> | ||
293 | <a name="l00247"></a>00247 <span class="keyword"> </span>{ | ||
294 | <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<f64></a> bminusa = b - a; | ||
295 | <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<f64></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); | ||
296 | <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<f64></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); | ||
297 | <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); | ||
298 | <a name="l00252"></a>00252 <span class="keywordflow">if</span> ( res < 0 ) | ||
299 | <a name="l00253"></a>00253 { | ||
300 | <a name="l00254"></a>00254 <span class="comment">// This catches some floating point troubles.</span> | ||
301 | <a name="l00255"></a>00255 <span class="comment">// Unfortunately slightly expensive and we don't really know the best epsilon for iszero.</span> | ||
302 | <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<f64></a> cp1 = bminusa.<a class="code" href="classirr_1_1core_1_1vector3d.html#a84a1861464ef70e6965c146732103c09" title="Normalizes the vector.">normalize</a>().crossProduct((p1 - a).normalize()); | ||
303 | <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>) | ||
304 | <a name="l00258"></a>00258 && <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) | ||
305 | <a name="l00259"></a>00259 && <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) ) | ||
306 | <a name="l00260"></a>00260 { | ||
307 | <a name="l00261"></a>00261 res = 0.f; | ||
308 | <a name="l00262"></a>00262 } | ||
309 | <a name="l00263"></a>00263 } | ||
310 | <a name="l00264"></a>00264 <span class="keywordflow">return</span> (res >= 0.0f); | ||
311 | <a name="l00265"></a>00265 } | ||
312 | <a name="l00266"></a>00266 }; | ||
313 | <a name="l00267"></a>00267 | ||
314 | <a name="l00268"></a>00268 | ||
315 | <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<f32></a> <a class="code" href="namespaceirr_1_1core.html#a1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">triangle3df</a>; | ||
316 | <a name="l00271"></a>00271 | ||
317 | <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<s32></a> <a class="code" href="namespaceirr_1_1core.html#a72a3206800849803d401d34764c40c21" title="Typedef for an integer 3d triangle.">triangle3di</a>; | ||
318 | <a name="l00274"></a>00274 | ||
319 | <a name="l00275"></a>00275 } <span class="comment">// end namespace core</span> | ||
320 | <a name="l00276"></a>00276 } <span class="comment">// end namespace irr</span> | ||
321 | <a name="l00277"></a>00277 | ||
322 | <a name="l00278"></a>00278 <span class="preprocessor">#endif</span> | ||
323 | <a name="l00279"></a>00279 <span class="preprocessor"></span> | ||
324 | </pre></div></div> | ||
325 | </div> | ||
326 | <div id="nav-path" class="navpath"> | ||
327 | <ul> | ||
328 | <li class="navelem"><a class="el" href="triangle3d_8h.html">triangle3d.h</a> </li> | ||
329 | <!-- window showing the filter options --> | ||
330 | <div id="MSearchSelectWindow" | ||
331 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
332 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
333 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
334 | <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div> | ||
335 | |||
336 | <!-- iframe showing the search results (closed by default) --> | ||
337 | <div id="MSearchResultsWindow"> | ||
338 | <iframe src="javascript:void(0)" frameborder="0" | ||
339 | name="MSearchResults" id="MSearchResults"> | ||
340 | </iframe> | ||
341 | </div> | ||
342 | |||
343 | |||
344 | <li class="footer"> | ||
345 | <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht | ||
346 | Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:00 for Irrlicht 3D Engine by | ||
347 | <a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li> | ||
348 | </ul> | ||
349 | </div> | ||
350 | |||
351 | |||
352 | </body> | ||
353 | </html> | ||