]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/segment.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / segment.cpp
1 // Boost.Geometry
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 //[segment
12 //` Declaration and use of the Boost.Geometry model::segment, modelling the Segment Concept
13
14 #include <iostream>
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/geometries.hpp>
17
18 namespace bg = boost::geometry;
19
20 int main()
21 {
22 typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
23 typedef bg::model::segment<point_t> segment_t;
24
25 segment_t seg1; /*< Default-construct a segment. >*/
26 segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning the first and the second point. >*/
27
28 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
29
30 segment_t seg3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/
31
32 #endif
33
34 bg::set<0, 0>(seg1, 1.0); /*< Set a coordinate. >*/
35 bg::set<0, 1>(seg1, 2.0);
36 bg::set<1, 0>(seg1, 3.0);
37 bg::set<1, 1>(seg1, 4.0);
38
39 double x0 = bg::get<0, 0>(seg1); /*< Get a coordinate. >*/
40 double y0 = bg::get<0, 1>(seg1);
41 double x1 = bg::get<1, 0>(seg1);
42 double y1 = bg::get<1, 1>(seg1);
43
44 std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl;
45
46 return 0;
47 }
48
49 //]
50
51
52 //[segment_output
53 /*`
54 Output:
55 [pre
56 1, 2, 3, 4
57 ]
58 */
59 //]