• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3 
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 //[point_xy
11 //` Declaration and use of the Boost.Geometry model::d2::point_xy, modelling the Point Concept
12 
13 #include <iostream>
14 #include <boost/geometry.hpp>
15 #include <boost/geometry/geometries/point_xy.hpp>
16 
17 namespace bg = boost::geometry;
18 
main()19 int main()
20 {
21     bg::model::d2::point_xy<double> point1;
22     bg::model::d2::point_xy<double> point2(1.0, 2.0); /*< Construct, assigning coordinates. >*/
23 
24     bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/
25     point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/
26 
27     double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/
28     double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
29 
30     std::cout << x << ", " << y << std::endl;
31     return 0;
32 }
33 
34 //]
35 
36 
37 //[point_xy_output
38 /*`
39 Output:
40 [pre
41 1, 2
42 ]
43 */
44 //]
45