<!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>Crystal Space 1.2.1: csMath2 Class Reference (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="classes.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="classes.html"><span>Alphabetical List</span></a></li> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <h1>csMath2 Class Reference<br> <small> [<a class="el" href="group__geom__utils.html">Geometry utilities</a>]</small> </h1><!-- doxytag: class="csMath2" -->Various functions in 2D, such as 2D vector functions. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="math2d_8h-source.html">csgeom/math2d.h</a>></code> <p> <p> <a href="classcsMath2-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static float </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#b17722b23834f6066c18e49496356bd1">Area2</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &a, const <a class="el" href="classcsVector2.html">csVector2</a> &b, const <a class="el" href="classcsVector2.html">csVector2</a> &c)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates 2 x the area of a given triangle. <a href="#b17722b23834f6066c18e49496356bd1"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#e6c5a2ed582c67ddb95a71e069e442ab">InPoly2D</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &v, <a class="el" href="classcsVector2.html">csVector2</a> *P, int n, <a class="el" href="classcsBox2.html">csBox2</a> *bounding_box)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates whether a vector lies inside a given 2D polygon. <a href="#e6c5a2ed582c67ddb95a71e069e442ab"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static float </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#c49bb16aa194878371dfcf6db75af6ed">Left</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &a, const <a class="el" href="classcsVector2.html">csVector2</a> &b, const <a class="el" href="classcsVector2.html">csVector2</a> &c)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates whether a point lies to the left of a given line. <a href="#c49bb16aa194878371dfcf6db75af6ed"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#5d065e3215ccd7e94fa3a5d8f3b86748">PlanesClose</a> (const <a class="el" href="classcsPlane2.html">csPlane2</a> &p1, const <a class="el" href="classcsPlane2.html">csPlane2</a> &p2)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check if two planes are close together. <a href="#5d065e3215ccd7e94fa3a5d8f3b86748"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#58c3e6d161fac12f3269a7182e98c1e3">PlanesEqual</a> (const <a class="el" href="classcsPlane2.html">csPlane2</a> &p1, const <a class="el" href="classcsPlane2.html">csPlane2</a> &p2)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check if two planes are almost equal. <a href="#58c3e6d161fac12f3269a7182e98c1e3"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static float </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#91dd6b806c11853408a9e88847feb66e">Right</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &a, const <a class="el" href="classcsVector2.html">csVector2</a> &b, const <a class="el" href="classcsVector2.html">csVector2</a> &c)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates whether a point lies to the right of a given line. <a href="#91dd6b806c11853408a9e88847feb66e"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#82dcbfb44a824cd8f979f92b2f129705">Visible</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &p, const <a class="el" href="classcsPlane2.html">csPlane2</a> &pl)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check if the plane is visible from the given point. <a href="#82dcbfb44a824cd8f979f92b2f129705"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#18413e5bd1416df9c1499b05043c9199">WhichSide2D</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &v, const <a class="el" href="classcsSegment2.html">csSegment2</a> &s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates which side of a line a given point is on. <a href="#18413e5bd1416df9c1499b05043c9199"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="classcsMath2.html#827a71523cc957bc066adfeb2b7ee35f">WhichSide2D</a> (const <a class="el" href="classcsVector2.html">csVector2</a> &v, const <a class="el" href="classcsVector2.html">csVector2</a> &s1, const <a class="el" href="classcsVector2.html">csVector2</a> &s2)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Calculates which side of a line a given point is on. <a href="#827a71523cc957bc066adfeb2b7ee35f"></a><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> Various functions in 2D, such as 2D vector functions. <p> This is a static class and contains only static member functions. <p>Definition at line <a class="el" href="math2d_8h-source.html#l00044">44</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="b17722b23834f6066c18e49496356bd1"></a><!-- doxytag: member="csMath2::Area2" ref="b17722b23834f6066c18e49496356bd1" args="(const csVector2 &a, const csVector2 &b, const csVector2 &c)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static float csMath2::Area2 </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>a</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>b</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>c</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates 2 x the area of a given triangle. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>twice the signed area of the triangle determined by a,b,c, positive if a,b,c are oriented ccw, and negative if cw. </dd></dl> <p>Definition at line <a class="el" href="math2d_8h-source.html#l00090">90</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <p>References <a class="el" href="vector2_8h-source.html#l00041">csVector2::x</a>, and <a class="el" href="vector2_8h-source.html#l00043">csVector2::y</a>.</p> </div> </div><p> <a class="anchor" name="e6c5a2ed582c67ddb95a71e069e442ab"></a><!-- doxytag: member="csMath2::InPoly2D" ref="e6c5a2ed582c67ddb95a71e069e442ab" args="(const csVector2 &v, csVector2 *P, int n, csBox2 *bounding_box)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int csMath2::InPoly2D </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>v</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classcsVector2.html">csVector2</a> * </td> <td class="paramname"> <em>P</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>n</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classcsBox2.html">csBox2</a> * </td> <td class="paramname"> <em>bounding_box</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates whether a vector lies inside a given 2D polygon. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>CS_POLY_IN, CS_POLY_OUT, or CS_POLY_ON for this vector with respect to the given polygon. The polygon is given as an array of 2D vectors with a bounding box. WARNING: does no safety checking for P or bounding_box. </dd></dl> </div> </div><p> <a class="anchor" name="c49bb16aa194878371dfcf6db75af6ed"></a><!-- doxytag: member="csMath2::Left" ref="c49bb16aa194878371dfcf6db75af6ed" args="(const csVector2 &a, const csVector2 &b, const csVector2 &c)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static float csMath2::Left </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>a</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>b</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>c</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates whether a point lies to the left of a given line. <p> Returns true iff c is strictly to the left of the directed line through a to b. <p>Definition at line <a class="el" href="math2d_8h-source.html#l00117">117</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> </div> </div><p> <a class="anchor" name="5d065e3215ccd7e94fa3a5d8f3b86748"></a><!-- doxytag: member="csMath2::PlanesClose" ref="5d065e3215ccd7e94fa3a5d8f3b86748" args="(const csPlane2 &p1, const csPlane2 &p2)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool csMath2::PlanesClose </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsPlane2.html">csPlane2</a> & </td> <td class="paramname"> <em>p1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsPlane2.html">csPlane2</a> & </td> <td class="paramname"> <em>p2</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Check if two planes are close together. <p> Two planes are close if there are almost equal OR if the normalized versions are almost equal. </div> </div><p> <a class="anchor" name="58c3e6d161fac12f3269a7182e98c1e3"></a><!-- doxytag: member="csMath2::PlanesEqual" ref="58c3e6d161fac12f3269a7182e98c1e3" args="(const csPlane2 &p1, const csPlane2 &p2)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool csMath2::PlanesEqual </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsPlane2.html">csPlane2</a> & </td> <td class="paramname"> <em>p1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsPlane2.html">csPlane2</a> & </td> <td class="paramname"> <em>p2</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Check if two planes are almost equal. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>true iff each component of the plane equation for one plane is within .001 of the corresponding component of the other plane. </dd></dl> <p>Definition at line <a class="el" href="math2d_8h-source.html#l00138">138</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <p>References <a class="el" href="math3d__d_8h-source.html#l00036">ABS</a>, <a class="el" href="plane2_8h-source.html#l00055">csPlane2::CC</a>, and <a class="el" href="plane2_8h-source.html#l00052">csPlane2::norm</a>.</p> </div> </div><p> <a class="anchor" name="91dd6b806c11853408a9e88847feb66e"></a><!-- doxytag: member="csMath2::Right" ref="91dd6b806c11853408a9e88847feb66e" args="(const csVector2 &a, const csVector2 &b, const csVector2 &c)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static float csMath2::Right </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>a</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>b</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>c</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates whether a point lies to the right of a given line. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>true iff c is strictly to the right of the directed line through a to b. </dd></dl> <p>Definition at line <a class="el" href="math2d_8h-source.html#l00105">105</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> </div> </div><p> <a class="anchor" name="82dcbfb44a824cd8f979f92b2f129705"></a><!-- doxytag: member="csMath2::Visible" ref="82dcbfb44a824cd8f979f92b2f129705" args="(const csVector2 &p, const csPlane2 &pl)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool csMath2::Visible </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsPlane2.html">csPlane2</a> & </td> <td class="paramname"> <em>pl</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Check if the plane is visible from the given point. <p> This function does a back-face culling test to see whether the front face of plane pl is visible from point p. <p>Definition at line <a class="el" href="math2d_8h-source.html#l00129">129</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <p>References <a class="el" href="plane2_8h-source.html#l00118">csPlane2::Classify()</a>.</p> </div> </div><p> <a class="anchor" name="18413e5bd1416df9c1499b05043c9199"></a><!-- doxytag: member="csMath2::WhichSide2D" ref="18413e5bd1416df9c1499b05043c9199" args="(const csVector2 &v, const csSegment2 &s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int csMath2::WhichSide2D </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>v</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsSegment2.html">csSegment2</a> & </td> <td class="paramname"> <em>s</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates which side of a line a given point is on. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>-1 if point v is left of line segment 'seg' 1 if point v is right of segment 'seg' or 0 if point v lies on segment 'seg'. </dd></dl> <p>Definition at line <a class="el" href="math2d_8h-source.html#l00069">69</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <p>References <a class="el" href="segment_8h-source.html#l00067">csSegment2::End()</a>, and <a class="el" href="segment_8h-source.html#l00064">csSegment2::Start()</a>.</p> </div> </div><p> <a class="anchor" name="827a71523cc957bc066adfeb2b7ee35f"></a><!-- doxytag: member="csMath2::WhichSide2D" ref="827a71523cc957bc066adfeb2b7ee35f" args="(const csVector2 &v, const csVector2 &s1, const csVector2 &s2)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int csMath2::WhichSide2D </td> <td>(</td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>v</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>s1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classcsVector2.html">csVector2</a> & </td> <td class="paramname"> <em>s2</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline, static]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Calculates which side of a line a given point is on. <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd>-1 if point v is left of line segment 's1-s2', 1 if point v is right of segment 's1-s2' or 0 if point v lies on segment 's1-s2'. </dd></dl> <p>Definition at line <a class="el" href="math2d_8h-source.html#l00053">53</a> of file <a class="el" href="math2d_8h-source.html">math2d.h</a>.</p> <p>References <a class="el" href="vector2_8h-source.html#l00041">csVector2::x</a>, and <a class="el" href="vector2_8h-source.html#l00043">csVector2::y</a>.</p> </div> </div><p> <hr>The documentation for this class was generated from the following file:<ul> <li>csgeom/<a class="el" href="math2d_8h-source.html">math2d.h</a></ul> <hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>