• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3 
4 // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India.
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_xyz
11 //` Declaration and use of the Boost.Geometry model::d3::point_xyz, modelling the Point Concept
12 
13 #include <iostream>
14 #include <boost/geometry.hpp>
15 #include <boost/geometry/geometries/point_xyz.hpp>
16 
17 namespace bg = boost::geometry;
18 
main()19 int main()
20 {
21     bg::model::d3::point_xyz<double> point1;
22     bg::model::d3::point_xyz<double> point2(3, 4, 5); /*< 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     point1.z(4.0);
27 
28     double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/
29     double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
30     double z = point1.z();
31 
32     std::cout << x << ", " << y << ", " << z << std::endl;
33     return 0;
34 }
35 
36 //]
37 
38 
39 //[point_xyz_output
40 /*`
41 Output:
42 [pre
43 1, 2, 4
44 ]
45 */
46 //]
47