]>
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 | //[assign_2d_point | |
11 | //` Shows the usage of assign to set point coordinates, and, besides that, shows how you can initialize ttmath points with high precision | |
12 | ||
13 | #include <iostream> | |
14 | #include <iomanip> | |
15 | ||
16 | #include <boost/geometry.hpp> | |
17 | #include <boost/geometry/geometries/point_xy.hpp> | |
18 | ||
19 | #if defined(HAVE_TTMATH) | |
20 | # include <boost/geometry/extensions/contrib/ttmath_stub.hpp> | |
21 | #endif | |
22 | ||
23 | ||
24 | int main() | |
25 | { | |
26 | using boost::geometry::assign_values; | |
27 | ||
28 | ||
29 | boost::geometry::model::d2::point_xy<double> p1; | |
30 | assign_values(p1, 1.2345, 2.3456); | |
31 | ||
32 | #if defined(HAVE_TTMATH) | |
33 | boost::geometry::model::d2::point_xy<ttmath::Big<1,4> > p2; | |
34 | assign_values(p2, "1.2345", "2.3456"); /*< It is possible to assign coordinates with other types than the coordinate type. | |
35 | For ttmath, you can e.g. conveniently use strings. The advantage is that it then has higher precision, because | |
36 | if doubles are used for assignments the double-precision is used. | |
37 | >*/ | |
38 | #endif | |
39 | ||
40 | std::cout | |
41 | << std::setprecision(20) | |
42 | << boost::geometry::dsv(p1) << std::endl | |
43 | #if defined(HAVE_TTMATH) | |
44 | << boost::geometry::dsv(p2) << std::endl | |
45 | #endif | |
46 | ; | |
47 | ||
48 | return 0; | |
49 | } | |
50 | ||
51 | //] | |
52 | ||
53 | ||
54 | //[assign_2d_point_output | |
55 | /*` | |
56 | Output: | |
57 | [pre | |
58 | (1.2344999999999999, 2.3456000000000001) | |
59 | (1.2345, 2.3456) | |
60 | ] | |
61 | */ | |
62 | //] |