]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | //[boost_array | |
11 | //` Shows how to use a Boost.Array using Boost.Geometry's distance, set and assign_values algorithms | |
12 | ||
13 | #include <iostream> | |
14 | ||
15 | #include <boost/geometry.hpp> | |
16 | #include <boost/geometry/geometries/linestring.hpp> | |
17 | #include <boost/geometry/geometries/adapted/boost_array.hpp> | |
18 | ||
19 | BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian) | |
20 | ||
21 | int main() | |
22 | { | |
23 | boost::array<float, 2> a = { {1, 2} }; | |
24 | boost::array<double, 2> b = { {2, 3} }; | |
25 | std::cout << boost::geometry::distance(a, b) << std::endl; | |
26 | ||
27 | boost::geometry::set<0>(a, 1.1f); | |
28 | boost::geometry::set<1>(a, 2.2f); | |
29 | std::cout << boost::geometry::distance(a, b) << std::endl; | |
30 | ||
31 | boost::geometry::assign_values(b, 2.2, 3.3); | |
32 | std::cout << boost::geometry::distance(a, b) << std::endl; | |
33 | ||
34 | boost::geometry::model::linestring<boost::array<double, 2> > line; | |
35 | line.push_back(b); | |
36 | ||
37 | return 0; | |
38 | } | |
39 | ||
40 | //] | |
41 | ||
42 | //[boost_array_output | |
43 | /*` | |
44 | Output: | |
45 | [pre | |
46 | 1.41421 | |
47 | 1.20416 | |
48 | 1.55563 | |
49 | ] | |
50 | */ | |
51 | //] |