]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/segment.cpp
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
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)
12 //` Declaration and use of the Boost.Geometry model::segment, modelling the Segment Concept
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/geometries.hpp>
18 namespace bg
= boost::geometry
;
22 typedef bg::model::point
<double, 2, bg::cs::cartesian
> point_t
;
23 typedef bg::model::segment
<point_t
> segment_t
;
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. >*/
28 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
30 segment_t seg3
{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/
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);
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
);
44 std::cout
<< x0
<< ", " << y0
<< ", " << x1
<< ", " << y1
<< std::endl
;