mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-12 14:01:47 +00:00
287 lines
17 KiB
HTML
287 lines
17 KiB
HTML
<!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">
|
||
|
||
</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 Page</span></a></li>
|
||
<li><a href="pages.html"><span>Related 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><a href="files.html"><span>Files</span></a></li>
|
||
<li><a href="examples.html"><span>Examples</span></a></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="contents">
|
||
<h1>centroid: calculate centroid (center of gravity) of a geometry</h1><table border="0" cellpadding="0" cellspacing="0">
|
||
<tr><td></td></tr>
|
||
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
|
||
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1geometry_1_1concept_1_1_centroid_strategy.html">boost::geometry::concept::CentroidStrategy< Strategy ></a></td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Checks <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a> for centroid. <a href="classboost_1_1geometry_1_1concept_1_1_centroid_strategy.html#_details">More...</a><br></td></tr>
|
||
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct </td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1geometry_1_1strategy__centroid.html">boost::geometry::strategy_centroid< CsTag, GeometryTag, Dimension, Point, Geometry ></a></td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Traits class binding a centroid calculation <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a> to a coordinate system. <a href="structboost_1_1geometry_1_1strategy__centroid.html#_details">More...</a><br></td></tr>
|
||
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
|
||
<tr><td class="memTemplParams" nowrap colspan="2">template<typename Geometry , typename Point > </td></tr>
|
||
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__centroid.html#g6ba67d019f82f28401213b6096224892">boost::geometry::centroid</a> (Geometry const &geometry, Point &c)</td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Calculate centroid. <a href="#g6ba67d019f82f28401213b6096224892"></a><br></td></tr>
|
||
<tr><td class="memTemplParams" nowrap colspan="2">template<typename Geometry , typename Point , typename Strategy > </td></tr>
|
||
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__centroid.html#g7f67098dd56aba656f32b3635b66d105">boost::geometry::centroid</a> (Geometry const &geometry, Point &c, Strategy const &strategy)</td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Calculate centroid using a specified <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a>. <a href="#g7f67098dd56aba656f32b3635b66d105"></a><br></td></tr>
|
||
<tr><td class="memTemplParams" nowrap colspan="2">template<typename Point , typename Geometry , typename Strategy > </td></tr>
|
||
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">Point </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__centroid.html#g02af164c207ab95f31c62d3fcfab7cff">boost::geometry::make_centroid</a> (Geometry const &geometry, Strategy const &strategy)</td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Calculate and return centroid, using a specified <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a>. <a href="#g02af164c207ab95f31c62d3fcfab7cff"></a><br></td></tr>
|
||
<tr><td class="memTemplParams" nowrap colspan="2">template<typename Point , typename Geometry > </td></tr>
|
||
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">Point </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__centroid.html#gc7afddb71d27110bc3d8366bb752e2c6">boost::geometry::make_centroid</a> (Geometry const &geometry)</td></tr>
|
||
|
||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Calculate and return centroid. <a href="#gc7afddb71d27110bc3d8366bb752e2c6"></a><br></td></tr>
|
||
</table>
|
||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||
<dl class="user" compact><dt><b>Source descriptions:</b></dt><dd><ul>
|
||
<li>OGC description: The mathematical centroid for this Surface as a Point. The result is not guaranteed to be on this Surface.</li><li>From Wikipedia: Informally, it is the "average" of all points </li></ul>
|
||
</dd></dl>
|
||
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://en.wikipedia.org/wiki/Centroid">http://en.wikipedia.org/wiki/Centroid</a> </dd></dl>
|
||
<dl class="note" compact><dt><b>Note:</b></dt><dd>Polygon should be closed, and can be orientated either way <p>
|
||
The "centroid" functions are taking a non const reference to the centroid. The "make_centroid" functions return the centroid, the type has to be specified. <p>
|
||
Both of them have an overloaded version where a centroid calculation strategy can be specified </dd></dl>
|
||
<dl compact><dt><b>Exceptions:</b></dt><dd>
|
||
<table border="0" cellspacing="2" cellpadding="0">
|
||
<tr><td valign="top"></td><td valign="top"><em>centroid_exception</em> </td><td>if calculation is not successful, e.g. because polygon didn't contain points</td></tr>
|
||
</table>
|
||
</dl>
|
||
<dl class="user" compact><dt><b>Example:</b></dt><dd>Example showing centroid calculation <div class="fragment"><pre class="fragment">{
|
||
<a class="code" href="classboost_1_1geometry_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">boost::geometry::polygon<boost::geometry::point_xy<double></a> > poly;
|
||
boost::geometry::read_wkt(<span class="stringliteral">"POLYGON((0 0,0 7,4 2,2 0,0 0))"</span>, poly);
|
||
<span class="comment">// Center of polygon might have different type than points of polygon</span>
|
||
<a class="code" href="classboost_1_1geometry_1_1point__xy.html" title="2D point in Cartesian coordinate system">boost::geometry::point_xy<float></a> center;
|
||
<a class="code" href="group__centroid.html#g7f67098dd56aba656f32b3635b66d105" title="Calculate centroid using a specified strategy.">boost::geometry::centroid</a>(poly, center);
|
||
std::cout << <span class="stringliteral">"Centroid: "</span> << <a class="code" href="group__utility.html#g62cc5db4d3bb1147591298b3500f8f1a" title="Main DSV-streaming function.">boost::geometry::dsv</a>(center) << std::endl;
|
||
}
|
||
</pre></div></dd></dl>
|
||
<dl class="user" compact><dt><b>Performance</b></dt><dd>2776 * 1000 centroid calculations are done in 0.16 seconds (<a href="http://trac.osgeo.org/ggl/wiki/Performance#Centroid1">http://trac.osgeo.org/ggl/wiki/Performance#Centroid1</a>)</dd></dl>
|
||
<dl class="user" compact><dt><b>Geometries:</b></dt><dd><ul>
|
||
<li>RING: <div align="center">
|
||
<img src="centroid_ring.png" alt="centroid_ring.png">
|
||
</div>
|
||
</li><li>BOX: the centroid of a 2D or 3D box is the center of the box</li><li>POLYGON <div align="center">
|
||
<img src="centroid_polygon.png" alt="centroid_polygon.png">
|
||
</div>
|
||
</li><li>POINT: the point is the centroid</li><li>LINESTRING: the average of the centers of its segments</li><li>MULTIPOINT: the average of the points </li></ul>
|
||
</dd></dl>
|
||
<hr><h2>Function Documentation</h2>
|
||
<a class="anchor" name="g7f67098dd56aba656f32b3635b66d105"></a><!-- doxytag: member="boost::geometry::centroid" ref="g7f67098dd56aba656f32b3635b66d105" args="(Geometry const &geometry, Point &c, Strategy const &strategy)" -->
|
||
<div class="memitem">
|
||
<div class="memproto">
|
||
<div class="memtemplate">
|
||
template<typename Geometry , typename Point , typename Strategy > </div>
|
||
<table class="memname">
|
||
<tr>
|
||
<td class="memname">void boost::geometry::centroid </td>
|
||
<td>(</td>
|
||
<td class="paramtype">Geometry const & </td>
|
||
<td class="paramname"> <em>geometry</em>, </td>
|
||
</tr>
|
||
<tr>
|
||
<td class="paramkey"></td>
|
||
<td></td>
|
||
<td class="paramtype">Point & </td>
|
||
<td class="paramname"> <em>c</em>, </td>
|
||
</tr>
|
||
<tr>
|
||
<td class="paramkey"></td>
|
||
<td></td>
|
||
<td class="paramtype">Strategy const & </td>
|
||
<td class="paramname"> <em>strategy</em></td><td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td></td>
|
||
<td>)</td>
|
||
<td></td><td></td><td></td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="memdoc">
|
||
|
||
<p>
|
||
Calculate centroid using a specified <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a>.
|
||
<p>
|
||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||
<table border="0" cellspacing="2" cellpadding="0">
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry.html">geometry</a></em> </td><td>the <a class="el" href="namespaceboost_1_1geometry.html">geometry</a> to calculate centroid from </td></tr>
|
||
<tr><td valign="top"></td><td valign="top"><em>c</em> </td><td>reference to <a class="el" href="classboost_1_1geometry_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">point</a> which will contain the centroid </td></tr>
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a></em> </td><td>Calculation <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a> for centroid </td></tr>
|
||
</table>
|
||
</dl>
|
||
<dl compact><dt><b>Examples: </b></dt><dd>
|
||
<a class="el" href="03__polygon__example_8cpp-example.html#a8">03_polygon_example.cpp</a>, <a class="el" href="c04__a__custom__triangle__example_8cpp-example.html#a4">c04_a_custom_triangle_example.cpp</a>, and <a class="el" href="c04__b__custom__triangle__example_8cpp-example.html#a4">c04_b_custom_triangle_example.cpp</a>.</dl>
|
||
<p>Definition at line <a class="el" href="algorithms_2centroid_8hpp_source.html#l00386">386</a> of file <a class="el" href="algorithms_2centroid_8hpp_source.html">centroid.hpp</a>.</p>
|
||
|
||
</div>
|
||
</div><p>
|
||
<a class="anchor" name="g6ba67d019f82f28401213b6096224892"></a><!-- doxytag: member="boost::geometry::centroid" ref="g6ba67d019f82f28401213b6096224892" args="(Geometry const &geometry, Point &c)" -->
|
||
<div class="memitem">
|
||
<div class="memproto">
|
||
<div class="memtemplate">
|
||
template<typename Geometry , typename Point > </div>
|
||
<table class="memname">
|
||
<tr>
|
||
<td class="memname">void boost::geometry::centroid </td>
|
||
<td>(</td>
|
||
<td class="paramtype">Geometry const & </td>
|
||
<td class="paramname"> <em>geometry</em>, </td>
|
||
</tr>
|
||
<tr>
|
||
<td class="paramkey"></td>
|
||
<td></td>
|
||
<td class="paramtype">Point & </td>
|
||
<td class="paramname"> <em>c</em></td><td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td></td>
|
||
<td>)</td>
|
||
<td></td><td></td><td></td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="memdoc">
|
||
|
||
<p>
|
||
Calculate centroid.
|
||
<p>
|
||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||
<table border="0" cellspacing="2" cellpadding="0">
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry.html">geometry</a></em> </td><td>a <a class="el" href="namespaceboost_1_1geometry.html">geometry</a> (e.g. closed ring or <a class="el" href="classboost_1_1geometry_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon</a>) </td></tr>
|
||
<tr><td valign="top"></td><td valign="top"><em>c</em> </td><td>reference to <a class="el" href="classboost_1_1geometry_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">point</a> which will contain the centroid </td></tr>
|
||
</table>
|
||
</dl>
|
||
|
||
<p>Definition at line <a class="el" href="algorithms_2centroid_8hpp_source.html#l00414">414</a> of file <a class="el" href="algorithms_2centroid_8hpp_source.html">centroid.hpp</a>.</p>
|
||
|
||
</div>
|
||
</div><p>
|
||
<a class="anchor" name="gc7afddb71d27110bc3d8366bb752e2c6"></a><!-- doxytag: member="boost::geometry::make_centroid" ref="gc7afddb71d27110bc3d8366bb752e2c6" args="(Geometry const &geometry)" -->
|
||
<div class="memitem">
|
||
<div class="memproto">
|
||
<div class="memtemplate">
|
||
template<typename Point , typename Geometry > </div>
|
||
<table class="memname">
|
||
<tr>
|
||
<td class="memname">Point boost::geometry::make_centroid </td>
|
||
<td>(</td>
|
||
<td class="paramtype">Geometry const & </td>
|
||
<td class="paramname"> <em>geometry</em> </td>
|
||
<td> ) </td>
|
||
<td></td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="memdoc">
|
||
|
||
<p>
|
||
Calculate and return centroid.
|
||
<p>
|
||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||
<table border="0" cellspacing="2" cellpadding="0">
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry.html">geometry</a></em> </td><td>the <a class="el" href="namespaceboost_1_1geometry.html">geometry</a> to calculate centroid from </td></tr>
|
||
</table>
|
||
</dl>
|
||
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the centroid </dd></dl>
|
||
|
||
<p>Definition at line <a class="el" href="algorithms_2centroid_8hpp_source.html#l00438">438</a> of file <a class="el" href="algorithms_2centroid_8hpp_source.html">centroid.hpp</a>.</p>
|
||
|
||
</div>
|
||
</div><p>
|
||
<a class="anchor" name="g02af164c207ab95f31c62d3fcfab7cff"></a><!-- doxytag: member="boost::geometry::make_centroid" ref="g02af164c207ab95f31c62d3fcfab7cff" args="(Geometry const &geometry, Strategy const &strategy)" -->
|
||
<div class="memitem">
|
||
<div class="memproto">
|
||
<div class="memtemplate">
|
||
template<typename Point , typename Geometry , typename Strategy > </div>
|
||
<table class="memname">
|
||
<tr>
|
||
<td class="memname">Point boost::geometry::make_centroid </td>
|
||
<td>(</td>
|
||
<td class="paramtype">Geometry const & </td>
|
||
<td class="paramname"> <em>geometry</em>, </td>
|
||
</tr>
|
||
<tr>
|
||
<td class="paramkey"></td>
|
||
<td></td>
|
||
<td class="paramtype">Strategy const & </td>
|
||
<td class="paramname"> <em>strategy</em></td><td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td></td>
|
||
<td>)</td>
|
||
<td></td><td></td><td></td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="memdoc">
|
||
|
||
<p>
|
||
Calculate and return centroid, using a specified <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a>.
|
||
<p>
|
||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||
<table border="0" cellspacing="2" cellpadding="0">
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry.html">geometry</a></em> </td><td>the <a class="el" href="namespaceboost_1_1geometry.html">geometry</a> to calculate centroid from </td></tr>
|
||
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a></em> </td><td>Calculation <a class="el" href="namespaceboost_1_1geometry_1_1strategy.html">strategy</a> for centroid </td></tr>
|
||
</table>
|
||
</dl>
|
||
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the centroid </dd></dl>
|
||
|
||
<p>Definition at line <a class="el" href="algorithms_2centroid_8hpp_source.html#l00455">455</a> of file <a class="el" href="algorithms_2centroid_8hpp_source.html">centroid.hpp</a>.</p>
|
||
|
||
</div>
|
||
</div><p>
|
||
</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 <a href="http://www.doxygen.org/index.html">Doxygen</a>
|
||
</small></address>
|
||
</body>
|
||
</html>
|