4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=windows-1252">
5 <title>Point Usage
</title>
10 <p><font face=
"Courier New">/*
<br>
11 Copyright
2008 Intel Corporation
<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>
17 #include
<boost/polygon/polygon.hpp
><br>
18 #include
<cassert
><br>
19 namespace gtl = boost::polygon;
<br>
20 using namespace boost::polygon::operators;
<br><br>
22 //constructing a gtl point
<br>
23 typedef gtl::point_data
<int
> Point;
<br>
24 int x =
10;
<br>
25 int y =
20;
<br>
26 Point pt(x, y);
<br>
27 assert(gtl::x(pt) ==
10);
<br>
28 assert(gtl::y(pt) ==
20);
<br>
30 //a quick primer in isotropic point access
<br>
31 typedef gtl::orientation_2d O;
<br>
32 using gtl::HORIZONTAL;
<br>
33 using gtl::VERTICAL;
<br>
34 O o = HORIZONTAL;
<br>
35 assert(gtl::x(pt) == gtl::get(pt, o));
<br>
37 o = o.get_perpendicular();
<br>
38 assert(o == VERTICAL);
<br>
39 assert(gtl::y(pt) == gtl::get(pt, o));
<br>
41 gtl::set(pt, o,
30);
<br>
42 assert(gtl::y(pt) ==
30);
<br>
44 //using some of the library functions
<br>
45 Point pt2(
10,
30);
<br>
46 assert(gtl::equivalence(pt, pt2));
<br>
48 gtl::transformation
<int
> tr(gtl::axis_transformation::SWAP_XY);
<br>
49 gtl::transform(pt, tr);
<br>
50 assert(gtl::equivalence(pt, Point(
30,
10)));
<br>
52 gtl::transformation
<int
> tr2 = tr.inverse();
<br>
53 assert(tr == tr2); //SWAP_XY is its own inverse transform
<br>
55 gtl::transform(pt, tr2);
<br>
56 assert(gtl::equivalence(pt, pt2)); //the two points are equal again
<br>
58 gtl::move(pt, o,
10); //move pt
10 units in y
<br>
59 assert(gtl::euclidean_distance(pt, pt2) ==
10.0f);
<br>
61 gtl::move(pt, o.get_perpendicular(),
10); //move pt
10 units in x
<br>
62 assert(gtl::manhattan_distance(pt, pt2) ==
20);
<br>
69 <table class=
"docinfo" rules=
"none" frame=
"void" id=
"table1">
71 <col class=
"docinfo-name"><col class=
"docinfo-content">
75 <th class=
"docinfo-name">Copyright:
</th>
76 <td>Copyright © Intel Corporation
2008-
2010.
</td>
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>