#### /Src/Dependencies/Boost/libs/geometry/doc/src/examples/algorithms/transform_with_strategy.cpp

C++ | 63 lines | 24 code | 16 blank | 23 comment | 0 complexity | bdf4919697cfbda3dc52d731f157cd5a MD5 | raw file
``` 1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// QuickBook Example
3
4// Copyright (c) 2011 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
9
10//[transform_with_strategy
11//` Shows how points can be scaled, translated or rotated
12
13#include <iostream>
14#include <boost/geometry.hpp>
15
16
17int main()
18{
19    namespace trans = boost::geometry::strategy::transform;
20    using boost::geometry::dsv;
21
22    typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> point_type;
23
24    point_type p1(1.0, 1.0);
25
26    // Translate over (1.5, 1.5)
27    point_type p2;
28    trans::translate_transformer<point_type, point_type> translate(1.5, 1.5);
29    boost::geometry::transform(p1, p2, translate);
30
31    // Scale with factor 3.0
32    point_type p3;
33    trans::scale_transformer<point_type, point_type> scale(3.0);
34    boost::geometry::transform(p1, p3, scale);
35
36    // Rotate with respect to the origin (0,0) over 90 degrees (clockwise)
37    point_type p4;
38    trans::rotate_transformer<point_type, point_type, boost::geometry::degree> rotate(90.0);
39    boost::geometry::transform(p1, p4, rotate);
40
41    std::cout
42        << "p1: " << dsv(p1) << std::endl
43        << "p2: " << dsv(p2) << std::endl
44        << "p3: " << dsv(p3) << std::endl
45        << "p4: " << dsv(p4) << std::endl;
46
47    return 0;
48}
49
50//]
51
52
53//[transform_with_strategy_output
54/*`
55Output:
56[pre
57p1: (1, 1)
58p2: (2.5, 2.5)
59p3: (3, 3)
60p4: (1, -1)
61]
62*/
63//]
```