<!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>GEOS: Angle.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>Angle.h</h1> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**********************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> * $Id: Angle.h 2809 2009-12-06 01:05:24Z mloskot $</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * GEOS - Geometry Engine Open Source</span> <a name="l00005"></a>00005 <span class="comment"> * http://geos.refractions.net</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2009 Sandro Santilli <strk@keybit.net></span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This is free software; you can redistribute and/or modify it under</span> <a name="l00010"></a>00010 <span class="comment"> * the terms of the GNU Lesser General Public Licence as published</span> <a name="l00011"></a>00011 <span class="comment"> * by the Free Software Foundation. </span> <a name="l00012"></a>00012 <span class="comment"> * See the COPYING file for more information.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> **********************************************************************</span> <a name="l00015"></a>00015 <span class="comment"> *</span> <a name="l00016"></a>00016 <span class="comment"> * Last port: algorithm/Angle.java rev. 1.6 (JTS-1.9)</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> **********************************************************************/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef GEOS_ALGORITHM_ANGLE_H</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define GEOS_ALGORITHM_ANGLE_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <geos/algorithm/CGAlgorithms.h></span> <span class="comment">// for constants</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="comment">// Forward declarations</span> <a name="l00026"></a><a class="code" href="namespacegeos.html">00026</a> <span class="keyword">namespace </span>geos { <a name="l00027"></a><a class="code" href="namespacegeos_1_1geom.html">00027</a> <span class="keyword">namespace </span>geom { <a name="l00028"></a>00028 <span class="keyword">class </span><a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>; <a name="l00029"></a>00029 } <a name="l00030"></a>00030 } <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">namespace </span>geos { <a name="l00033"></a><a class="code" href="namespacegeos_1_1algorithm.html">00033</a> <span class="keyword">namespace </span>algorithm { <span class="comment">// geos::algorithm</span> <a name="l00034"></a>00034 <a name="l00036"></a>00036 <span class="comment">//</span> <a name="l00039"></a><a class="code" href="classgeos_1_1algorithm_1_1Angle.html">00039</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classgeos_1_1algorithm_1_1Angle.html" title="Utility functions for working with angles.">Angle</a> <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <span class="keyword">public</span>: <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> PI_TIMES_2; <span class="comment">// 2.0 * PI;</span> <a name="l00044"></a>00044 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> PI_OVER_2; <span class="comment">// PI / 2.0;</span> <a name="l00045"></a>00045 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> PI_OVER_4; <span class="comment">// PI / 4.0;</span> <a name="l00046"></a>00046 <a name="l00048"></a><a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a735054807eb53b763cc95b8807642ee4">00048</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a735054807eb53b763cc95b8807642ee4" title="Constant representing counterclockwise orientation.">COUNTERCLOCKWISE</a> = CGAlgorithms::COUNTERCLOCKWISE; <a name="l00049"></a>00049 <a name="l00051"></a><a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a5429234c5e29ec6f331320d2883fdcf9">00051</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a5429234c5e29ec6f331320d2883fdcf9" title="Constant representing clockwise orientation.">CLOCKWISE</a> = CGAlgorithms::CLOCKWISE; <a name="l00052"></a>00052 <a name="l00054"></a><a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a7a698bf884ab1d18c9a2508b6ee67e8d">00054</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a7a698bf884ab1d18c9a2508b6ee67e8d" title="Constant representing no orientation.">NONE</a> = CGAlgorithms::COLLINEAR; <a name="l00055"></a>00055 <a name="l00057"></a>00057 <span class="comment">//</span> <a name="l00061"></a>00061 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a9ad83c541e462f7e87f4ccb4453aa6ef" title="Converts from radians to degrees.">toDegrees</a>(<span class="keywordtype">double</span> radians); <a name="l00062"></a>00062 <a name="l00064"></a>00064 <span class="comment">//</span> <a name="l00068"></a>00068 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#aeb3a56d12a8acaf534be3a9be1e66885" title="Converts from degrees to radians.">toRadians</a>(<span class="keywordtype">double</span> angleDegrees); <a name="l00069"></a>00069 <a name="l00073"></a>00073 <span class="comment">//</span> <a name="l00079"></a>00079 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a1510a92c16299367c5eeb982e1ac8209" title="Returns the angle of the vector from p0 to p1, relative to the positive X-axis.">angle</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p0, <a name="l00080"></a>00080 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p1); <a name="l00081"></a>00081 <a name="l00085"></a>00085 <span class="comment">//</span> <a name="l00091"></a>00091 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a1510a92c16299367c5eeb982e1ac8209" title="Returns the angle of the vector from p0 to p1, relative to the positive X-axis.">angle</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p); <a name="l00092"></a>00092 <a name="l00094"></a>00094 <span class="comment">//</span> <a name="l00104"></a>00104 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a8ead08040de37e155075f32439c7c3b3" title="Tests whether the angle between p0-p1-p2 is acute.">isAcute</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p0, <a name="l00105"></a>00105 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p1, <a name="l00106"></a>00106 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p2); <a name="l00107"></a>00107 <a name="l00109"></a>00109 <span class="comment">//</span> <a name="l00119"></a>00119 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a43f4f2031e72038b9e6931da59330954" title="Tests whether the angle between p0-p1-p2 is obtuse.">isObtuse</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p0, <a name="l00120"></a>00120 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p1, <a name="l00121"></a>00121 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p2); <a name="l00122"></a>00122 <a name="l00124"></a>00124 <span class="comment">//</span> <a name="l00132"></a>00132 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a37b9b3ef28618d538e459d9171331190" title="Returns the unoriented smallest angle between two vectors.">angleBetween</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tip1, <a name="l00133"></a>00133 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tail, <a name="l00134"></a>00134 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tip2); <a name="l00135"></a>00135 <a name="l00137"></a>00137 <span class="comment">//</span> <a name="l00148"></a>00148 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#af483a721dcfc7506f70d3085408f991c" title="Returns the oriented smallest angle between two vectors.">angleBetweenOriented</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tip1, <a name="l00149"></a>00149 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tail, <a name="l00150"></a>00150 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& tip2); <a name="l00151"></a>00151 <a name="l00153"></a>00153 <span class="comment">//</span> <a name="l00165"></a>00165 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a7d0faa9a4613314b73a211afbd475b2c" title="Computes the interior angle between two segments of a ring.">interiorAngle</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p0, <a name="l00166"></a>00166 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p1, <a name="l00167"></a>00167 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">geom::Coordinate</a>& p2); <a name="l00168"></a>00168 <a name="l00178"></a>00178 <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a4e25f61567be2ab03f92d36c775a9b9b" title="Returns whether an angle must turn clockwise or counterclockwise to overlap another angle...">getTurn</a>(<span class="keywordtype">double</span> ang1, <span class="keywordtype">double</span> ang2); <a name="l00179"></a>00179 <a name="l00187"></a>00187 <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#ad9ba65b29aaae8715cbf5d77dc7da077" title="Computes the normalized value of an angle, which is the equivalent angle in the range ( -Pi...">normalize</a>(<span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a1510a92c16299367c5eeb982e1ac8209" title="Returns the angle of the vector from p0 to p1, relative to the positive X-axis.">angle</a>); <a name="l00188"></a>00188 <a name="l00207"></a>00207 <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#aad6d7eb020edf56d3289bb58b7235997" title="Computes the normalized positive value of an angle, which is the equivalent angle in the range [ 0...">normalizePositive</a>(<span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a1510a92c16299367c5eeb982e1ac8209" title="Returns the angle of the vector from p0 to p1, relative to the positive X-axis.">angle</a>); <a name="l00208"></a>00208 <a name="l00209"></a>00209 <a name="l00211"></a>00211 <span class="comment">//</span> <a name="l00220"></a>00220 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classgeos_1_1algorithm_1_1Angle.html#a11b9891ce2c21eb4988bcb18ac245e25" title="Computes the unoriented smallest difference between two angles.">diff</a>(<span class="keywordtype">double</span> ang1, <span class="keywordtype">double</span> ang2); <a name="l00221"></a>00221 }; <a name="l00222"></a>00222 <a name="l00223"></a>00223 <a name="l00224"></a>00224 } <span class="comment">// namespace geos::algorithm</span> <a name="l00225"></a>00225 } <span class="comment">// namespace geos</span> <a name="l00226"></a>00226 <a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="preprocessor">#endif // GEOS_ALGORITHM_ANGLE_H</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Thu Jul 22 2010 for GEOS by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address> </body> </html>