geometry/doc/doxygen_output/html/arithmetic_8hpp_source.html
Barend Gehrels 363580fbf6 Added old doxygen docs
[SVN r59777]
2010-02-20 15:57:12 +00:00

211 lines
19 KiB
HTML
Raw Blame History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Geometry (aka GGL, Generic Geometry Library)</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head>
<table cellpadding="2" width="100%">
<tbody>
<tr>
<td valign="top">
<img alt="Boost.Geometry" src="images/ggl-logo-big.png" height="80" width="200">
&nbsp;&nbsp;
</td>
<td valign="top" align="right">
<a href="http://www.boost.org">
<img alt="Boost C++ Libraries" src="images/accepted_by_boost.png" height="80" width="230" border="0">
</a>
</td>
</tr>
</tbody>
</table>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</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>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<h1>boost/geometry/arithmetic/arithmetic.hpp</h1><a href="arithmetic_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Boost.Geometry (aka GGL, Generic Geometry Library)</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
<a name="l00005"></a>00005 <span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
<a name="l00006"></a>00006 <span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
<a name="l00007"></a>00007 <span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;functional&gt;</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;boost/call_traits.hpp&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;boost/concept/requires.hpp&gt;</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;<a class="code" href="coordinate__type_8hpp.html">boost/geometry/core/coordinate_type.hpp</a>&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;<a class="code" href="point__concept_8hpp.html">boost/geometry/geometries/concepts/point_concept.hpp</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;<a class="code" href="for__each__coordinate_8hpp.html">boost/geometry/util/for_each_coordinate.hpp</a>&gt;</span>
<a name="l00020"></a>00020
<a name="l00025"></a>00025 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>geometry
<a name="l00026"></a>00026 {
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef DOXYGEN_NO_DETAIL</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="keyword">namespace </span>detail
<a name="l00030"></a>00030 {
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> P&gt;
<a name="l00033"></a>00033 <span class="keyword">struct </span>param
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035 <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::call_traits
<a name="l00036"></a>00036 &lt;
<a name="l00037"></a>00037 <span class="keyword">typename</span> coordinate_type&lt;P&gt;::type
<a name="l00038"></a>00038 &gt;::param_type type;
<a name="l00039"></a>00039 };
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> C, <span class="keyword">template</span> &lt;<span class="keyword">typename</span>&gt; <span class="keyword">class </span>Function&gt;
<a name="l00042"></a>00042 <span class="keyword">struct </span>value_operation
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 C m_value;
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="keyword">inline</span> value_operation(C <span class="keyword">const</span> &amp;value)
<a name="l00047"></a>00047 : m_value(value)
<a name="l00048"></a>00048 {}
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> P, <span class="keywordtype">int</span> I&gt;
<a name="l00051"></a>00051 <span class="keyword">inline</span> <span class="keywordtype">void</span> apply(P&amp; point)<span class="keyword"> const</span>
<a name="l00052"></a>00052 <span class="keyword"> </span>{
<a name="l00053"></a>00053 set&lt;I&gt;(point, Function&lt;C&gt;()(get&lt;I&gt;(point), m_value));
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 };
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>Src, <span class="keyword">template</span> &lt;<span class="keyword">typename</span>&gt; <span class="keyword">class </span>Function&gt;
<a name="l00058"></a>00058 <span class="keyword">struct </span>point_operation
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 <span class="keyword">typedef</span> <span class="keyword">typename</span> coordinate_type&lt;PointSrc&gt;::type coordinate_type;
<a name="l00061"></a>00061 PointSrc <span class="keyword">const</span>&amp; m_source_point;
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keyword">inline</span> point_operation(PointSrc <span class="keyword">const</span>&amp; point)
<a name="l00064"></a>00064 : m_source_point(point)
<a name="l00065"></a>00065 {}
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>Dst, <span class="keywordtype">int</span> I&gt;
<a name="l00068"></a>00068 <span class="keyword">inline</span> <span class="keywordtype">void</span> apply(PointDst&amp; dest_point)<span class="keyword"> const</span>
<a name="l00069"></a>00069 <span class="keyword"> </span>{
<a name="l00070"></a>00070 set&lt;I&gt;(dest_point,
<a name="l00071"></a>00071 Function&lt;coordinate_type&gt;()(get&lt;I&gt;(dest_point), get&lt;I&gt;(m_source_point)));
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074
<a name="l00075"></a>00075 } <span class="comment">// namespace detail</span>
<a name="l00076"></a>00076 <span class="preprocessor">#endif // DOXYGEN_NO_DETAIL</span>
<a name="l00077"></a>00077 <span class="preprocessor"></span>
<a name="l00085"></a>00085 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>&gt;
<a name="l00086"></a><a class="code" href="group__arithmetic.html#g7458ae2b1a6267e21b2daac8b35e443e">00086</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g7458ae2b1a6267e21b2daac8b35e443e" title="Adds a value to each coordinate of a point.">add_value</a>(Point&amp; p, <span class="keyword">typename</span> detail::param&lt;Point&gt;::type value)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point&gt;</a>) );
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p, detail::value_operation&lt;<span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1coordinate__type.html" title="Meta-function which defines coordinate type (int, float, double, etc) of any geometry...">coordinate_type&lt;Point&gt;::type</a>, std::plus&gt;(value));
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00101"></a>00101 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>1, <span class="keyword">typename</span> Po<span class="keywordtype">int</span>2&gt;
<a name="l00102"></a><a class="code" href="group__arithmetic.html#gf595c14ab7034da7d6b67322e0a99870">00102</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#gf595c14ab7034da7d6b67322e0a99870" title="Adds a point to another.">add_point</a>(Point1&amp; p1, Point2 <span class="keyword">const</span>&amp; p2)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point2&gt;</a>) );
<a name="l00105"></a>00105 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_const_point.html" title="point concept (const version)">concept::ConstPoint&lt;Point2&gt;</a>) );
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p1, detail::point_operation&lt;Point2, std::plus&gt;(p2));
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109
<a name="l00117"></a>00117 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>&gt;
<a name="l00118"></a><a class="code" href="group__arithmetic.html#g931ec2441c2cc157611340c9a6da0182">00118</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g931ec2441c2cc157611340c9a6da0182" title="Subtracts a value to each coordinate of a point.">subtract_value</a>(Point&amp; p, <span class="keyword">typename</span> detail::param&lt;Point&gt;::type value)
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point&gt;</a>) );
<a name="l00121"></a>00121
<a name="l00122"></a>00122 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p, detail::value_operation&lt;<span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1coordinate__type.html" title="Meta-function which defines coordinate type (int, float, double, etc) of any geometry...">coordinate_type&lt;Point&gt;::type</a>, std::minus&gt;(value));
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124
<a name="l00133"></a>00133 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>1, <span class="keyword">typename</span> Po<span class="keywordtype">int</span>2&gt;
<a name="l00134"></a><a class="code" href="group__arithmetic.html#g941f5637305d369b047144faeb2d29b0">00134</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g941f5637305d369b047144faeb2d29b0" title="Subtracts a point to another.">subtract_point</a>(Point1&amp; p1, Point2 <span class="keyword">const</span>&amp; p2)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point2&gt;</a>) );
<a name="l00137"></a>00137 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_const_point.html" title="point concept (const version)">concept::ConstPoint&lt;Point2&gt;</a>) );
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p1, detail::point_operation&lt;Point2, std::minus&gt;(p2));
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00149"></a>00149 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>&gt;
<a name="l00150"></a><a class="code" href="group__arithmetic.html#g1486e033b9a991315ce0be491f9c5585">00150</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g1486e033b9a991315ce0be491f9c5585" title="Multiplies each coordinate of a point by a value.">multiply_value</a>(Point&amp; p, <span class="keyword">typename</span> detail::param&lt;Point&gt;::type value)
<a name="l00151"></a>00151 {
<a name="l00152"></a>00152 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point&gt;</a>) );
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p, detail::value_operation&lt;<span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1coordinate__type.html" title="Meta-function which defines coordinate type (int, float, double, etc) of any geometry...">coordinate_type&lt;Point&gt;::type</a>, std::multiplies&gt;(value));
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156
<a name="l00166"></a>00166 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>1, <span class="keyword">typename</span> Po<span class="keywordtype">int</span>2&gt;
<a name="l00167"></a><a class="code" href="group__arithmetic.html#g6bed4618f2d58404362a7c584d8045e5">00167</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g6bed4618f2d58404362a7c584d8045e5" title="Multiplies a point by another.">multiply_point</a>(Point1&amp; p1, Point2 <span class="keyword">const</span>&amp; p2)
<a name="l00168"></a>00168 {
<a name="l00169"></a>00169 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point2&gt;</a>) );
<a name="l00170"></a>00170 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_const_point.html" title="point concept (const version)">concept::ConstPoint&lt;Point2&gt;</a>) );
<a name="l00171"></a>00171
<a name="l00172"></a>00172 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p1, detail::point_operation&lt;Point2, std::multiplies&gt;(p2));
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00182"></a>00182 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>&gt;
<a name="l00183"></a><a class="code" href="group__arithmetic.html#g6bc24f87156cc3c40e16e0f2fa47280a">00183</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g6bc24f87156cc3c40e16e0f2fa47280a" title="Divides each coordinate of a point by a value.">divide_value</a>(Point&amp; p, <span class="keyword">typename</span> detail::param&lt;Point&gt;::type value)
<a name="l00184"></a>00184 {
<a name="l00185"></a>00185 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point&gt;</a>) );
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p, detail::value_operation&lt;<span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1coordinate__type.html" title="Meta-function which defines coordinate type (int, float, double, etc) of any geometry...">coordinate_type&lt;Point&gt;::type</a>, std::divides&gt;(value));
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189
<a name="l00198"></a>00198 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>1, <span class="keyword">typename</span> Po<span class="keywordtype">int</span>2&gt;
<a name="l00199"></a><a class="code" href="group__arithmetic.html#g72f0f1ea2b53e00c45e6eed40604e270">00199</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__arithmetic.html#g72f0f1ea2b53e00c45e6eed40604e270" title="Divides a point by another.">divide_point</a>(Point1&amp; p1, Point2 <span class="keyword">const</span>&amp; p2)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_point.html" title="Point concept.">concept::Point&lt;Point2&gt;</a>) );
<a name="l00202"></a>00202 BOOST_CONCEPT_ASSERT( (<a class="code" href="classboost_1_1geometry_1_1concept_1_1_const_point.html" title="point concept (const version)">concept::ConstPoint&lt;Point2&gt;</a>) );
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <a class="code" href="namespaceboost_1_1geometry.html#02f69ee47aa6561a84aad36ab45c96b4">for_each_coordinate</a>(p1, detail::point_operation&lt;Point2, std::divides&gt;(p2));
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206
<a name="l00207"></a>00207 }} <span class="comment">// namespace boost::geometry</span>
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="preprocessor">#endif // BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP</span>
</pre></div></div>
<hr size="1">
<table width="100%">
<tbody>
<tr>
<td align="left"><small>
<p>December 1, 2009</p>
</small></td>
<td align="right">
<small>Copyright <20> 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
Copyright <20> 2008-2009 Bruno Lalande, Paris<br>
Copyright <20> 2009 Mateusz Loskot, Cadcorp, London<br>
</small>
</td>
</tr>
</tbody>
</table>
<address style="text-align: right;"><small>
Documentation is generated by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a>
</small></address>
</body>
</html>