mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-13 12:32:09 +00:00
Added and updated documentation of correct, transform, distance, comparable_distance
[SVN r71153]
This commit is contained in:
63
doc/src/examples/algorithms/transform_with_strategy.cpp
Normal file
63
doc/src/examples/algorithms/transform_with_strategy.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 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)
|
||||
|
||||
//[transform_with_strategy
|
||||
//` Shows how points can be scaled, translated or rotated
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace trans = boost::geometry::strategy::transform;
|
||||
using boost::geometry::dsv;
|
||||
|
||||
typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> point_type;
|
||||
|
||||
point_type p1(1.0, 1.0);
|
||||
|
||||
// Translate over (1.5, 1.5)
|
||||
point_type p2;
|
||||
trans::translate_transformer<point_type, point_type> translate(1.5, 1.5);
|
||||
boost::geometry::transform(p1, p2, translate);
|
||||
|
||||
// Scale with factor 3.0
|
||||
point_type p3;
|
||||
trans::scale_transformer<point_type, point_type> scale(3.0);
|
||||
boost::geometry::transform(p1, p3, scale);
|
||||
|
||||
// Rotate with respect to the origin (0,0) over 90 degrees (clockwise)
|
||||
point_type p4;
|
||||
trans::rotate_transformer<point_type, point_type, boost::geometry::degree> rotate(90.0);
|
||||
boost::geometry::transform(p1, p4, rotate);
|
||||
|
||||
std::cout
|
||||
<< "p1: " << dsv(p1) << std::endl
|
||||
<< "p2: " << dsv(p2) << std::endl
|
||||
<< "p3: " << dsv(p3) << std::endl
|
||||
<< "p4: " << dsv(p4) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[transform_with_strategy_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
p1: (1, 1)
|
||||
p2: (2.5, 2.5)
|
||||
p3: (3, 3)
|
||||
p4: (1, -1)
|
||||
]
|
||||
*/
|
||||
//]
|
||||
Reference in New Issue
Block a user