irrlicht/doc/html/plane3d_8h_source.html
2020-05-16 23:31:28 +02:00

319 lines
42 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: plane3d.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('plane3d_8h.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">plane3d.h</div> </div>
</div>
<div class="contents">
<a href="plane3d_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2002-2012 Nikolaus Gebhardt</span>
<a name="l00002"></a>00002 <span class="comment">// This file is part of the &quot;Irrlicht Engine&quot;.</span>
<a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span>
<a name="l00004"></a>00004
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_PLANE_3D_H_INCLUDED__</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_PLANE_3D_H_INCLUDED__</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="irr_math_8h.html">irrMath.h</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="vector3d_8h.html">vector3d.h</a>&quot;</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><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96c">00017</a> <span class="keyword">enum</span> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96c" title="Enumeration for intersection relations of 3d objects.">EIntersectionRelation3D</a>
<a name="l00018"></a>00018 {
<a name="l00019"></a><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca30484977b2480b6d6621114512d0b703">00019</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca30484977b2480b6d6621114512d0b703">ISREL3D_FRONT</a> = 0,
<a name="l00020"></a><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96cae3f42495b4c63c980c19a82a44b7746b">00020</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96cae3f42495b4c63c980c19a82a44b7746b">ISREL3D_BACK</a>,
<a name="l00021"></a><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca8a8605f10c124b4aca71783cc7735f0c">00021</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca8a8605f10c124b4aca71783cc7735f0c">ISREL3D_PLANAR</a>,
<a name="l00022"></a><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca26444234d5d37ce75f55249fffe25a61">00022</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca26444234d5d37ce75f55249fffe25a61">ISREL3D_SPANNING</a>,
<a name="l00023"></a><a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca4a33464e7b7175c8614c5a6c9f9a3751">00023</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca4a33464e7b7175c8614c5a6c9f9a3751">ISREL3D_CLIPPED</a>
<a name="l00024"></a>00024 };
<a name="l00025"></a>00025
<a name="l00027"></a>00027
<a name="l00032"></a>00032 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00033"></a><a class="code" href="classirr_1_1core_1_1plane3d.html">00033</a> <span class="keyword">class </span><a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d</a>
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035 <span class="keyword">public</span>:
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="comment">// Constructors</span>
<a name="l00038"></a>00038
<a name="l00039"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a56ab7a294a2ae8570c719321ae356d27">00039</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a56ab7a294a2ae8570c719321ae356d27">plane3d</a>(): <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(0,1,0) { <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>(0,0,0)); }
<a name="l00040"></a>00040
<a name="l00041"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a83ddb90b9dd873dbd5ec1d1ae3d1eec2">00041</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a83ddb90b9dd873dbd5ec1d1ae3d1eec2">plane3d</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; MPoint, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>) : Normal(Normal) { <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(MPoint); }
<a name="l00042"></a>00042
<a name="l00043"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#af754b386af5b0296a47d97f1c9e39d55">00043</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#af754b386af5b0296a47d97f1c9e39d55">plane3d</a>(T px, T py, T pz, T nx, T ny, T nz) : <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(nx, ny, nz) { <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(<a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>(px, py, pz)); }
<a name="l00044"></a>00044
<a name="l00045"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a79aa2659564f880e71db761516d91b9e">00045</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a56ab7a294a2ae8570c719321ae356d27">plane3d</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point1, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point2, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point3)
<a name="l00046"></a>00046 { <a class="code" href="classirr_1_1core_1_1plane3d.html#a74c75911a10cc048c546ca5ea3646232">setPlane</a>(point1, point2, point3); }
<a name="l00047"></a>00047
<a name="l00048"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a3f3171c926e019c47e56e2eb0ba9a9bf">00048</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a3f3171c926e019c47e56e2eb0ba9a9bf">plane3d</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> &amp; normal, <span class="keyword">const</span> T d) : <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(normal), <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>(d) { }
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="comment">// operators</span>
<a name="l00051"></a>00051
<a name="l00052"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a4ea013907b2e44c91cc9defacb7a8d53">00052</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a4ea013907b2e44c91cc9defacb7a8d53">operator==</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>, other.<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) &amp;&amp; <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>==other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);}
<a name="l00053"></a>00053
<a name="l00054"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a1ef3ad54e652a02f3ea8c97884332f06">00054</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a1ef3ad54e652a02f3ea8c97884332f06">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !(*<span class="keyword">this</span> == other);}
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="comment">// functions</span>
<a name="l00057"></a>00057
<a name="l00058"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a74c75911a10cc048c546ca5ea3646232">00058</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a74c75911a10cc048c546ca5ea3646232">setPlane</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; nvector)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = nvector;
<a name="l00061"></a>00061 <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(point);
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063
<a name="l00064"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a1f68018de37d6bc904c33192816b899b">00064</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a74c75911a10cc048c546ca5ea3646232">setPlane</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; nvect, T d)
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066 <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = nvect;
<a name="l00067"></a>00067 <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> = d;
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069
<a name="l00070"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a32ca1fd89b65630b4d77641005ffa94d">00070</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a74c75911a10cc048c546ca5ea3646232">setPlane</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point1, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point2, <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point3)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072 <span class="comment">// creates the plane from 3 memberpoints</span>
<a name="l00073"></a>00073 <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = (point2 - point1).crossProduct(point3 - point1);
<a name="l00074"></a>00074 <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.normalize();
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(point1);
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078
<a name="l00079"></a>00079
<a name="l00081"></a>00081
<a name="l00086"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a81c6fd667e7018805f9fb388721e2f30">00086</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint,
<a name="l00087"></a>00087 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; lineVect,
<a name="l00088"></a>00088 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outIntersection)<span class="keyword"> const</span>
<a name="l00089"></a>00089 <span class="keyword"> </span>{
<a name="l00090"></a>00090 T t2 = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(lineVect);
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keywordflow">if</span> (t2 == 0)
<a name="l00093"></a>00093 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00094"></a>00094
<a name="l00095"></a>00095 T t =- (<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(linePoint) + <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) / t2;
<a name="l00096"></a>00096 outIntersection = linePoint + (lineVect * t);
<a name="l00097"></a>00097 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099
<a name="l00101"></a>00101
<a name="l00107"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a572803fab72c142ad186b364da3193cb">00107</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a572803fab72c142ad186b364da3193cb" title="Get percentage of line between two points where an intersection with this plane happens.">getKnownIntersectionWithLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint1,
<a name="l00108"></a>00108 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint2)<span class="keyword"> const</span>
<a name="l00109"></a>00109 <span class="keyword"> </span>{
<a name="l00110"></a>00110 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> vect = linePoint2 - linePoint1;
<a name="l00111"></a>00111 T t2 = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(vect);
<a name="l00112"></a>00112 <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)-((<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(linePoint1) + <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) / t2);
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114
<a name="l00116"></a>00116
<a name="l00121"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a9da6378730742e46bd1e73624b048641">00121</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a9da6378730742e46bd1e73624b048641" title="Get an intersection with a 3d line, limited between two 3d points.">getIntersectionWithLimitedLine</a>(
<a name="l00122"></a>00122 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint1,
<a name="l00123"></a>00123 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; linePoint2,
<a name="l00124"></a>00124 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outIntersection)<span class="keyword"> const</span>
<a name="l00125"></a>00125 <span class="keyword"> </span>{
<a name="l00126"></a>00126 <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1plane3d.html#a81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(linePoint1, linePoint2 - linePoint1, outIntersection) &amp;&amp;
<a name="l00127"></a>00127 outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#ace05ee3b68b47c2ec6baff0d9d64de98" title="Returns if this vector interpreted as a point is on a line between two other points.">isBetweenPoints</a>(linePoint1, linePoint2));
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129
<a name="l00131"></a>00131
<a name="l00135"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a0ef82b15cefb92fc8a1a93f2465c95cb">00135</a> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96c" title="Enumeration for intersection relations of 3d objects.">EIntersectionRelation3D</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a0ef82b15cefb92fc8a1a93f2465c95cb" title="Classifies the relation of a point to this plane.">classifyPointRelation</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point)<span class="keyword"> const</span>
<a name="l00136"></a>00136 <span class="keyword"> </span>{
<a name="l00137"></a>00137 <span class="keyword">const</span> T d = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(point) + <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>;
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="keywordflow">if</span> (d &lt; -<a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>)
<a name="l00140"></a>00140 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96cae3f42495b4c63c980c19a82a44b7746b">ISREL3D_BACK</a>;
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keywordflow">if</span> (d &gt; <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>)
<a name="l00143"></a>00143 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca30484977b2480b6d6621114512d0b703">ISREL3D_FRONT</a>;
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a8a9999eb0d151083f48afe5f7d17a96ca8a8605f10c124b4aca71783cc7735f0c">ISREL3D_PLANAR</a>;
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147
<a name="l00149"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff">00149</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane.">recalculateD</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; MPoint)
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151 <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> = - MPoint.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153
<a name="l00155"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#ae95084f1f1d942d2416aeaef247882fd">00155</a> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#ae95084f1f1d942d2416aeaef247882fd" title="Gets a member point of the plane.">getMemberPoint</a>()<span class="keyword"> const</span>
<a name="l00156"></a>00156 <span class="keyword"> </span>{
<a name="l00157"></a>00157 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> * -<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>;
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159
<a name="l00161"></a>00161
<a name="l00162"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#aa238ddaac4eb9d2781ccac678d594a78">00162</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#aa238ddaac4eb9d2781ccac678d594a78" title="Tests if there is an intersection with the other plane.">existsIntersection</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; other)<span class="keyword"> const</span>
<a name="l00163"></a>00163 <span class="keyword"> </span>{
<a name="l00164"></a>00164 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> cross = other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.crossProduct(<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);
<a name="l00165"></a>00165 <span class="keywordflow">return</span> cross.<a class="code" href="classirr_1_1core_1_1vector3d.html#ab0f95138bd31d82b5486237c8e49a2d5" title="Get length of the vector.">getLength</a>() &gt; <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">core::ROUNDING_ERROR_f32</a>;
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167
<a name="l00169"></a>00169
<a name="l00173"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a8c611fd6346a361bbf34eb0e4fbd3fe0">00173</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a8c611fd6346a361bbf34eb0e4fbd3fe0" title="Intersects this plane with another.">getIntersectionWithPlane</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; other,
<a name="l00174"></a>00174 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outLinePoint,
<a name="l00175"></a>00175 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outLineVect)<span class="keyword"> const</span>
<a name="l00176"></a>00176 <span class="keyword"> </span>{
<a name="l00177"></a>00177 <span class="keyword">const</span> T fn00 = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.getLength();
<a name="l00178"></a>00178 <span class="keyword">const</span> T fn01 = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);
<a name="l00179"></a>00179 <span class="keyword">const</span> T fn11 = other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.getLength();
<a name="l00180"></a>00180 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> det = fn00*fn11 - fn01*fn01;
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="keywordflow">if</span> (fabs(det) &lt; <a class="code" href="namespaceirr_1_1core.html#a7b314c22d6804639cbcbce5231724f0b">ROUNDING_ERROR_f64</a> )
<a name="l00183"></a>00183 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00184"></a>00184
<a name="l00185"></a>00185 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> invdet = 1.0 / det;
<a name="l00186"></a>00186 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> fc0 = (fn11*-<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> + fn01*other.<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) * invdet;
<a name="l00187"></a>00187 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> fc1 = (fn00*-other.<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> + fn01*<a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) * invdet;
<a name="l00188"></a>00188
<a name="l00189"></a>00189 outLineVect = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.crossProduct(other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);
<a name="l00190"></a>00190 outLinePoint = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>*(T)fc0 + other.<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>*(T)fc1;
<a name="l00191"></a>00191 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193
<a name="l00195"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a42591d9bdd8dd03bb6b14836b6e5af7b">00195</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a42591d9bdd8dd03bb6b14836b6e5af7b" title="Get the intersection point with two other planes if there is one.">getIntersectionWithPlanes</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; o1,
<a name="l00196"></a>00196 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;T&gt;</a>&amp; o2, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; outPoint)<span class="keyword"> const</span>
<a name="l00197"></a>00197 <span class="keyword"> </span>{
<a name="l00198"></a>00198 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> linePoint, lineVect;
<a name="l00199"></a>00199 <span class="keywordflow">if</span> (<a class="code" href="classirr_1_1core_1_1plane3d.html#a8c611fd6346a361bbf34eb0e4fbd3fe0" title="Intersects this plane with another.">getIntersectionWithPlane</a>(o1, linePoint, lineVect))
<a name="l00200"></a>00200 <span class="keywordflow">return</span> o2.<a class="code" href="classirr_1_1core_1_1plane3d.html#a81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(linePoint, lineVect, outPoint);
<a name="l00201"></a>00201
<a name="l00202"></a>00202 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204
<a name="l00206"></a>00206
<a name="l00214"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a5b769b842600d377415d594f0db09a3e">00214</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a5b769b842600d377415d594f0db09a3e" title="Test if the triangle would be front or backfacing from any point.">isFrontFacing</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; lookDirection)<span class="keyword"> const</span>
<a name="l00215"></a>00215 <span class="keyword"> </span>{
<a name="l00216"></a>00216 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> d = <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(lookDirection);
<a name="l00217"></a>00217 <span class="keywordflow">return</span> <a class="code" href="irr_math_8h.html#a26bc42a9cc1fc775bc588052c32ff9a0">F32_LOWER_EQUAL_0</a> ( d );
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00221"></a>00221
<a name="l00222"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a1877d6c25a437f2f00a664a1ac3d247f">00222</a> T <a class="code" href="classirr_1_1core_1_1plane3d.html#a1877d6c25a437f2f00a664a1ac3d247f" title="Get the distance to a point.">getDistanceTo</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a>&amp; point)<span class="keyword"> const</span>
<a name="l00223"></a>00223 <span class="keyword"> </span>{
<a name="l00224"></a>00224 <span class="keywordflow">return</span> point.<a class="code" href="classirr_1_1core_1_1vector3d.html#a0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>) + <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>;
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226
<a name="l00228"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719">00228</a> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d&lt;T&gt;</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#a932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>;
<a name="l00229"></a>00229
<a name="l00231"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8">00231</a> T <a class="code" href="classirr_1_1core_1_1plane3d.html#afa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>;
<a name="l00232"></a>00232 };
<a name="l00233"></a>00233
<a name="l00234"></a>00234
<a name="l00236"></a><a class="code" href="namespaceirr_1_1core.html#ae7491b7985dcb74b840bfcd9c054b232">00236</a> <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1plane3d.html">plane3d&lt;f32&gt;</a> <a class="code" href="namespaceirr_1_1core.html#ae7491b7985dcb74b840bfcd9c054b232" title="Typedef for a f32 3d plane.">plane3df</a>;
<a name="l00237"></a>00237
<a name="l00239"></a><a class="code" href="namespaceirr_1_1core.html#af977958e3f4578d8ef16178badb89f2d">00239</a> <span class="keyword">typedef</span> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3d&lt;s32&gt;</a> <a class="code" href="namespaceirr_1_1core.html#af977958e3f4578d8ef16178badb89f2d" title="Typedef for an integer 3d plane.">plane3di</a>;
<a name="l00240"></a>00240
<a name="l00241"></a>00241 } <span class="comment">// end namespace core</span>
<a name="l00242"></a>00242 } <span class="comment">// end namespace irr</span>
<a name="l00243"></a>00243
<a name="l00244"></a>00244 <span class="preprocessor">#endif</span>
<a name="l00245"></a>00245 <span class="preprocessor"></span>
</pre></div></div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="plane3d_8h.html">plane3d.h</a> </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sat Jul 9 2016 18:18:20 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>