diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/doc/html/line2d_8h_source.html | 363 |
1 files changed, 363 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/line2d_8h_source.html b/libraries/irrlicht-1.8/doc/html/line2d_8h_source.html new file mode 100644 index 0000000..6df1943 --- /dev/null +++ b/libraries/irrlicht-1.8/doc/html/line2d_8h_source.html | |||
@@ -0,0 +1,363 @@ | |||
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: line2d.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('line2d_8h.html',''); | ||
84 | </script> | ||
85 | <div id="doc-content"> | ||
86 | <div class="header"> | ||
87 | <div class="headertitle"> | ||
88 | <div class="title">line2d.h</div> </div> | ||
89 | </div> | ||
90 | <div class="contents"> | ||
91 | <a href="line2d_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_LINE_2D_H_INCLUDED__</span> | ||
96 | <a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_LINE_2D_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="irr_types_8h.html">irrTypes.h</a>"</span> | ||
99 | <a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="vector2d_8h.html">vector2d.h</a>"</span> | ||
100 | <a name="l00010"></a>00010 | ||
101 | <a name="l00011"></a>00011 <span class="keyword">namespace </span>irr | ||
102 | <a name="l00012"></a>00012 { | ||
103 | <a name="l00013"></a>00013 <span class="keyword">namespace </span>core | ||
104 | <a name="l00014"></a>00014 { | ||
105 | <a name="l00015"></a>00015 | ||
106 | <a name="l00017"></a>00017 <span class="keyword">template</span> <<span class="keyword">class</span> T> | ||
107 | <a name="l00018"></a><a class="code" href="classirr_1_1core_1_1line2d.html">00018</a> <span class="keyword">class </span><a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d</a> | ||
108 | <a name="l00019"></a>00019 { | ||
109 | <a name="l00020"></a>00020 <span class="keyword">public</span>: | ||
110 | <a name="l00022"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a7d0f25f93572eb73734da83da8490410">00022</a> <a class="code" href="classirr_1_1core_1_1line2d.html#a7d0f25f93572eb73734da83da8490410" title="Default constructor for line going from (0,0) to (1,1).">line2d</a>() : <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>(0,0), <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>(1,1) {} | ||
111 | <a name="l00024"></a><a class="code" href="classirr_1_1core_1_1line2d.html#af9614350cdb0527c190dcf3342ecb42e">00024</a> <a class="code" href="classirr_1_1core_1_1line2d.html#af9614350cdb0527c190dcf3342ecb42e" title="Constructor for line between the two points.">line2d</a>(T xa, T ya, T xb, T yb) : <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>(xa, ya), <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>(xb, yb) {} | ||
112 | <a name="l00026"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a447958017eba9f8667625b82c25f344c">00026</a> <a class="code" href="classirr_1_1core_1_1line2d.html#a447958017eba9f8667625b82c25f344c" title="Constructor for line between the two points given as vectors.">line2d</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>) : start(start), end(end) {} | ||
113 | <a name="l00028"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a19338e17d69fa3062709ebd7b7f73409">00028</a> <a class="code" href="classirr_1_1core_1_1line2d.html#a19338e17d69fa3062709ebd7b7f73409" title="Copy constructor.">line2d</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& other) : <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>(other.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>), <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>(other.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>) {} | ||
114 | <a name="l00029"></a>00029 | ||
115 | <a name="l00030"></a>00030 <span class="comment">// operators</span> | ||
116 | <a name="l00031"></a>00031 | ||
117 | <a name="l00032"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a51af9b8fe28dd6b86ecdec1a4bb0b33b">00032</a> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#a51af9b8fe28dd6b86ecdec1a4bb0b33b">operator+</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> + point, <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> + point); } | ||
118 | <a name="l00033"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a65cf466904a15dd61311c1381e05cf8a">00033</a> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& <a class="code" href="classirr_1_1core_1_1line2d.html#a65cf466904a15dd61311c1381e05cf8a">operator+=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point) { <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> += point; <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> += point; <span class="keywordflow">return</span> *<span class="keyword">this</span>; } | ||
119 | <a name="l00034"></a>00034 | ||
120 | <a name="l00035"></a><a class="code" href="classirr_1_1core_1_1line2d.html#adf2a36aae4b47529e5675386dec27e2e">00035</a> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#adf2a36aae4b47529e5675386dec27e2e">operator-</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> - point, <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> - point); } | ||
121 | <a name="l00036"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a57edf657caac2f4c15ae8201fcef0e84">00036</a> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& <a class="code" href="classirr_1_1core_1_1line2d.html#a57edf657caac2f4c15ae8201fcef0e84">operator-=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point) { <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> -= point; <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> -= point; <span class="keywordflow">return</span> *<span class="keyword">this</span>; } | ||
122 | <a name="l00037"></a>00037 | ||
123 | <a name="l00038"></a><a class="code" href="classirr_1_1core_1_1line2d.html#afe1f119e95b91aafedab58c5019bdd1c">00038</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1line2d.html#afe1f119e95b91aafedab58c5019bdd1c">operator==</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& other)<span class="keyword"> const</span> | ||
124 | <a name="l00039"></a>00039 <span class="keyword"> </span>{ <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>) || (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>);} | ||
125 | <a name="l00040"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a6b11d575a1e248c2928ababb81638e87">00040</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1line2d.html#a6b11d575a1e248c2928ababb81638e87">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& other)<span class="keyword"> const</span> | ||
126 | <a name="l00041"></a>00041 <span class="keyword"> </span>{ <span class="keywordflow">return</span> !(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>) || (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>==other.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>);} | ||
127 | <a name="l00042"></a>00042 | ||
128 | <a name="l00043"></a>00043 <span class="comment">// functions</span> | ||
129 | <a name="l00045"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a65224228a0681a6be6f2576fb0093a12">00045</a> <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1line2d.html#a65224228a0681a6be6f2576fb0093a12" title="Set this line to new line going through the two points.">setLine</a>(<span class="keyword">const</span> T& xa, <span class="keyword">const</span> T& ya, <span class="keyword">const</span> T& xb, <span class="keyword">const</span> T& yb){<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.set(xa, ya); <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.set(xb, yb);} | ||
130 | <a name="l00047"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a2573eb6b41d08ae4ab16be2630168d3b">00047</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1line2d.html#a2573eb6b41d08ae4ab16be2630168d3b" title="Set this line to new line going through the two points.">setLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& nstart, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& nend){<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.set(nstart); <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.set(nend);} | ||
131 | <a name="l00049"></a><a class="code" href="classirr_1_1core_1_1line2d.html#af7a159fc82aff5dcab173fcd24934df1">00049</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1line2d.html#af7a159fc82aff5dcab173fcd24934df1" title="Set this line to new line given as parameter.">setLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& line){<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.set(line.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>); <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.set(line.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>);} | ||
132 | <a name="l00050"></a>00050 | ||
133 | <a name="l00052"></a>00052 | ||
134 | <a name="l00053"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a2eb306d0e3db94712ece741bfadbfa55">00053</a> T <a class="code" href="classirr_1_1core_1_1line2d.html#a2eb306d0e3db94712ece741bfadbfa55" title="Get length of line.">getLength</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.getDistanceFrom(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>); } | ||
135 | <a name="l00054"></a>00054 | ||
136 | <a name="l00056"></a>00056 | ||
137 | <a name="l00057"></a><a class="code" href="classirr_1_1core_1_1line2d.html#abd4c50d417c8d91401ff4bc59902ab35">00057</a> T <a class="code" href="classirr_1_1core_1_1line2d.html#abd4c50d417c8d91401ff4bc59902ab35" title="Get squared length of the line.">getLengthSQ</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.getDistanceFromSQ(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>); } | ||
138 | <a name="l00058"></a>00058 | ||
139 | <a name="l00060"></a>00060 | ||
140 | <a name="l00061"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a83b583161e402d93a2346a2dfbbd885c">00061</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#a83b583161e402d93a2346a2dfbbd885c" title="Get middle of the line.">getMiddle</a>()<span class="keyword"> const</span> | ||
141 | <a name="l00062"></a>00062 <span class="keyword"> </span>{ | ||
142 | <a name="l00063"></a>00063 <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> + <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>)/(T)2; | ||
143 | <a name="l00064"></a>00064 } | ||
144 | <a name="l00065"></a>00065 | ||
145 | <a name="l00067"></a>00067 | ||
146 | <a name="l00068"></a><a class="code" href="classirr_1_1core_1_1line2d.html#af6df3035ac8f217f86106ea88cc2e941">00068</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#af6df3035ac8f217f86106ea88cc2e941" title="Get the vector of the line.">getVector</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X, <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y); } | ||
147 | <a name="l00069"></a>00069 | ||
148 | <a name="l00071"></a>00071 | ||
149 | <a name="l00077"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a3ebdfe2b5dd3de6da61d7cb3030662e8">00077</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1line2d.html#a3ebdfe2b5dd3de6da61d7cb3030662e8" title="Tests if this line intersects with another line.">intersectWith</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& l, <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& out, <span class="keywordtype">bool</span> checkOnlySegments=<span class="keyword">true</span>)<span class="keyword"> const</span> | ||
150 | <a name="l00078"></a>00078 <span class="keyword"> </span>{ | ||
151 | <a name="l00079"></a>00079 <span class="comment">// Uses the method given at:</span> | ||
152 | <a name="l00080"></a>00080 <span class="comment">// http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/</span> | ||
153 | <a name="l00081"></a>00081 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> commonDenominator = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)*(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) - | ||
154 | <a name="l00082"></a>00082 (l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X)*(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y); | ||
155 | <a name="l00083"></a>00083 | ||
156 | <a name="l00084"></a>00084 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> numeratorA = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X)*(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y) - | ||
157 | <a name="l00085"></a>00085 (l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)*(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X -l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X); | ||
158 | <a name="l00086"></a>00086 | ||
159 | <a name="l00087"></a>00087 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> numeratorB = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X)*(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y - l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y) - | ||
160 | <a name="l00088"></a>00088 (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)*(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X -l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X); | ||
161 | <a name="l00089"></a>00089 | ||
162 | <a name="l00090"></a>00090 <span class="keywordflow">if</span>(<a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(commonDenominator, 0.f)) | ||
163 | <a name="l00091"></a>00091 { | ||
164 | <a name="l00092"></a>00092 <span class="comment">// The lines are either coincident or parallel</span> | ||
165 | <a name="l00093"></a>00093 <span class="comment">// if both numerators are 0, the lines are coincident</span> | ||
166 | <a name="l00094"></a>00094 <span class="keywordflow">if</span>(<a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(numeratorA, 0.f) && <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(numeratorB, 0.f)) | ||
167 | <a name="l00095"></a>00095 { | ||
168 | <a name="l00096"></a>00096 <span class="comment">// Try and find a common endpoint</span> | ||
169 | <a name="l00097"></a>00097 <span class="keywordflow">if</span>(l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> == <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> || l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> == <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>) | ||
170 | <a name="l00098"></a>00098 out = <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
171 | <a name="l00099"></a>00099 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> == <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> || l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> == <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>) | ||
172 | <a name="l00100"></a>00100 out = <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
173 | <a name="l00101"></a>00101 <span class="comment">// now check if the two segments are disjunct</span> | ||
174 | <a name="l00102"></a>00102 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) | ||
175 | <a name="l00103"></a>00103 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
176 | <a name="l00104"></a>00104 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y) | ||
177 | <a name="l00105"></a>00105 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
178 | <a name="l00106"></a>00106 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) | ||
179 | <a name="l00107"></a>00107 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
180 | <a name="l00108"></a>00108 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y) | ||
181 | <a name="l00109"></a>00109 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
182 | <a name="l00110"></a>00110 <span class="comment">// else the lines are overlapping to some extent</span> | ||
183 | <a name="l00111"></a>00111 <span class="keywordflow">else</span> | ||
184 | <a name="l00112"></a>00112 { | ||
185 | <a name="l00113"></a>00113 <span class="comment">// find the points which are not contributing to the</span> | ||
186 | <a name="l00114"></a>00114 <span class="comment">// common part</span> | ||
187 | <a name="l00115"></a>00115 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> maxp; | ||
188 | <a name="l00116"></a>00116 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> minp; | ||
189 | <a name="l00117"></a>00117 <span class="keywordflow">if</span> ((<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X>l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) || (<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y>l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y)) | ||
190 | <a name="l00118"></a>00118 maxp=<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
191 | <a name="l00119"></a>00119 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X>l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) || (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y>l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)) | ||
192 | <a name="l00120"></a>00120 maxp=<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
193 | <a name="l00121"></a>00121 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) || (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y>l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y)) | ||
194 | <a name="l00122"></a>00122 maxp=l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
195 | <a name="l00123"></a>00123 <span class="keywordflow">else</span> | ||
196 | <a name="l00124"></a>00124 maxp=l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
197 | <a name="l00125"></a>00125 <span class="keywordflow">if</span> (maxp != <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && ((<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) || (<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y))) | ||
198 | <a name="l00126"></a>00126 minp=<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
199 | <a name="l00127"></a>00127 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (maxp != <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> && ((<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X<l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) || (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y<l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y))) | ||
200 | <a name="l00128"></a>00128 minp=<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
201 | <a name="l00129"></a>00129 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (maxp != l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> && ((l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X) || (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y<<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y))) | ||
202 | <a name="l00130"></a>00130 minp=l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
203 | <a name="l00131"></a>00131 <span class="keywordflow">else</span> | ||
204 | <a name="l00132"></a>00132 minp=l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
205 | <a name="l00133"></a>00133 | ||
206 | <a name="l00134"></a>00134 <span class="comment">// one line is contained in the other. Pick the center</span> | ||
207 | <a name="l00135"></a>00135 <span class="comment">// of the remaining points, which overlap for sure</span> | ||
208 | <a name="l00136"></a>00136 out = <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">core::vector2d<T></a>(); | ||
209 | <a name="l00137"></a>00137 <span class="keywordflow">if</span> (<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> != maxp && <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> != minp) | ||
210 | <a name="l00138"></a>00138 out += <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
211 | <a name="l00139"></a>00139 <span class="keywordflow">if</span> (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> != maxp && <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> != minp) | ||
212 | <a name="l00140"></a>00140 out += <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
213 | <a name="l00141"></a>00141 <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> != maxp && l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a> != minp) | ||
214 | <a name="l00142"></a>00142 out += l.<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
215 | <a name="l00143"></a>00143 <span class="keywordflow">if</span> (l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> != maxp && l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a> != minp) | ||
216 | <a name="l00144"></a>00144 out += l.<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
217 | <a name="l00145"></a>00145 out.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a> = (T)(out.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a>/2); | ||
218 | <a name="l00146"></a>00146 out.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a> = (T)(out.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a>/2); | ||
219 | <a name="l00147"></a>00147 } | ||
220 | <a name="l00148"></a>00148 | ||
221 | <a name="l00149"></a>00149 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// coincident</span> | ||
222 | <a name="l00150"></a>00150 } | ||
223 | <a name="l00151"></a>00151 | ||
224 | <a name="l00152"></a>00152 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// parallel</span> | ||
225 | <a name="l00153"></a>00153 } | ||
226 | <a name="l00154"></a>00154 | ||
227 | <a name="l00155"></a>00155 <span class="comment">// Get the point of intersection on this line, checking that</span> | ||
228 | <a name="l00156"></a>00156 <span class="comment">// it is within the line segment.</span> | ||
229 | <a name="l00157"></a>00157 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> uA = numeratorA / commonDenominator; | ||
230 | <a name="l00158"></a>00158 <span class="keywordflow">if</span>(checkOnlySegments && (uA < 0.f || uA > 1.f) ) | ||
231 | <a name="l00159"></a>00159 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// Outside the line segment</span> | ||
232 | <a name="l00160"></a>00160 | ||
233 | <a name="l00161"></a>00161 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> uB = numeratorB / commonDenominator; | ||
234 | <a name="l00162"></a>00162 <span class="keywordflow">if</span>(checkOnlySegments && (uB < 0.f || uB > 1.f)) | ||
235 | <a name="l00163"></a>00163 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// Outside the line segment</span> | ||
236 | <a name="l00164"></a>00164 | ||
237 | <a name="l00165"></a>00165 <span class="comment">// Calculate the intersection point.</span> | ||
238 | <a name="l00166"></a>00166 out.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a> = (T)(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X + uA * (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X)); | ||
239 | <a name="l00167"></a>00167 out.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a> = (T)(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y + uA * (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)); | ||
240 | <a name="l00168"></a>00168 <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
241 | <a name="l00169"></a>00169 } | ||
242 | <a name="l00170"></a>00170 | ||
243 | <a name="l00172"></a>00172 | ||
244 | <a name="l00173"></a><a class="code" href="classirr_1_1core_1_1line2d.html#aa504bac64b0ccd56786d6179809ecdd9">00173</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#aa504bac64b0ccd56786d6179809ecdd9" title="Get unit vector of the line.">getUnitVector</a>()<span class="keyword"> const</span> | ||
245 | <a name="l00174"></a>00174 <span class="keyword"> </span>{ | ||
246 | <a name="l00175"></a>00175 T len = (T)(1.0 / <a class="code" href="classirr_1_1core_1_1line2d.html#a2eb306d0e3db94712ece741bfadbfa55" title="Get length of line.">getLength</a>()); | ||
247 | <a name="l00176"></a>00176 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>((<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) * len, (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y) * len); | ||
248 | <a name="l00177"></a>00177 } | ||
249 | <a name="l00178"></a>00178 | ||
250 | <a name="l00180"></a>00180 | ||
251 | <a name="l00182"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a0f5dbd437c10e127d2797dd002ed3f98">00182</a> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="classirr_1_1core_1_1line2d.html#a0f5dbd437c10e127d2797dd002ed3f98" title="Get angle between this line and given line.">getAngleWith</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<T></a>& l)<span class="keyword"> const</span> | ||
252 | <a name="l00183"></a>00183 <span class="keyword"> </span>{ | ||
253 | <a name="l00184"></a>00184 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> vect = <a class="code" href="classirr_1_1core_1_1line2d.html#af6df3035ac8f217f86106ea88cc2e941" title="Get the vector of the line.">getVector</a>(); | ||
254 | <a name="l00185"></a>00185 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> vect2 = l.<a class="code" href="classirr_1_1core_1_1line2d.html#af6df3035ac8f217f86106ea88cc2e941" title="Get the vector of the line.">getVector</a>(); | ||
255 | <a name="l00186"></a>00186 <span class="keywordflow">return</span> vect.<a class="code" href="classirr_1_1core_1_1vector2d.html#a581ab3975900d5af8d4c7517738beba2" title="Calculates the angle between this vector and another one in degree.">getAngleWith</a>(vect2); | ||
256 | <a name="l00187"></a>00187 } | ||
257 | <a name="l00188"></a>00188 | ||
258 | <a name="l00190"></a>00190 | ||
259 | <a name="l00192"></a><a class="code" href="classirr_1_1core_1_1line2d.html#ae9c006816863a6ec0e0eda497bc2ba96">00192</a> T <a class="code" href="classirr_1_1core_1_1line2d.html#ae9c006816863a6ec0e0eda497bc2ba96" title="Tells us if the given point lies to the left, right, or on the line.">getPointOrientation</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point)<span class="keyword"> const</span> | ||
260 | <a name="l00193"></a>00193 <span class="keyword"> </span>{ | ||
261 | <a name="l00194"></a>00194 <span class="keywordflow">return</span> ( (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) * (point.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a> - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y) - | ||
262 | <a name="l00195"></a>00195 (point.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a> - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X) * (<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y - <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y) ); | ||
263 | <a name="l00196"></a>00196 } | ||
264 | <a name="l00197"></a>00197 | ||
265 | <a name="l00199"></a>00199 | ||
266 | <a name="l00200"></a><a class="code" href="classirr_1_1core_1_1line2d.html#ad30c08c673c12674d29a942b657b9457">00200</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1line2d.html#ad30c08c673c12674d29a942b657b9457" title="Check if the given point is a member of the line.">isPointOnLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point)<span class="keyword"> const</span> | ||
267 | <a name="l00201"></a>00201 <span class="keyword"> </span>{ | ||
268 | <a name="l00202"></a>00202 T d = <a class="code" href="classirr_1_1core_1_1line2d.html#ae9c006816863a6ec0e0eda497bc2ba96" title="Tells us if the given point lies to the left, right, or on the line.">getPointOrientation</a>(point); | ||
269 | <a name="l00203"></a>00203 <span class="keywordflow">return</span> (d == 0 && point.<a class="code" href="classirr_1_1core_1_1vector2d.html#adc8bba9dfd48218d083dcbe88bf98da0" title="Returns if this vector interpreted as a point is on a line between two other points.">isBetweenPoints</a>(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>, <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>)); | ||
270 | <a name="l00204"></a>00204 } | ||
271 | <a name="l00205"></a>00205 | ||
272 | <a name="l00207"></a>00207 | ||
273 | <a name="l00208"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a44e00a0ecc9604954f7b5507a3b1e067">00208</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1line2d.html#a44e00a0ecc9604954f7b5507a3b1e067" title="Check if the given point is between start and end of the line.">isPointBetweenStartAndEnd</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point)<span class="keyword"> const</span> | ||
274 | <a name="l00209"></a>00209 <span class="keyword"> </span>{ | ||
275 | <a name="l00210"></a>00210 <span class="keywordflow">return</span> point.<a class="code" href="classirr_1_1core_1_1vector2d.html#adc8bba9dfd48218d083dcbe88bf98da0" title="Returns if this vector interpreted as a point is on a line between two other points.">isBetweenPoints</a>(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>, <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>); | ||
276 | <a name="l00211"></a>00211 } | ||
277 | <a name="l00212"></a>00212 | ||
278 | <a name="l00214"></a>00214 | ||
279 | <a name="l00216"></a><a class="code" href="classirr_1_1core_1_1line2d.html#acf6060494506a97e09052e661f1b6014">00216</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#acf6060494506a97e09052e661f1b6014" title="Get the closest point on this line to a point.">getClosestPoint</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>& point, <span class="keywordtype">bool</span> checkOnlySegments=<span class="keyword">true</span>)<span class="keyword"> const</span> | ||
280 | <a name="l00217"></a>00217 <span class="keyword"> </span>{ | ||
281 | <a name="l00218"></a>00218 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<f64></a> c((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)(point.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a>-<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X), (<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)(point.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a>- <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)); | ||
282 | <a name="l00219"></a>00219 <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<f64></a> v((<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a>)(<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X-<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</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_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y-<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y)); | ||
283 | <a name="l00220"></a>00220 <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> d = v.<a class="code" href="classirr_1_1core_1_1vector2d.html#ad4c3614d12e2517223349a31632007ed" title="Gets the length of the vector.">getLength</a>(); | ||
284 | <a name="l00221"></a>00221 <span class="keywordflow">if</span> ( d == 0 ) <span class="comment">// can't tell much when the line is just a single point</span> | ||
285 | <a name="l00222"></a>00222 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
286 | <a name="l00223"></a>00223 v /= d; | ||
287 | <a name="l00224"></a>00224 <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> t = v.<a class="code" href="classirr_1_1core_1_1vector2d.html#a3899c231259a77c4aae6fec8ed72a6bc" title="Get the dot product of this vector with another.">dotProduct</a>(c); | ||
288 | <a name="l00225"></a>00225 | ||
289 | <a name="l00226"></a>00226 <span class="keywordflow">if</span> ( checkOnlySegments ) | ||
290 | <a name="l00227"></a>00227 { | ||
291 | <a name="l00228"></a>00228 <span class="keywordflow">if</span> (t < 0) <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>((T)<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X, (T)<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y); | ||
292 | <a name="l00229"></a>00229 <span class="keywordflow">if</span> (t > d) <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>((T)<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.X, (T)<a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>.Y); | ||
293 | <a name="l00230"></a>00230 } | ||
294 | <a name="l00231"></a>00231 | ||
295 | <a name="l00232"></a>00232 v *= t; | ||
296 | <a name="l00233"></a>00233 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a>((T)(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.X + v.<a class="code" href="classirr_1_1core_1_1vector2d.html#a8fabb0d10a3dd33b407b63bb3539be4d" title="X coordinate of vector.">X</a>), (T)(<a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>.Y + v.<a class="code" href="classirr_1_1core_1_1vector2d.html#aa4d36f518d3fc35a7aafcea33a31f76c" title="Y coordinate of vector.">Y</a>)); | ||
297 | <a name="l00234"></a>00234 } | ||
298 | <a name="l00235"></a>00235 | ||
299 | <a name="l00237"></a><a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8">00237</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#ae9a3be281b33b15eb7de868b51651ad8" title="Start point of the line.">start</a>; | ||
300 | <a name="l00239"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863">00239</a> <a class="code" href="classirr_1_1core_1_1vector2d.html" title="2d vector template class with lots of operators and methods.">vector2d<T></a> <a class="code" href="classirr_1_1core_1_1line2d.html#a339c443c3be2c006ac2f616a773f2863" title="End point of the line.">end</a>; | ||
301 | <a name="l00240"></a>00240 }; | ||
302 | <a name="l00241"></a>00241 | ||
303 | <a name="l00242"></a>00242 <span class="comment">// partial specialization to optimize <f32> lines (avoiding casts)</span> | ||
304 | <a name="l00243"></a>00243 <span class="keyword">template</span> <> | ||
305 | <a name="l00244"></a><a class="code" href="classirr_1_1core_1_1line2d.html#a8768141176461ebf0f49d64182108e6e">00244</a> <span class="keyword">inline</span> <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a> <a class="code" href="classirr_1_1core_1_1line2d.html#acf6060494506a97e09052e661f1b6014" title="Get the closest point on this line to a point.">line2d<irr::f32>::getClosestPoint</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a>& point, <span class="keywordtype">bool</span> checkOnlySegments)<span class="keyword"> const</span> | ||
306 | <a name="l00245"></a>00245 <span class="keyword"> </span>{ | ||
307 | <a name="l00246"></a>00246 <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a> c = point - start; | ||
308 | <a name="l00247"></a>00247 <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a> v = end - start; | ||
309 | <a name="l00248"></a>00248 <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>)v.<a class="code" href="classirr_1_1core_1_1vector2d.html#ad4c3614d12e2517223349a31632007ed" title="Gets the length of the vector.">getLength</a>(); | ||
310 | <a name="l00249"></a>00249 <span class="keywordflow">if</span> ( d == 0 ) <span class="comment">// can't tell much when the line is just a single point</span> | ||
311 | <a name="l00250"></a>00250 <span class="keywordflow">return</span> start; | ||
312 | <a name="l00251"></a>00251 v /= d; | ||
313 | <a name="l00252"></a>00252 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> t = v.<a class="code" href="classirr_1_1core_1_1vector2d.html#a3899c231259a77c4aae6fec8ed72a6bc" title="Get the dot product of this vector with another.">dotProduct</a>(c); | ||
314 | <a name="l00253"></a>00253 | ||
315 | <a name="l00254"></a>00254 <span class="keywordflow">if</span> ( checkOnlySegments ) | ||
316 | <a name="l00255"></a>00255 { | ||
317 | <a name="l00256"></a>00256 <span class="keywordflow">if</span> (t < 0) <span class="keywordflow">return</span> start; | ||
318 | <a name="l00257"></a>00257 <span class="keywordflow">if</span> (t > d) <span class="keywordflow">return</span> end; | ||
319 | <a name="l00258"></a>00258 } | ||
320 | <a name="l00259"></a>00259 | ||
321 | <a name="l00260"></a>00260 v *= t; | ||
322 | <a name="l00261"></a>00261 <span class="keywordflow">return</span> start + v; | ||
323 | <a name="l00262"></a>00262 } | ||
324 | <a name="l00263"></a>00263 | ||
325 | <a name="l00264"></a>00264 | ||
326 | <a name="l00266"></a><a class="code" href="namespaceirr_1_1core.html#a19bbe2f8741053a37be916e9ea42e456">00266</a> <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<f32></a> <a class="code" href="namespaceirr_1_1core.html#a19bbe2f8741053a37be916e9ea42e456" title="Typedef for an f32 line.">line2df</a>; | ||
327 | <a name="l00268"></a><a class="code" href="namespaceirr_1_1core.html#a5df3909d20023818270e81c64a24326c">00268</a> <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1line2d.html" title="2D line between two points with intersection methods.">line2d<s32></a> <a class="code" href="namespaceirr_1_1core.html#a5df3909d20023818270e81c64a24326c" title="Typedef for an integer line.">line2di</a>; | ||
328 | <a name="l00269"></a>00269 | ||
329 | <a name="l00270"></a>00270 } <span class="comment">// end namespace core</span> | ||
330 | <a name="l00271"></a>00271 } <span class="comment">// end namespace irr</span> | ||
331 | <a name="l00272"></a>00272 | ||
332 | <a name="l00273"></a>00273 <span class="preprocessor">#endif</span> | ||
333 | <a name="l00274"></a>00274 <span class="preprocessor"></span> | ||
334 | </pre></div></div> | ||
335 | </div> | ||
336 | <div id="nav-path" class="navpath"> | ||
337 | <ul> | ||
338 | <li class="navelem"><a class="el" href="line2d_8h.html">line2d.h</a> </li> | ||
339 | <!-- window showing the filter options --> | ||
340 | <div id="MSearchSelectWindow" | ||
341 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
342 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
343 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
344 | <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> | ||
345 | |||
346 | <!-- iframe showing the search results (closed by default) --> | ||
347 | <div id="MSearchResultsWindow"> | ||
348 | <iframe src="javascript:void(0)" frameborder="0" | ||
349 | name="MSearchResults" id="MSearchResults"> | ||
350 | </iframe> | ||
351 | </div> | ||
352 | |||
353 | |||
354 | <li class="footer"> | ||
355 | <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht | ||
356 | Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:00 for Irrlicht 3D Engine by | ||
357 | <a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li> | ||
358 | </ul> | ||
359 | </div> | ||
360 | |||
361 | |||
362 | </body> | ||
363 | </html> | ||