1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>model::point</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="../models.html" title="Models"> 9<link rel="prev" href="../models.html" title="Models"> 10<link rel="next" href="model_d2_point_xy.html" title="model::d2::point_xy"> 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="../models.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.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="model_d2_point_xy.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="geometry.reference.models.model_point"></a><a class="link" href="model_point.html" title="model::point">model::point</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635680921392"></a><a class="indexterm" name="idm45635680920704"></a> 31Basic point class, having coordinates defined in a neutral way. 32 </p> 33<h6> 34<a name="geometry.reference.models.model_point.h0"></a> 35 <span class="phrase"><a name="geometry.reference.models.model_point.description"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.description">Description</a> 36 </h6> 37<p> 38 Defines a neutral point class, fulfilling the Point Concept. Library users 39 can use this point class, or use their own point classes. This point class 40 is used in most of the samples and tests of Boost.Geometry This point class 41 is used occasionally within the library, where a temporary point class 42 is necessary. 43 </p> 44<h6> 45<a name="geometry.reference.models.model_point.h1"></a> 46 <span class="phrase"><a name="geometry.reference.models.model_point.model_of"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.model_of">Model 47 of</a> 48 </h6> 49<p> 50 <a class="link" href="../concepts/concept_point.html" title="Point Concept">Point Concept</a> 51 </p> 52<h6> 53<a name="geometry.reference.models.model_point.h2"></a> 54 <span class="phrase"><a name="geometry.reference.models.model_point.synopsis"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.synopsis">Synopsis</a> 55 </h6> 56<p> 57</p> 58<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">CoordinateType</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">DimensionCount</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">CoordinateSystem</span><span class="special">></span> 59<span class="keyword">class</span> <span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span> 60<span class="special">{</span> 61 <span class="comment">// ...</span> 62<span class="special">};</span> 63</pre> 64<p> 65 </p> 66<h6> 67<a name="geometry.reference.models.model_point.h3"></a> 68 <span class="phrase"><a name="geometry.reference.models.model_point.template_parameter_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.template_parameter_s_">Template 69 parameter(s)</a> 70 </h6> 71<div class="informaltable"><table class="table"> 72<colgroup> 73<col> 74<col> 75</colgroup> 76<thead><tr> 77<th> 78 <p> 79 Parameter 80 </p> 81 </th> 82<th> 83 <p> 84 Description 85 </p> 86 </th> 87</tr></thead> 88<tbody> 89<tr> 90<td> 91 <p> 92 typename CoordinateType 93 </p> 94 </td> 95<td> 96 <p> 97 numerical type (int, double, ttmath, ...) 98 </p> 99 </td> 100</tr> 101<tr> 102<td> 103 <p> 104 std::size_t DimensionCount 105 </p> 106 </td> 107<td> 108 <p> 109 number of coordinates, usually 2 or 3 110 </p> 111 </td> 112</tr> 113<tr> 114<td> 115 <p> 116 typename CoordinateSystem 117 </p> 118 </td> 119<td> 120 <p> 121 coordinate system, for example cs::cartesian 122 </p> 123 </td> 124</tr> 125</tbody> 126</table></div> 127<h6> 128<a name="geometry.reference.models.model_point.h4"></a> 129 <span class="phrase"><a name="geometry.reference.models.model_point.constructor_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.constructor_s_">Constructor(s)</a> 130 </h6> 131<div class="informaltable"><table class="table"> 132<colgroup> 133<col> 134<col> 135<col> 136</colgroup> 137<thead><tr> 138<th> 139 <p> 140 Function 141 </p> 142 </th> 143<th> 144 <p> 145 Description 146 </p> 147 </th> 148<th> 149 <p> 150 Parameters 151 </p> 152 </th> 153</tr></thead> 154<tbody> 155<tr> 156<td> 157 <p> 158</p> 159<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">point</span><span class="special">()</span></pre> 160<p> 161 </p> 162 </td> 163<td> 164 <p> 165 Default constructor, no initialization. 166 </p> 167 </td> 168<td> 169 </td> 170</tr> 171<tr> 172<td> 173 <p> 174</p> 175<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v0</span><span class="special">)</span></pre> 176<p> 177 </p> 178 </td> 179<td> 180 <p> 181 Constructor to set one value. 182 </p> 183 </td> 184<td> 185 <p> 186 <span class="bold"><strong>CoordinateType const &</strong></span>: 187 <span class="emphasis"><em>v0</em></span>: 188 </p> 189 </td> 190</tr> 191<tr> 192<td> 193 <p> 194</p> 195<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v0</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">)</span></pre> 196<p> 197 </p> 198 </td> 199<td> 200 <p> 201 Constructor to set two values. 202 </p> 203 </td> 204<td> 205 <p> 206 <span class="bold"><strong>CoordinateType const &</strong></span>: 207 <span class="emphasis"><em>v0</em></span>: 208 </p> 209 <p> 210 <span class="bold"><strong>CoordinateType const &</strong></span>: 211 <span class="emphasis"><em>v1</em></span>: 212 </p> 213 </td> 214</tr> 215<tr> 216<td> 217 <p> 218</p> 219<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">point</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v0</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v1</span><span class="special">,</span> <span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v2</span><span class="special">)</span></pre> 220<p> 221 </p> 222 </td> 223<td> 224 <p> 225 Constructor to set three values. 226 </p> 227 </td> 228<td> 229 <p> 230 <span class="bold"><strong>CoordinateType const &</strong></span>: 231 <span class="emphasis"><em>v0</em></span>: 232 </p> 233 <p> 234 <span class="bold"><strong>CoordinateType const &</strong></span>: 235 <span class="emphasis"><em>v1</em></span>: 236 </p> 237 <p> 238 <span class="bold"><strong>CoordinateType const &</strong></span>: 239 <span class="emphasis"><em>v2</em></span>: 240 </p> 241 </td> 242</tr> 243</tbody> 244</table></div> 245<h6> 246<a name="geometry.reference.models.model_point.h5"></a> 247 <span class="phrase"><a name="geometry.reference.models.model_point.member_function_s_"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.member_function_s_">Member 248 Function(s)</a> 249 </h6> 250<div class="informaltable"><table class="table"> 251<colgroup> 252<col> 253<col> 254<col> 255<col> 256</colgroup> 257<thead><tr> 258<th> 259 <p> 260 Function 261 </p> 262 </th> 263<th> 264 <p> 265 Description 266 </p> 267 </th> 268<th> 269 <p> 270 Parameters 271 </p> 272 </th> 273<th> 274 <p> 275 Returns 276 </p> 277 </th> 278</tr></thead> 279<tbody> 280<tr> 281<td> 282 <p> 283</p> 284<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">K</span><span class="special">></span> 285<span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">get</span><span class="special">()</span></pre> 286<p> 287 </p> 288 </td> 289<td> 290 <p> 291 Get a coordinate. 292 </p> 293 </td> 294<td> 295 </td> 296<td> 297 <p> 298 the coordinate 299 </p> 300 </td> 301</tr> 302<tr> 303<td> 304 <p> 305</p> 306<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">K</span><span class="special">></span> 307<span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="identifier">CoordinateType</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">value</span><span class="special">)</span></pre> 308<p> 309 </p> 310 </td> 311<td> 312 <p> 313 Set a coordinate. 314 </p> 315 </td> 316<td> 317 <p> 318 <span class="bold"><strong>CoordinateType const &</strong></span>: 319 <span class="emphasis"><em>value</em></span>: value to set 320 </p> 321 </td> 322<td> 323 </td> 324</tr> 325</tbody> 326</table></div> 327<h6> 328<a name="geometry.reference.models.model_point.h6"></a> 329 <span class="phrase"><a name="geometry.reference.models.model_point.header"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.header">Header</a> 330 </h6> 331<p> 332 Either 333 </p> 334<p> 335 <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">geometries</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 336 </p> 337<p> 338 Or 339 </p> 340<p> 341 <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">geometries</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 342 </p> 343<h6> 344<a name="geometry.reference.models.model_point.h7"></a> 345 <span class="phrase"><a name="geometry.reference.models.model_point.examples"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.examples">Examples</a> 346 </h6> 347<p> 348 Declaration and use of the Boost.Geometry model::point, modelling the Point 349 Concept 350 </p> 351<p> 352</p> 353<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 354<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> 355 356<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> 357 358<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 359<span class="special">{</span> 360 <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">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">cartesian</span><span class="special">></span> <span class="identifier">point1</span><span class="special">;</span> 361 <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">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">point2</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">3.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c0" href="model_point.html#geometry.reference.models.model_point.c1"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> 362 363 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="number">0</span><span class="special">>(</span><span class="identifier">point1</span><span class="special">,</span> <span class="number">1.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c2" href="model_point.html#geometry.reference.models.model_point.c3"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> 364 <span class="identifier">point1</span><span class="special">.</span><span class="identifier">set</span><span class="special"><</span><span class="number">1</span><span class="special">>(</span><span class="number">2.0</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c4" href="model_point.html#geometry.reference.models.model_point.c5"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> 365 366 <span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">get</span><span class="special"><</span><span class="number">0</span><span class="special">>(</span><span class="identifier">point1</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_point.c6" href="model_point.html#geometry.reference.models.model_point.c7"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> 367 <span class="keyword">double</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">point1</span><span class="special">.</span><span class="identifier">get</span><span class="special"><</span><span class="number">1</span><span class="special">>();</span> <a class="co" name="geometry.reference.models.model_point.c8" href="model_point.html#geometry.reference.models.model_point.c9"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a> 368 369 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">x</span> <span class="special"><<</span> <span class="string">", "</span> <span class="special"><<</span> <span class="identifier">y</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 370 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 371<span class="special">}</span> 372</pre> 373<p> 374 </p> 375<div class="calloutlist"><table border="0" summary="Callout list"> 376<tr> 377<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c1"></a><a href="#geometry.reference.models.model_point.c0"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 378<td valign="top" align="left"><p> 379 Construct, assigning three coordinates 380 </p></td> 381</tr> 382<tr> 383<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c3"></a><a href="#geometry.reference.models.model_point.c2"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> 384<td valign="top" align="left"><p> 385 Set a coordinate, generic. 386 </p></td> 387</tr> 388<tr> 389<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c5"></a><a href="#geometry.reference.models.model_point.c4"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> 390<td valign="top" align="left"><p> 391 Set a coordinate, class-specific (<span class="bold"><strong>Note</strong></span>: 392 prefer <code class="computeroutput"><span class="identifier">bg</span><span class="special">::</span><span class="identifier">set</span><span class="special">()</span></code>). 393 </p></td> 394</tr> 395<tr> 396<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c7"></a><a href="#geometry.reference.models.model_point.c6"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> </p></td> 397<td valign="top" align="left"><p> 398 Get a coordinate, generic. 399 </p></td> 400</tr> 401<tr> 402<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_point.c9"></a><a href="#geometry.reference.models.model_point.c8"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a> </p></td> 403<td valign="top" align="left"><p> 404 Get a coordinate, class-specific (<span class="bold"><strong>Note</strong></span>: 405 prefer <code class="computeroutput"><span class="identifier">bg</span><span class="special">::</span><span class="identifier">get</span><span class="special">()</span></code>). 406 </p></td> 407</tr> 408</table></div> 409<p> 410 Output: 411 </p> 412<pre class="programlisting">1, 2 413</pre> 414<h6> 415<a name="geometry.reference.models.model_point.h8"></a> 416 <span class="phrase"><a name="geometry.reference.models.model_point.notes"></a></span><a class="link" href="model_point.html#geometry.reference.models.model_point.notes">Notes</a> 417 </h6> 418<div class="note"><table border="0" summary="Note"> 419<tr> 420<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td> 421<th align="left">Note</th> 422</tr> 423<tr><td align="left" valign="top"><p> 424 Coordinates are not initialized. If the constructor with parameters is 425 not called and points are not assigned using <code class="computeroutput"><span class="identifier">set</span></code> 426 or <code class="computeroutput"><span class="identifier">assign</span></code> then the coordinate 427 values will contain garbage 428 </p></td></tr> 429</table></div> 430</div> 431<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 432<td align="left"></td> 433<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 434 Wulkiewicz, Oracle and/or its affiliates<p> 435 Distributed under the Boost Software License, Version 1.0. (See accompanying 436 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>) 437 </p> 438</div></td> 439</tr></table> 440<hr> 441<div class="spirit-nav"> 442<a accesskey="p" href="../models.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.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="model_d2_point_xy.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 443</div> 444</body> 445</html> 446