summaryrefslogtreecommitdiff
path: root/libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp')
-rw-r--r--libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp b/libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp
new file mode 100644
index 000000000..b03dc0519
--- /dev/null
+++ b/libs/geometry/doc/src/examples/algorithms/assign_2d_point.cpp
@@ -0,0 +1,62 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// QuickBook Example
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[assign_2d_point
+//` Shows the usage of assign to set point coordinates, and, besides that, shows how you can initialize ttmath points with high precision
+
+#include <iostream>
+#include <iomanip>
+
+#include <boost/geometry.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#if defined(HAVE_TTMATH)
+# include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
+#endif
+
+
+int main()
+{
+ using boost::geometry::assign_values;
+
+
+ boost::geometry::model::d2::point_xy<double> p1;
+ assign_values(p1, 1.2345, 2.3456);
+
+#if defined(HAVE_TTMATH)
+ boost::geometry::model::d2::point_xy<ttmath::Big<1,4> > p2;
+ assign_values(p2, "1.2345", "2.3456"); /*< It is possible to assign coordinates with other types than the coordinate type.
+ For ttmath, you can e.g. conveniently use strings. The advantage is that it then has higher precision, because
+ if doubles are used for assignments the double-precision is used.
+ >*/
+#endif
+
+ std::cout
+ << std::setprecision(20)
+ << boost::geometry::dsv(p1) << std::endl
+#if defined(HAVE_TTMATH)
+ << boost::geometry::dsv(p2) << std::endl
+#endif
+ ;
+
+ return 0;
+}
+
+//]
+
+
+//[assign_2d_point_output
+/*`
+Output:
+[pre
+(1.2344999999999999, 2.3456000000000001)
+(1.2345, 2.3456)
+]
+*/
+//]