<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Irrlicht Engine: plane3d.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table class="irrlicht" > <tr valign="middle"> <td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a> | <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a> | <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a> | <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF"> Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a> | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> Namespace Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td> </tr> </table> <!-- Generated by Doxygen 1.5.6 --> <h1>plane3d.h</h1><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-2009 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_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 "<a class="code" href="irr_math_8h.html">irrMath.h</a>"</span> <a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="vector3d_8h.html">vector3d.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><a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c">00017</a> <span class="keyword">enum</span> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c" 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#8a9999eb0d151083f48afe5f7d17a96c30484977b2480b6d6621114512d0b703">00019</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c30484977b2480b6d6621114512d0b703">ISREL3D_FRONT</a> = 0, <a name="l00020"></a><a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96ce3f42495b4c63c980c19a82a44b7746b">00020</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96ce3f42495b4c63c980c19a82a44b7746b">ISREL3D_BACK</a>, <a name="l00021"></a><a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c8a8605f10c124b4aca71783cc7735f0c">00021</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c8a8605f10c124b4aca71783cc7735f0c">ISREL3D_PLANAR</a>, <a name="l00022"></a><a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c26444234d5d37ce75f55249fffe25a61">00022</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c26444234d5d37ce75f55249fffe25a61">ISREL3D_SPANNING</a>, <a name="l00023"></a><a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c4a33464e7b7175c8614c5a6c9f9a3751">00023</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c4a33464e7b7175c8614c5a6c9f9a3751">ISREL3D_CLIPPED</a> <a name="l00024"></a>00024 }; <a name="l00025"></a>00025 <a name="l00027"></a>00027 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00028"></a><a class="code" href="classirr_1_1core_1_1plane3d.html">00028</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="l00029"></a>00029 { <a name="l00030"></a>00030 <span class="keyword">public</span>: <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">// Constructors</span> <a name="l00033"></a>00033 <a name="l00034"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">00034</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">plane3d</a>(): <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(0,1,0) { <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" 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<T></a>(0,0,0)); } <a name="l00035"></a>00035 <a name="l00036"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#83ddb90b9dd873dbd5ec1d1ae3d1eec2">00036</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">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<T></a>& 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<T></a>& <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>) : Normal(Normal) { <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane...">recalculateD</a>(MPoint); } <a name="l00037"></a>00037 <a name="l00038"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#f754b386af5b0296a47d97f1c9e39d55">00038</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">plane3d</a>(T px, T py, T pz, T nx, T ny, T nz) : <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(nx, ny, nz) { <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" 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<T></a>(px, py, pz)); } <a name="l00039"></a>00039 <a name="l00040"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#79aa2659564f880e71db761516d91b9e">00040</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">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<T></a>& 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<T></a>& 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<T></a>& point3) <a name="l00041"></a>00041 { <a class="code" href="classirr_1_1core_1_1plane3d.html#74c75911a10cc048c546ca5ea3646232">setPlane</a>(point1, point2, point3); } <a name="l00042"></a>00042 <a name="l00043"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#3f3171c926e019c47e56e2eb0ba9a9bf">00043</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#56ab7a294a2ae8570c719321ae356d27">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<T></a> & normal, <span class="keyword">const</span> T d) : <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>(normal), <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>(d) { } <a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="comment">// operators</span> <a name="l00046"></a>00046 <a name="l00047"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#4ea013907b2e44c91cc9defacb7a8d53">00047</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#4ea013907b2e44c91cc9defacb7a8d53">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<T></a>& other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>, other.<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) && <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>==other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>);} <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#1ef3ad54e652a02f3ea8c97884332f06">00049</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#1ef3ad54e652a02f3ea8c97884332f06">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<T></a>& other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !(*<span class="keyword">this</span> == other);} <a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="comment">// functions</span> <a name="l00052"></a>00052 <a name="l00053"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#74c75911a10cc048c546ca5ea3646232">00053</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#74c75911a10cc048c546ca5ea3646232">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<T></a>& 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<T></a>& nvector) <a name="l00054"></a>00054 { <a name="l00055"></a>00055 <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = nvector; <a name="l00056"></a>00056 <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane...">recalculateD</a>(point); <a name="l00057"></a>00057 } <a name="l00058"></a>00058 <a name="l00059"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#1f68018de37d6bc904c33192816b899b">00059</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#74c75911a10cc048c546ca5ea3646232">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<T></a>& nvect, T d) <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = nvect; <a name="l00062"></a>00062 <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> = d; <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00065"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#32ca1fd89b65630b4d77641005ffa94d">00065</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#74c75911a10cc048c546ca5ea3646232">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<T></a>& 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<T></a>& 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<T></a>& point3) <a name="l00066"></a>00066 { <a name="l00067"></a>00067 <span class="comment">// creates the plane from 3 memberpoints</span> <a name="l00068"></a>00068 <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> = (point2 - point1).crossProduct(point3 - point1); <a name="l00069"></a>00069 <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.normalize(); <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" title="Recalculates the distance from origin by applying a new member point to the plane...">recalculateD</a>(point1); <a name="l00072"></a>00072 } <a name="l00073"></a>00073 <a name="l00074"></a>00074 <a name="l00076"></a>00076 <a name="l00081"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#81c6fd667e7018805f9fb388721e2f30">00081</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& linePoint, <a name="l00082"></a>00082 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& lineVect, <a name="l00083"></a>00083 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outIntersection)<span class="keyword"> const</span> <a name="l00084"></a>00084 <span class="keyword"> </span>{ <a name="l00085"></a>00085 T t2 = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(lineVect); <a name="l00086"></a>00086 <a name="l00087"></a>00087 <span class="keywordflow">if</span> (t2 == 0) <a name="l00088"></a>00088 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00089"></a>00089 <a name="l00090"></a>00090 T t =- (<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(linePoint) + <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) / t2; <a name="l00091"></a>00091 outIntersection = linePoint + (lineVect * t); <a name="l00092"></a>00092 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <a name="l00096"></a>00096 <a name="l00102"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#572803fab72c142ad186b364da3193cb">00102</a> <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#572803fab72c142ad186b364da3193cb" 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<T></a>& linePoint1, <a name="l00103"></a>00103 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& linePoint2)<span class="keyword"> const</span> <a name="l00104"></a>00104 <span class="keyword"> </span>{ <a name="l00105"></a>00105 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> vect = linePoint2 - linePoint1; <a name="l00106"></a>00106 T t2 = (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(vect); <a name="l00107"></a>00107 <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)-((<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(linePoint1) + <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) / t2); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00111"></a>00111 <a name="l00116"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#9da6378730742e46bd1e73624b048641">00116</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#9da6378730742e46bd1e73624b048641" title="Get an intersection with a 3d line, limited between two 3d points.">getIntersectionWithLimitedLine</a>( <a name="l00117"></a>00117 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& linePoint1, <a name="l00118"></a>00118 <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& linePoint2, <a name="l00119"></a>00119 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outIntersection)<span class="keyword"> const</span> <a name="l00120"></a>00120 <span class="keyword"> </span>{ <a name="l00121"></a>00121 <span class="keywordflow">return</span> (<a class="code" href="classirr_1_1core_1_1plane3d.html#81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(linePoint1, linePoint2 - linePoint1, outIntersection) && <a name="l00122"></a>00122 outIntersection.<a class="code" href="classirr_1_1core_1_1vector3d.html#ce05ee3b68b47c2ec6baff0d9d64de98" title="Returns if this vector interpreted as a point is on a line between two other points...">isBetweenPoints</a>(linePoint1, linePoint2)); <a name="l00123"></a>00123 } <a name="l00124"></a>00124 <a name="l00126"></a>00126 <a name="l00130"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#0ef82b15cefb92fc8a1a93f2465c95cb">00130</a> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c" title="Enumeration for intersection relations of 3d objects.">EIntersectionRelation3D</a> <a class="code" href="classirr_1_1core_1_1plane3d.html#0ef82b15cefb92fc8a1a93f2465c95cb" 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<T></a>& point)<span class="keyword"> const</span> <a name="l00131"></a>00131 <span class="keyword"> </span>{ <a name="l00132"></a>00132 <span class="keyword">const</span> T d = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(point) + <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>; <a name="l00133"></a>00133 <a name="l00134"></a>00134 <span class="keywordflow">if</span> (d < -<a class="code" href="namespaceirr_1_1core.html#9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) <a name="l00135"></a>00135 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96ce3f42495b4c63c980c19a82a44b7746b">ISREL3D_BACK</a>; <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keywordflow">if</span> (d > <a class="code" href="namespaceirr_1_1core.html#9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) <a name="l00138"></a>00138 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c30484977b2480b6d6621114512d0b703">ISREL3D_FRONT</a>; <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#8a9999eb0d151083f48afe5f7d17a96c8a8605f10c124b4aca71783cc7735f0c">ISREL3D_PLANAR</a>; <a name="l00141"></a>00141 } <a name="l00142"></a>00142 <a name="l00144"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff">00144</a> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#65c1748d516ddc820b6b970f9367f1ff" 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<T></a>& MPoint) <a name="l00145"></a>00145 { <a name="l00146"></a>00146 <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> = - MPoint.<a class="code" href="classirr_1_1core_1_1vector3d.html#0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>); <a name="l00147"></a>00147 } <a name="l00148"></a>00148 <a name="l00150"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#e95084f1f1d942d2416aeaef247882fd">00150</a> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> <a class="code" href="classirr_1_1core_1_1plane3d.html#e95084f1f1d942d2416aeaef247882fd" title="Gets a member point of the plane.">getMemberPoint</a>()<span class="keyword"> const</span> <a name="l00151"></a>00151 <span class="keyword"> </span>{ <a name="l00152"></a>00152 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a> * -<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>; <a name="l00153"></a>00153 } <a name="l00154"></a>00154 <a name="l00156"></a>00156 <a name="l00157"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#a238ddaac4eb9d2781ccac678d594a78">00157</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#a238ddaac4eb9d2781ccac678d594a78" 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<T></a>& other)<span class="keyword"> const</span> <a name="l00158"></a>00158 <span class="keyword"> </span>{ <a name="l00159"></a>00159 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> cross = other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.crossProduct(<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>); <a name="l00160"></a>00160 <span class="keywordflow">return</span> cross.<a class="code" href="classirr_1_1core_1_1vector3d.html#b0f95138bd31d82b5486237c8e49a2d5" title="Get length of the vector.">getLength</a>() > <a class="code" href="namespaceirr_1_1core.html#9514dd34463a30102ef8836915cf9c4c">core::ROUNDING_ERROR_f32</a>; <a name="l00161"></a>00161 } <a name="l00162"></a>00162 <a name="l00164"></a>00164 <a name="l00168"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#8c611fd6346a361bbf34eb0e4fbd3fe0">00168</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#8c611fd6346a361bbf34eb0e4fbd3fe0" 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<T></a>& other, <a name="l00169"></a>00169 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outLinePoint, <a name="l00170"></a>00170 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outLineVect)<span class="keyword"> const</span> <a name="l00171"></a>00171 <span class="keyword"> </span>{ <a name="l00172"></a>00172 <span class="keyword">const</span> T fn00 = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.getLength(); <a name="l00173"></a>00173 <span class="keyword">const</span> T fn01 = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>); <a name="l00174"></a>00174 <span class="keyword">const</span> T fn11 = other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.getLength(); <a name="l00175"></a>00175 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> det = fn00*fn11 - fn01*fn01; <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="keywordflow">if</span> (fabs(det) < <a class="code" href="namespaceirr_1_1core.html#7b314c22d6804639cbcbce5231724f0b">ROUNDING_ERROR_f64</a> ) <a name="l00178"></a>00178 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> invdet = 1.0 / det; <a name="l00181"></a>00181 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> fc0 = (fn11*-<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> + fn01*other.<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) * invdet; <a name="l00182"></a>00182 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> fc1 = (fn00*-other.<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a> + fn01*<a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>) * invdet; <a name="l00183"></a>00183 <a name="l00184"></a>00184 outLineVect = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.crossProduct(other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>); <a name="l00185"></a>00185 outLinePoint = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>*(T)fc0 + other.<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>*(T)fc1; <a name="l00186"></a>00186 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <a name="l00190"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#42591d9bdd8dd03bb6b14836b6e5af7b">00190</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#42591d9bdd8dd03bb6b14836b6e5af7b" 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<T></a>& o1, <a name="l00191"></a>00191 <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<T></a>& o2, <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& outPoint)<span class="keyword"> const</span> <a name="l00192"></a>00192 <span class="keyword"> </span>{ <a name="l00193"></a>00193 <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> linePoint, lineVect; <a name="l00194"></a>00194 <span class="keywordflow">if</span> (<a class="code" href="classirr_1_1core_1_1plane3d.html#8c611fd6346a361bbf34eb0e4fbd3fe0" title="Intersects this plane with another.">getIntersectionWithPlane</a>(o1, linePoint, lineVect)) <a name="l00195"></a>00195 <span class="keywordflow">return</span> o2.<a class="code" href="classirr_1_1core_1_1plane3d.html#81c6fd667e7018805f9fb388721e2f30" title="Get an intersection with a 3d line.">getIntersectionWithLine</a>(linePoint, lineVect, outPoint); <a name="l00196"></a>00196 <a name="l00197"></a>00197 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a name="l00201"></a>00201 <a name="l00209"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#5b769b842600d377415d594f0db09a3e">00209</a> <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1plane3d.html#5b769b842600d377415d594f0db09a3e" title="Test if the triangle would be front or backfacing from any point.">isFrontFacing</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a>& lookDirection)<span class="keyword"> const</span> <a name="l00210"></a>00210 <span class="keyword"> </span>{ <a name="l00211"></a>00211 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> d = <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>.dotProduct(lookDirection); <a name="l00212"></a>00212 <span class="keywordflow">return</span> <a class="code" href="irr_math_8h.html#26bc42a9cc1fc775bc588052c32ff9a0">F32_LOWER_EQUAL_0</a> ( d ); <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00216"></a>00216 <a name="l00217"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#1877d6c25a437f2f00a664a1ac3d247f">00217</a> T <a class="code" href="classirr_1_1core_1_1plane3d.html#1877d6c25a437f2f00a664a1ac3d247f" 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<T></a>& point)<span class="keyword"> const</span> <a name="l00218"></a>00218 <span class="keyword"> </span>{ <a name="l00219"></a>00219 <span class="keywordflow">return</span> point.<a class="code" href="classirr_1_1core_1_1vector3d.html#0b247d39047c0e51ff16d0118bb396ab" title="Get the dot product with another vector.">dotProduct</a>(<a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>) + <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>; <a name="l00220"></a>00220 } <a name="l00221"></a>00221 <a name="l00223"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719">00223</a> <a class="code" href="classirr_1_1core_1_1vector3d.html" title="3d vector template class with lots of operators and methods.">vector3d<T></a> <a class="code" href="classirr_1_1core_1_1plane3d.html#932ca6e90e55cdceedb4f15ab706b719" title="Normal vector of the plane.">Normal</a>; <a name="l00224"></a>00224 <a name="l00226"></a><a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8">00226</a> T <a class="code" href="classirr_1_1core_1_1plane3d.html#fa304cf77cf1a3aae2351d5add5606a8" title="Distance from origin.">D</a>; <a name="l00227"></a>00227 }; <a name="l00228"></a>00228 <a name="l00229"></a>00229 <a name="l00231"></a><a class="code" href="namespaceirr_1_1core.html#e7491b7985dcb74b840bfcd9c054b232">00231</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<f32></a> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3df</a>; <a name="l00232"></a>00232 <a name="l00234"></a><a class="code" href="namespaceirr_1_1core.html#f977958e3f4578d8ef16178badb89f2d">00234</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<s32></a> <a class="code" href="classirr_1_1core_1_1plane3d.html" title="Template plane class with some intersection testing methods.">plane3di</a>; <a name="l00235"></a>00235 <a name="l00236"></a>00236 } <span class="comment">// end namespace core</span> <a name="l00237"></a>00237 } <span class="comment">// end namespace irr</span> <a name="l00238"></a>00238 <a name="l00239"></a>00239 <span class="preprocessor">#endif</span> <a name="l00240"></a>00240 <span class="preprocessor"></span> </pre></div></div> <hr size="1"> <address style="align: right;"> <small> </small> </address> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="0"> <div align="left"><small><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="irrlicht.png" alt="The Irrlicht Engine" align="middle" border=0 width=88 height=31></a></small></div></td> <td> <div align="left"><small><em><font size="2">The <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht Engine</a> Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:04 2010 by <a href="http://www.doxygen.org" target="_blank">Doxygen</a> (1.5.6)</font></em></small></div></td> </tr> </table> <address style="align: right;"> </address> </body> </html>