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

114 lines
6.5 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">
&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><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>06_transformation_example.cpp</h1>This sample demonstrates the usage of transformations in the Generic Geometry Library. Behind the screens this is done using with the uBLAS matrix/vector library.<p>
<div class="fragment"><pre class="fragment"><span class="comment">// Boost.Geometry (aka GGL, Generic Geometry Library)</span>
<span class="comment">//</span>
<span class="comment">// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands</span>
<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
<span class="comment">//</span>
<span class="comment">// Transformation Example</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;boost/geometry/geometry.hpp&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">boost/geometry/geometries/cartesian2d.hpp</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="c__array__cartesian_8hpp.html">boost/geometry/geometries/adapted/c_array_cartesian.hpp</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="std__as__linestring_8hpp.html">boost/geometry/geometries/adapted/std_as_linestring.hpp</a>&gt;</span>
<span class="keywordtype">int</span> main()
{
<span class="keyword">using namespace </span>boost::geometry;
<a name="_a0"></a><a class="code" href="classboost_1_1geometry_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> p(1, 1);
<a class="code" href="classboost_1_1geometry_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> p2;
<span class="comment">// Example: translate a point over (5,5)</span>
<a name="_a1"></a><a class="code" href="structboost_1_1geometry_1_1strategy_1_1transform_1_1translate__transformer.html" title="Strategy of translate transformation in Cartesian system.">strategy::transform::translate_transformer&lt;point_2d, point_2d&gt;</a> translate(5, 5);
<a name="a2"></a><a class="code" href="group__transform.html#g6b9a387b5ac973d7d9e273d9dffc1d3e" title="Transforms from one geometry to another geometry using a strategy.">transform</a>(p, p2, translate);
std::cout &lt;&lt; <span class="stringliteral">"transformed point "</span> &lt;&lt; <a name="a3"></a><a class="code" href="group__utility.html#g62cc5db4d3bb1147591298b3500f8f1a" title="Main DSV-streaming function.">boost::geometry::dsv</a>(p2) &lt;&lt; std::endl;
<span class="comment">// Transform a polygon</span>
<a name="_a4"></a><a class="code" href="classboost_1_1geometry_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon_2d</a> poly, poly2;
<span class="keyword">const</span> <span class="keywordtype">double</span> coor[][2] = { {0, 0}, {0, 7}, {2, 2}, {2, 0}, {0, 0} };
<span class="comment">// note that for this syntax you have to include the two</span>
<span class="comment">// include files above (c_array_cartesian.hpp, std_as_linestring.hpp)</span>
<a name="a5"></a><a class="code" href="group__access.html#gd1a7d6277b95439021f13191094aebdb" title="assign two values to a 2D point">assign</a>(poly, coor);
<span class="comment">//read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);</span>
<a class="code" href="group__transform.html#g6b9a387b5ac973d7d9e273d9dffc1d3e" title="Transforms from one geometry to another geometry using a strategy.">transform</a>(poly, poly2, translate);
std::cout &lt;&lt; <span class="stringliteral">"source polygon "</span> &lt;&lt; <a class="code" href="group__utility.html#g62cc5db4d3bb1147591298b3500f8f1a" title="Main DSV-streaming function.">boost::geometry::dsv</a>(poly) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">"transformed polygon "</span> &lt;&lt; <a class="code" href="group__utility.html#g62cc5db4d3bb1147591298b3500f8f1a" title="Main DSV-streaming function.">boost::geometry::dsv</a>(poly2) &lt;&lt; std::endl;
<span class="comment">// Many more transformations are possible:</span>
<span class="comment">// - from Cartesian to Spherical coordinate systems and back</span>
<span class="comment">// - from Cartesian to Cartesian (mapping, affine transformations) and back (inverse)</span>
<span class="comment">// - Map Projections</span>
<span class="comment">// - from Degree to Radian and back in spherical or geographic coordinate systems</span>
<span class="keywordflow">return</span> 0;
}
</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 © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
Copyright © 2008-2009 Bruno Lalande, Paris<br>
Copyright © 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>