1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 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_"> 11</head> 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> 20</tr></table> 21<hr> 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> 24</div> 25<div class="section"> 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> 29<p> 30 <a class="indexterm" name="idm45635687845984"></a> 31Transforms from one geometry to another geometry using a strategy. 32 </p> 33<h6> 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> 36 </h6> 37<p> 38</p> 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> 41<p> 42 </p> 43<h6> 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> 46 </h6> 47<div class="informaltable"><table class="table"> 48<colgroup> 49<col> 50<col> 51<col> 52<col> 53</colgroup> 54<thead><tr> 55<th> 56 <p> 57 Type 58 </p> 59 </th> 60<th> 61 <p> 62 Concept 63 </p> 64 </th> 65<th> 66 <p> 67 Name 68 </p> 69 </th> 70<th> 71 <p> 72 Description 73 </p> 74 </th> 75</tr></thead> 76<tbody> 77<tr> 78<td> 79 <p> 80 Geometry1 const & 81 </p> 82 </td> 83<td> 84 <p> 85 Any type fulfilling a Geometry Concept 86 </p> 87 </td> 88<td> 89 <p> 90 geometry1 91 </p> 92 </td> 93<td> 94 <p> 95 A model of the specified concept 96 </p> 97 </td> 98</tr> 99<tr> 100<td> 101 <p> 102 Geometry2 & 103 </p> 104 </td> 105<td> 106 <p> 107 Any type fulfilling a Geometry Concept 108 </p> 109 </td> 110<td> 111 <p> 112 geometry2 113 </p> 114 </td> 115<td> 116 <p> 117 A model of the specified concept 118 </p> 119 </td> 120</tr> 121</tbody> 122</table></div> 123<h6> 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> 126 </h6> 127<p> 128 True if the transformation could be done 129 </p> 130<h6> 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> 133 </h6> 134<p> 135 Either 136 </p> 137<p> 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> 139 </p> 140<p> 141 Or 142 </p> 143<p> 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> 145 </p> 146<h6> 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> 149 </h6> 150<p> 151 The function transform is not defined by OGC. 152 </p> 153<h6> 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> 156 </h6> 157<div class="informaltable"><table class="table"> 158<colgroup> 159<col> 160<col> 161</colgroup> 162<thead><tr> 163<th> 164 <p> 165 Case 166 </p> 167 </th> 168<th> 169 <p> 170 Behavior 171 </p> 172 </th> 173</tr></thead> 174<tbody> 175<tr> 176<td> 177 <p> 178 Spherical (degree) / Spherical (radian) 179 </p> 180 </td> 181<td> 182 <p> 183 Transforms coordinates from degree to radian, or vice versa 184 </p> 185 </td> 186</tr> 187<tr> 188<td> 189 <p> 190 Spherical / Cartesian (3D) 191 </p> 192 </td> 193<td> 194 <p> 195 Transforms coordinates from spherical coordinates to X,Y,Z, 196 or vice versa, on a unit sphere 197 </p> 198 </td> 199</tr> 200<tr> 201<td> 202 <p> 203 Spherical (degree, with radius) / Spherical (radian, with radius) 204 </p> 205 </td> 206<td> 207 <p> 208 Transforms coordinates from degree to radian, or vice versa. 209 Third coordinate (radius) is untouched 210 </p> 211 </td> 212</tr> 213<tr> 214<td> 215 <p> 216 Spherical (with radius) / Cartesian (3D) 217 </p> 218 </td> 219<td> 220 <p> 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 224 </p> 225 </td> 226</tr> 227</tbody> 228</table></div> 229<h6> 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> 232 </h6> 233<p> 234 Linear 235 </p> 236<h6> 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> 239 </h6> 240<p> 241 Shows how points can be transformed using the default strategy 242 </p> 243<p> 244</p> 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> 247 248 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> 252 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> 255 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> 260 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> 265 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> 270 271 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 272<span class="special">}</span> 273</pre> 274<p> 275 </p> 276<p> 277 Output: 278 </p> 279<pre class="programlisting">p1: (15, 5) 280p2: (0.261799, 0.0872665) 281p3: (0.084186, 0.0225576, 0.996195) 282</pre> 283</div> 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-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 287 Wulkiewicz, Oracle and/or its affiliates<p> 288 Distributed under the Boost Software License, Version 1.0. (See accompanying 289 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>) 290 </p> 291</div></td> 292</tr></table> 293<hr> 294<div class="spirit-nav"> 295<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> 296</div> 297</body> 298</html> 299