3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>transform</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../../index.html" title="Chapter 1. Geometry">
8 <link rel="up" href="../transform.html" title="transform">
9 <link rel="prev" href="transform_3_with_strategy.html" title="transform (with strategy)">
10 <link rel="next" href="../union_.html" title="union_">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="transform_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../transform.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../union_.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="geometry.reference.algorithms.transform.transform_2"></a><a class="link" href="transform_2.html" title="transform">transform</a>
28 </h5></div></div></div>
30 <a class="indexterm" name="idp130918896"></a>
31 Transforms from one geometry to another geometry using a strategy.
34 <a name="geometry.reference.algorithms.transform.transform_2.h0"></a>
35 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.synopsis"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.synopsis">Synopsis</a>
39 <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Geometry2</span><span class="special">></span>
40 <span class="keyword">bool</span> <span class="identifier">transform</span><span class="special">(</span><span class="identifier">Geometry1</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry1</span><span class="special">,</span> <span class="identifier">Geometry2</span> <span class="special">&</span> <span class="identifier">geometry2</span><span class="special">)</span></pre>
44 <a name="geometry.reference.algorithms.transform.transform_2.h1"></a>
45 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.parameters"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.parameters">Parameters</a>
47 <div class="informaltable"><table class="table">
85 Any type fulfilling a Geometry Concept
95 A model of the specified concept
107 Any type fulfilling a Geometry Concept
117 A model of the specified concept
124 <a name="geometry.reference.algorithms.transform.transform_2.h2"></a>
125 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.returns"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.returns">Returns</a>
128 True if the transformation could be done
131 <a name="geometry.reference.algorithms.transform.transform_2.h3"></a>
132 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.header"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.header">Header</a>
138 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
144 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">algorithms</span><span class="special">/</span><span class="identifier">transform</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
147 <a name="geometry.reference.algorithms.transform.transform_2.h4"></a>
148 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.conformance"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.conformance">Conformance</a>
151 The function transform is not defined by OGC.
154 <a name="geometry.reference.algorithms.transform.transform_2.h5"></a>
155 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.behavior"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.behavior">Behavior</a>
157 <div class="informaltable"><table class="table">
178 Spherical (degree) / Spherical (radian)
183 Transforms coordinates from degree to radian, or vice versa
190 Spherical / Cartesian (3D)
195 Transforms coordinates from spherical coordinates to X,Y,Z,
196 or vice versa, on a unit sphere
203 Spherical (degree, with radius) / Spherical (radian, with radius)
208 Transforms coordinates from degree to radian, or vice versa.
209 Third coordinate (radius) is untouched
216 Spherical (with radius) / Cartesian (3D)
221 Transforms coordinates from spherical coordinates to X,Y,Z,
222 or vice versa, on a unit sphere. Third coordinate (radius)
223 is taken into account
230 <a name="geometry.reference.algorithms.transform.transform_2.h6"></a>
231 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.complexity"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.complexity">Complexity</a>
237 <a name="geometry.reference.algorithms.transform.transform_2.h7"></a>
238 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_2.example"></a></span><a class="link" href="transform_2.html#geometry.reference.algorithms.transform.transform_2.example">Example</a>
241 Shows how points can be transformed using the default strategy
245 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
246 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
249 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
250 <span class="special">{</span>
251 <span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span>
253 <span class="comment">// Select a point near the pole (theta=5.0, phi=15.0)</span>
254 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">long</span> <span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">spherical</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">degree</span><span class="special">></span> <span class="special">></span> <span class="identifier">p1</span><span class="special">(</span><span class="number">15.0</span><span class="special">,</span> <span class="number">5.0</span><span class="special">);</span>
256 <span class="comment">// Transform from degree to radian. Default strategy is automatically selected,</span>
257 <span class="comment">// it will convert from degree to radian</span>
258 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">long</span> <span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">spherical</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">radian</span><span class="special">></span> <span class="special">></span> <span class="identifier">p2</span><span class="special">;</span>
259 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">p1</span><span class="special">,</span> <span class="identifier">p2</span><span class="special">);</span>
261 <span class="comment">// Transform from degree (lon-lat) to 3D (x,y,z). Default strategy is automatically selected,</span>
262 <span class="comment">// it will consider points on a unit sphere</span>
263 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">long</span> <span class="keyword">double</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">></span> <span class="identifier">p3</span><span class="special">;</span>
264 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">p1</span><span class="special">,</span> <span class="identifier">p3</span><span class="special">);</span>
266 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span>
267 <span class="special"><<</span> <span class="string">"p1: "</span> <span class="special"><<</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">p1</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span>
268 <span class="special"><<</span> <span class="string">"p2: "</span> <span class="special"><<</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">p2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span>
269 <span class="special"><<</span> <span class="string">"p3: "</span> <span class="special"><<</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">p3</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
271 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
272 <span class="special">}</span>
279 <pre class="programlisting">p1: (15, 5)
280 p2: (0.261799, 0.0872665)
281 p3: (0.084186, 0.0225576, 0.996195)
284 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
285 <td align="left"></td>
286 <td align="right"><div class="copyright-footer">Copyright © 2009-2017 Barend
287 Gehrels, Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its
289 Distributed under the Boost Software License, Version 1.0. (See accompanying
290 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
295 <div class="spirit-nav">
296 <a accesskey="p" href="transform_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../transform.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../union_.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>