mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-14 06:20:26 +01:00
364 lines
76 KiB
HTML
364 lines
76 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<title>Irrlicht 3D Engine: line2d.h Source File</title>
|
||
|
|
||
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
$(document).ready(initResizable);
|
||
|
</script>
|
||
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="search/search.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="top"><!-- do not remove this div! -->
|
||
|
|
||
|
|
||
|
<div id="titlearea">
|
||
|
<table cellspacing="0" cellpadding="0">
|
||
|
<tbody>
|
||
|
<tr style="height: 56px;">
|
||
|
|
||
|
<td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
|
||
|
|
||
|
|
||
|
<td style="padding-left: 0.5em;">
|
||
|
<div id="projectname">Irrlicht 3D Engine
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</td>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
||
|
<span class="left">
|
||
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
alt=""/>
|
||
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
||
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
||
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
||
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
||
|
</span><span class="right">
|
||
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
||
|
</span>
|
||
|
</div>
|
||
|
</td>
|
||
|
|
||
|
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<!-- Generated by Doxygen 1.7.5.1 -->
|
||
|
<script type="text/javascript">
|
||
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||
|
</script>
|
||
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
</div>
|
||
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
<div id="nav-tree">
|
||
|
<div id="nav-tree-contents">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
class="ui-resizable-handle">
|
||
|
</div>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
initNavTree('line2d_8h.html','');
|
||
|
</script>
|
||
|
<div id="doc-content">
|
||
|
<div class="header">
|
||
|
<div class="headertitle">
|
||
|
<div class="title">line2d.h</div> </div>
|
||
|
</div>
|
||
|
<div class="contents">
|
||
|
<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>
|
||
|
<a name="l00002"></a>00002 <span class="comment">// This file is part of the "Irrlicht Engine".</span>
|
||
|
<a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span>
|
||
|
<a name="l00004"></a>00004
|
||
|
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_LINE_2D_H_INCLUDED__</span>
|
||
|
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_LINE_2D_H_INCLUDED__</span>
|
||
|
<a name="l00007"></a>00007 <span class="preprocessor"></span>
|
||
|
<a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="irr_types_8h.html">irrTypes.h</a>"</span>
|
||
|
<a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="vector2d_8h.html">vector2d.h</a>"</span>
|
||
|
<a name="l00010"></a>00010
|
||
|
<a name="l00011"></a>00011 <span class="keyword">namespace </span>irr
|
||
|
<a name="l00012"></a>00012 {
|
||
|
<a name="l00013"></a>00013 <span class="keyword">namespace </span>core
|
||
|
<a name="l00014"></a>00014 {
|
||
|
<a name="l00015"></a>00015
|
||
|
<a name="l00017"></a>00017 <span class="keyword">template</span> <<span class="keyword">class</span> T>
|
||
|
<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>
|
||
|
<a name="l00019"></a>00019 {
|
||
|
<a name="l00020"></a>00020 <span class="keyword">public</span>:
|
||
|
<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) {}
|
||
|
<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) {}
|
||
|
<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) {}
|
||
|
<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>) {}
|
||
|
<a name="l00029"></a>00029
|
||
|
<a name="l00030"></a>00030 <span class="comment">// operators</span>
|
||
|
<a name="l00031"></a>00031
|
||
|
<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); }
|
||
|
<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>; }
|
||
|
<a name="l00034"></a>00034
|
||
|
<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); }
|
||
|
<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>; }
|
||
|
<a name="l00037"></a>00037
|
||
|
<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>
|
||
|
<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>);}
|
||
|
<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>
|
||
|
<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>);}
|
||
|
<a name="l00042"></a>00042
|
||
|
<a name="l00043"></a>00043 <span class="comment">// functions</span>
|
||
|
<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);}
|
||
|
<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);}
|
||
|
<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>);}
|
||
|
<a name="l00050"></a>00050
|
||
|
<a name="l00052"></a>00052
|
||
|
<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>); }
|
||
|
<a name="l00054"></a>00054
|
||
|
<a name="l00056"></a>00056
|
||
|
<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>); }
|
||
|
<a name="l00058"></a>00058
|
||
|
<a name="l00060"></a>00060
|
||
|
<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>
|
||
|
<a name="l00062"></a>00062 <span class="keyword"> </span>{
|
||
|
<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;
|
||
|
<a name="l00064"></a>00064 }
|
||
|
<a name="l00065"></a>00065
|
||
|
<a name="l00067"></a>00067
|
||
|
<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); }
|
||
|
<a name="l00069"></a>00069
|
||
|
<a name="l00071"></a>00071
|
||
|
<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>
|
||
|
<a name="l00078"></a>00078 <span class="keyword"> </span>{
|
||
|
<a name="l00079"></a>00079 <span class="comment">// Uses the method given at:</span>
|
||
|
<a name="l00080"></a>00080 <span class="comment">// http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/</span>
|
||
|
<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) -
|
||
|
<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);
|
||
|
<a name="l00083"></a>00083
|
||
|
<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) -
|
||
|
<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);
|
||
|
<a name="l00086"></a>00086
|
||
|
<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) -
|
||
|
<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);
|
||
|
<a name="l00089"></a>00089
|
||
|
<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))
|
||
|
<a name="l00091"></a>00091 {
|
||
|
<a name="l00092"></a>00092 <span class="comment">// The lines are either coincident or parallel</span>
|
||
|
<a name="l00093"></a>00093 <span class="comment">// if both numerators are 0, the lines are coincident</span>
|
||
|
<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))
|
||
|
<a name="l00095"></a>00095 {
|
||
|
<a name="l00096"></a>00096 <span class="comment">// Try and find a common endpoint</span>
|
||
|
<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>)
|
||
|
<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>;
|
||
|
<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>)
|
||
|
<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>;
|
||
|
<a name="l00101"></a>00101 <span class="comment">// now check if the two segments are disjunct</span>
|
||
|
<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)
|
||
|
<a name="l00103"></a>00103 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
<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)
|
||
|
<a name="l00105"></a>00105 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
<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)
|
||
|
<a name="l00107"></a>00107 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
<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)
|
||
|
<a name="l00109"></a>00109 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
<a name="l00110"></a>00110 <span class="comment">// else the lines are overlapping to some extent</span>
|
||
|
<a name="l00111"></a>00111 <span class="keywordflow">else</span>
|
||
|
<a name="l00112"></a>00112 {
|
||
|
<a name="l00113"></a>00113 <span class="comment">// find the points which are not contributing to the</span>
|
||
|
<a name="l00114"></a>00114 <span class="comment">// common part</span>
|
||
|
<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;
|
||
|
<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;
|
||
|
<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))
|
||
|
<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>;
|
||
|
<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))
|
||
|
<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>;
|
||
|
<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))
|
||
|
<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>;
|
||
|
<a name="l00123"></a>00123 <span class="keywordflow">else</span>
|
||
|
<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>;
|
||
|
<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)))
|
||
|
<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>;
|
||
|
<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)))
|
||
|
<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>;
|
||
|
<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)))
|
||
|
<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>;
|
||
|
<a name="l00131"></a>00131 <span class="keywordflow">else</span>
|
||
|
<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>;
|
||
|
<a name="l00133"></a>00133
|
||
|
<a name="l00134"></a>00134 <span class="comment">// one line is contained in the other. Pick the center</span>
|
||
|
<a name="l00135"></a>00135 <span class="comment">// of the remaining points, which overlap for sure</span>
|
||
|
<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>();
|
||
|
<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)
|
||
|
<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>;
|
||
|
<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)
|
||
|
<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>;
|
||
|
<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)
|
||
|
<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>;
|
||
|
<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)
|
||
|
<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>;
|
||
|
<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);
|
||
|
<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);
|
||
|
<a name="l00147"></a>00147 }
|
||
|
<a name="l00148"></a>00148
|
||
|
<a name="l00149"></a>00149 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// coincident</span>
|
||
|
<a name="l00150"></a>00150 }
|
||
|
<a name="l00151"></a>00151
|
||
|
<a name="l00152"></a>00152 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// parallel</span>
|
||
|
<a name="l00153"></a>00153 }
|
||
|
<a name="l00154"></a>00154
|
||
|
<a name="l00155"></a>00155 <span class="comment">// Get the point of intersection on this line, checking that</span>
|
||
|
<a name="l00156"></a>00156 <span class="comment">// it is within the line segment.</span>
|
||
|
<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;
|
||
|
<a name="l00158"></a>00158 <span class="keywordflow">if</span>(checkOnlySegments && (uA < 0.f || uA > 1.f) )
|
||
|
<a name="l00159"></a>00159 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// Outside the line segment</span>
|
||
|
<a name="l00160"></a>00160
|
||
|
<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;
|
||
|
<a name="l00162"></a>00162 <span class="keywordflow">if</span>(checkOnlySegments && (uB < 0.f || uB > 1.f))
|
||
|
<a name="l00163"></a>00163 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// Outside the line segment</span>
|
||
|
<a name="l00164"></a>00164
|
||
|
<a name="l00165"></a>00165 <span class="comment">// Calculate the intersection point.</span>
|
||
|
<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));
|
||
|
<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));
|
||
|
<a name="l00168"></a>00168 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||
|
<a name="l00169"></a>00169 }
|
||
|
<a name="l00170"></a>00170
|
||
|
<a name="l00172"></a>00172
|
||
|
<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>
|
||
|
<a name="l00174"></a>00174 <span class="keyword"> </span>{
|
||
|
<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>());
|
||
|
<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);
|
||
|
<a name="l00177"></a>00177 }
|
||
|
<a name="l00178"></a>00178
|
||
|
<a name="l00180"></a>00180
|
||
|
<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>
|
||
|
<a name="l00183"></a>00183 <span class="keyword"> </span>{
|
||
|
<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>();
|
||
|
<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>();
|
||
|
<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);
|
||
|
<a name="l00187"></a>00187 }
|
||
|
<a name="l00188"></a>00188
|
||
|
<a name="l00190"></a>00190
|
||
|
<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>
|
||
|
<a name="l00193"></a>00193 <span class="keyword"> </span>{
|
||
|
<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) -
|
||
|
<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) );
|
||
|
<a name="l00196"></a>00196 }
|
||
|
<a name="l00197"></a>00197
|
||
|
<a name="l00199"></a>00199
|
||
|
<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>
|
||
|
<a name="l00201"></a>00201 <span class="keyword"> </span>{
|
||
|
<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);
|
||
|
<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>));
|
||
|
<a name="l00204"></a>00204 }
|
||
|
<a name="l00205"></a>00205
|
||
|
<a name="l00207"></a>00207
|
||
|
<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>
|
||
|
<a name="l00209"></a>00209 <span class="keyword"> </span>{
|
||
|
<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>);
|
||
|
<a name="l00211"></a>00211 }
|
||
|
<a name="l00212"></a>00212
|
||
|
<a name="l00214"></a>00214
|
||
|
<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>
|
||
|
<a name="l00217"></a>00217 <span class="keyword"> </span>{
|
||
|
<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));
|
||
|
<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));
|
||
|
<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>();
|
||
|
<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>
|
||
|
<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>;
|
||
|
<a name="l00223"></a>00223 v /= d;
|
||
|
<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);
|
||
|
<a name="l00225"></a>00225
|
||
|
<a name="l00226"></a>00226 <span class="keywordflow">if</span> ( checkOnlySegments )
|
||
|
<a name="l00227"></a>00227 {
|
||
|
<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);
|
||
|
<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);
|
||
|
<a name="l00230"></a>00230 }
|
||
|
<a name="l00231"></a>00231
|
||
|
<a name="l00232"></a>00232 v *= t;
|
||
|
<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>));
|
||
|
<a name="l00234"></a>00234 }
|
||
|
<a name="l00235"></a>00235
|
||
|
<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>;
|
||
|
<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>;
|
||
|
<a name="l00240"></a>00240 };
|
||
|
<a name="l00241"></a>00241
|
||
|
<a name="l00242"></a>00242 <span class="comment">// partial specialization to optimize <f32> lines (avoiding casts)</span>
|
||
|
<a name="l00243"></a>00243 <span class="keyword">template</span> <>
|
||
|
<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>
|
||
|
<a name="l00245"></a>00245 <span class="keyword"> </span>{
|
||
|
<a name="l00246"></a>00246 <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a> c = point - start;
|
||
|
<a name="l00247"></a>00247 <a class="code" href="classirr_1_1core_1_1vector2d.html">vector2df</a> v = end - start;
|
||
|
<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>();
|
||
|
<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>
|
||
|
<a name="l00250"></a>00250 <span class="keywordflow">return</span> start;
|
||
|
<a name="l00251"></a>00251 v /= d;
|
||
|
<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);
|
||
|
<a name="l00253"></a>00253
|
||
|
<a name="l00254"></a>00254 <span class="keywordflow">if</span> ( checkOnlySegments )
|
||
|
<a name="l00255"></a>00255 {
|
||
|
<a name="l00256"></a>00256 <span class="keywordflow">if</span> (t < 0) <span class="keywordflow">return</span> start;
|
||
|
<a name="l00257"></a>00257 <span class="keywordflow">if</span> (t > d) <span class="keywordflow">return</span> end;
|
||
|
<a name="l00258"></a>00258 }
|
||
|
<a name="l00259"></a>00259
|
||
|
<a name="l00260"></a>00260 v *= t;
|
||
|
<a name="l00261"></a>00261 <span class="keywordflow">return</span> start + v;
|
||
|
<a name="l00262"></a>00262 }
|
||
|
<a name="l00263"></a>00263
|
||
|
<a name="l00264"></a>00264
|
||
|
<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>;
|
||
|
<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>;
|
||
|
<a name="l00269"></a>00269
|
||
|
<a name="l00270"></a>00270 } <span class="comment">// end namespace core</span>
|
||
|
<a name="l00271"></a>00271 } <span class="comment">// end namespace irr</span>
|
||
|
<a name="l00272"></a>00272
|
||
|
<a name="l00273"></a>00273 <span class="preprocessor">#endif</span>
|
||
|
<a name="l00274"></a>00274 <span class="preprocessor"></span>
|
||
|
</pre></div></div>
|
||
|
</div>
|
||
|
<div id="nav-path" class="navpath">
|
||
|
<ul>
|
||
|
<li class="navelem"><a class="el" href="line2d_8h.html">line2d.h</a> </li>
|
||
|
<!-- window showing the filter options -->
|
||
|
<div id="MSearchSelectWindow"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </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>
|
||
|
|
||
|
<!-- iframe showing the search results (closed by default) -->
|
||
|
<div id="MSearchResultsWindow">
|
||
|
<iframe src="javascript:void(0)" frameborder="0"
|
||
|
name="MSearchResults" id="MSearchResults">
|
||
|
</iframe>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<li class="footer">
|
||
|
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
|
||
|
Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Tue Jan 19 2016 16:08:46 for Irrlicht 3D Engine by
|
||
|
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|