FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
geometry/example/06_a_transformation_example.cpp at develop · boostorg/geometry · GitHub
boostorg
geometry
Repository navigation
Code
Issues
145
(145)
Pull requests
14
(14)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
geometry
/
example
/
06_a_transformation_example.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (42 loc) · 1.94 KB
Breadcrumbs
geometry
/
example
/
06_a_transformation_example.cpp
Copy path
File metadata and controls
56 lines (42 loc) · 1.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
Boost.Geometry (aka GGL, Generic Geometry Library)
//
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
//
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
//
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
//
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)
//
//
Transformation Example
#
include
<
iostream
>
#
include
<
boost/geometry/geometry.hpp
>
#
include
<
boost/geometry/geometries/point_xy.hpp
>
#
include
<
boost/geometry/geometries/polygon.hpp
>
#
include
<
boost/geometry/geometries/adapted/c_array.hpp
>
BOOST_GEOMETRY_REGISTER_C_ARRAY_CS
(cs::cartesian)
int
main
()
{
using
namespace
boost
::geometry
;
typedef
model::d2::point_xy<
double
> point_2d;
point_2d
p
(
1
,
1
);
point_2d p2;
//
Example: translate a point over (5,5)
strategy::transform::translate_transformer<
double
,
2
,
2
>
translate
(
5
,
5
);
transform
(p, p2, translate);
std::cout <<
"
transformed point
"
<<
boost::geometry::dsv
(p2) << std::endl;
//
Transform a polygon
model::polygon<point_2d> poly, poly2;
const
double
coor[][
2
] = { {
0
,
0
}, {
0
,
7
}, {
2
,
2
}, {
2
,
0
}, {
0
,
0
} };
//
note that for this syntax you have to include the two
//
include files above (c_array.hpp)
assign_points
(poly, coor);
//
read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);
transform
(poly, poly2, translate);
std::cout <<
"
source polygon
"
<<
boost::geometry::dsv
(poly) << std::endl;
std::cout <<
"
transformed polygon
"
<<
boost::geometry::dsv
(poly2) << std::endl;
//
Many more transformations are possible:
//
- from Cartesian to Spherical coordinate systems and back
//
- from Cartesian to Cartesian (mapping, affine transformations) and back (inverse)
//
- Map Projections
//
- from Degree to Radian and back in spherical_equatorial or geographic coordinate systems
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL