1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>transform (with strategy)</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.html" title="transform"> 10<link rel="next" href="transform_2.html" title="transform"> 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.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="transform_2.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_3_with_strategy"></a><a class="link" href="transform_3_with_strategy.html" title="transform (with strategy)">transform 28 (with strategy)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635688047120"></a> 32Transforms from one geometry to another geometry using the specified 33 strategy. 34 </p> 35<h6> 36<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h0"></a> 37 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.synopsis"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.synopsis">Synopsis</a> 38 </h6> 39<p> 40</p> 41<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> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">></span> 42<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> <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">strategy</span><span class="special">)</span></pre> 43<p> 44 </p> 45<h6> 46<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h1"></a> 47 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.parameters"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.parameters">Parameters</a> 48 </h6> 49<div class="informaltable"><table class="table"> 50<colgroup> 51<col> 52<col> 53<col> 54<col> 55</colgroup> 56<thead><tr> 57<th> 58 <p> 59 Type 60 </p> 61 </th> 62<th> 63 <p> 64 Concept 65 </p> 66 </th> 67<th> 68 <p> 69 Name 70 </p> 71 </th> 72<th> 73 <p> 74 Description 75 </p> 76 </th> 77</tr></thead> 78<tbody> 79<tr> 80<td> 81 <p> 82 Geometry1 const & 83 </p> 84 </td> 85<td> 86 <p> 87 Any type fulfilling a Geometry Concept 88 </p> 89 </td> 90<td> 91 <p> 92 geometry1 93 </p> 94 </td> 95<td> 96 <p> 97 A model of the specified concept 98 </p> 99 </td> 100</tr> 101<tr> 102<td> 103 <p> 104 Geometry2 & 105 </p> 106 </td> 107<td> 108 <p> 109 Any type fulfilling a Geometry Concept 110 </p> 111 </td> 112<td> 113 <p> 114 geometry2 115 </p> 116 </td> 117<td> 118 <p> 119 A model of the specified concept 120 </p> 121 </td> 122</tr> 123<tr> 124<td> 125 <p> 126 Strategy const & 127 </p> 128 </td> 129<td> 130 <p> 131 strategy 132 </p> 133 </td> 134<td> 135 <p> 136 strategy 137 </p> 138 </td> 139<td> 140 <p> 141 The strategy to be used for transformation 142 </p> 143 </td> 144</tr> 145</tbody> 146</table></div> 147<h6> 148<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h2"></a> 149 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.returns"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.returns">Returns</a> 150 </h6> 151<p> 152 True if the transformation could be done 153 </p> 154<h6> 155<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h3"></a> 156 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.header"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.header">Header</a> 157 </h6> 158<p> 159 Either 160 </p> 161<p> 162 <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> 163 </p> 164<p> 165 Or 166 </p> 167<p> 168 <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> 169 </p> 170<h6> 171<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h4"></a> 172 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.complexity"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.complexity">Complexity</a> 173 </h6> 174<p> 175 Linear 176 </p> 177<h6> 178<a name="geometry.reference.algorithms.transform.transform_3_with_strategy.h5"></a> 179 <span class="phrase"><a name="geometry.reference.algorithms.transform.transform_3_with_strategy.example"></a></span><a class="link" href="transform_3_with_strategy.html#geometry.reference.algorithms.transform.transform_3_with_strategy.example">Example</a> 180 </h6> 181<p> 182 Shows how points can be scaled, translated or rotated 183 </p> 184<p> 185</p> 186<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 187<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> 188 189 190<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 191<span class="special">{</span> 192 <span class="keyword">namespace</span> <span class="identifier">trans</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">strategy</span><span class="special">::</span><span class="identifier">transform</span><span class="special">;</span> 193 <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">;</span> 194 195 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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">double</span><span class="special">,</span> <span class="number">2</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">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">></span> <span class="identifier">point_type</span><span class="special">;</span> 196 197 <span class="identifier">point_type</span> <span class="identifier">p1</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">);</span> 198 199 <span class="comment">// Translate over (1.5, 1.5)</span> 200 <span class="identifier">point_type</span> <span class="identifier">p2</span><span class="special">;</span> 201 <span class="identifier">trans</span><span class="special">::</span><span class="identifier">translate_transformer</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">translate</span><span class="special">(</span><span class="number">1.5</span><span class="special">,</span> <span class="number">1.5</span><span class="special">);</span> 202 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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> <span class="identifier">translate</span><span class="special">);</span> 203 204 <span class="comment">// Scale with factor 3.0</span> 205 <span class="identifier">point_type</span> <span class="identifier">p3</span><span class="special">;</span> 206 <span class="identifier">trans</span><span class="special">::</span><span class="identifier">scale_transformer</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">scale</span><span class="special">(</span><span class="number">3.0</span><span class="special">);</span> 207 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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> <span class="identifier">scale</span><span class="special">);</span> 208 209 <span class="comment">// Rotate with respect to the origin (0,0) over 90 degrees (clockwise)</span> 210 <span class="identifier">point_type</span> <span class="identifier">p4</span><span class="special">;</span> 211 <span class="identifier">trans</span><span class="special">::</span><span class="identifier">rotate_transformer</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">degree</span><span class="special">,</span> <span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">rotate</span><span class="special">(</span><span class="number">90.0</span><span class="special">);</span> 212 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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">p4</span><span class="special">,</span> <span class="identifier">rotate</span><span class="special">);</span> 213 214 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> 215 <span class="special"><<</span> <span class="string">"p1: "</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> 216 <span class="special"><<</span> <span class="string">"p2: "</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> 217 <span class="special"><<</span> <span class="string">"p3: "</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> 218 <span class="special"><<</span> <span class="string">"p4: "</span> <span class="special"><<</span> <span class="identifier">dsv</span><span class="special">(</span><span class="identifier">p4</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> 219 220 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 221<span class="special">}</span> 222</pre> 223<p> 224 </p> 225<p> 226 Output: 227 </p> 228<pre class="programlisting">p1: (1, 1) 229p2: (2.5, 2.5) 230p3: (3, 3) 231p4: (1, -1) 232</pre> 233</div> 234<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 235<td align="left"></td> 236<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 237 Wulkiewicz, Oracle and/or its affiliates<p> 238 Distributed under the Boost Software License, Version 1.0. (See accompanying 239 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>) 240 </p> 241</div></td> 242</tr></table> 243<hr> 244<div class="spirit-nav"> 245<a accesskey="p" href="../transform.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="transform_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 246</div> 247</body> 248</html> 249