]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/transform.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / transform.cpp
CommitLineData
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//[transform
11//` Shows how points can be transformed using the default strategy
12
13#include <iostream>
14#include <boost/geometry.hpp>
15
16
17int main()
18{
19 namespace bg = boost::geometry;
20
21 // Select a point near the pole (theta=5.0, phi=15.0)
22 bg::model::point<long double, 2, bg::cs::spherical<bg::degree> > p1(15.0, 5.0);
23
24 // Transform from degree to radian. Default strategy is automatically selected,
25 // it will convert from degree to radian
26 bg::model::point<long double, 2, bg::cs::spherical<bg::radian> > p2;
27 bg::transform(p1, p2);
28
29 // Transform from degree (lon-lat) to 3D (x,y,z). Default strategy is automatically selected,
30 // it will consider points on a unit sphere
31 bg::model::point<long double, 3, bg::cs::cartesian> p3;
32 bg::transform(p1, p3);
33
34 std::cout
35 << "p1: " << bg::dsv(p1) << std::endl
36 << "p2: " << bg::dsv(p2) << std::endl
37 << "p3: " << bg::dsv(p3) << std::endl;
38
39 return 0;
40}
41
42//]
43
44
45//[transform_output
46/*`
47Output:
48[pre
49p1: (15, 5)
50p2: (0.261799, 0.0872665)
51p3: (0.084186, 0.0225576, 0.996195)
52]
53*/
54//]