]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/polygon/doc/gtl_point_usage.htm
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / polygon / doc / gtl_point_usage.htm
1 <html>
2
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
5 <title>Point Usage</title>
6 </head>
7
8 <body>
9
10 <p><font face="Courier New">/*<br>
11 Copyright 2008 Intel Corporation<br>
12 <br>
13 Use, modification and distribution are subject to the Boost Software License,<br>
14 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at<br>
15 http://www.boost.org/LICENSE_1_0.txt).<br>
16 */<br>
17 #include &lt;boost/polygon/polygon.hpp&gt;<br>
18 #include &lt;cassert&gt;<br>
19 namespace gtl = boost::polygon;<br>
20 using namespace boost::polygon::operators;<br><br>
21 int main() {<br>
22 &nbsp; //constructing a gtl point<br>
23 &nbsp; typedef gtl::point_data&lt;int&gt; Point;<br>
24 &nbsp; int x = 10;<br>
25 &nbsp; int y = 20;<br>
26 &nbsp; Point pt(x, y);<br>
27 &nbsp; assert(gtl::x(pt) == 10);<br>
28 &nbsp; assert(gtl::y(pt) == 20);<br>
29 &nbsp; <br>
30 &nbsp; //a quick primer in isotropic point access<br>
31 &nbsp; typedef gtl::orientation_2d O;<br>
32 &nbsp; using gtl::HORIZONTAL;<br>
33 &nbsp; using gtl::VERTICAL;<br>
34 &nbsp; O o = HORIZONTAL;<br>
35 &nbsp; assert(gtl::x(pt) == gtl::get(pt, o));<br>
36 &nbsp; <br>
37 &nbsp; o = o.get_perpendicular();<br>
38 &nbsp; assert(o == VERTICAL);<br>
39 &nbsp; assert(gtl::y(pt) == gtl::get(pt, o));<br>
40 <br>
41 &nbsp; gtl::set(pt, o, 30);<br>
42 &nbsp; assert(gtl::y(pt) == 30);<br>
43 <br>
44 &nbsp; //using some of the library functions<br>
45 &nbsp; Point pt2(10, 30);<br>
46 &nbsp; assert(gtl::equivalence(pt, pt2));<br>
47 <br>
48 &nbsp; gtl::transformation&lt;int&gt; tr(gtl::axis_transformation::SWAP_XY);<br>
49 &nbsp; gtl::transform(pt, tr);<br>
50 &nbsp; assert(gtl::equivalence(pt, Point(30, 10)));<br>
51 <br>
52 &nbsp; gtl::transformation&lt;int&gt; tr2 = tr.inverse();<br>
53 &nbsp; assert(tr == tr2); //SWAP_XY is its own inverse transform<br>
54 <br>
55 &nbsp; gtl::transform(pt, tr2);<br>
56 &nbsp; assert(gtl::equivalence(pt, pt2)); //the two points are equal again<br>
57 <br>
58 &nbsp; gtl::move(pt, o, 10); //move pt 10 units in y<br>
59 &nbsp; assert(gtl::euclidean_distance(pt, pt2) == 10.0f);<br>
60 <br>
61 &nbsp; gtl::move(pt, o.get_perpendicular(), 10); //move pt 10 units in x<br>
62 &nbsp; assert(gtl::manhattan_distance(pt, pt2) == 20);<br>
63 <br>
64 &nbsp; return 0;<br>
65 }<br>
66 &nbsp;</font></p>
67
68
69 <table class="docinfo" rules="none" frame="void" id="table1">
70 <colgroup>
71 <col class="docinfo-name"><col class="docinfo-content">
72 </colgroup>
73 <tbody vAlign="top">
74 <tr>
75 <th class="docinfo-name">Copyright:</th>
76 <td>Copyright © Intel Corporation 2008-2010.</td>
77 </tr>
78 <tr class="field">
79 <th class="docinfo-name">License:</th>
80 <td class="field-body">Distributed under the Boost Software License,
81 Version 1.0. (See accompanying file <tt class="literal">
82 <span class="pre">LICENSE_1_0.txt</span></tt> or copy at
83 <a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
84 http://www.boost.org/LICENSE_1_0.txt</a>)</td>
85 </tr>
86 </table>
87
88 </body>
89
90 </html>