boost-react-native-bundle
Version:
Boost library as in https://sourceforge.net/projects/boost/files/boost/1.57.0/
77 lines (69 loc) • 3.18 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Polygon Usage</title>
</head>
<body>
<p><font face="Courier New">/*<br>
Copyright 2008 Intel Corporation<br>
<br>
Use, modification and distribution are subject to the Boost Software License,<br>
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at<br>
http://www.boost.org/LICENSE_1_0.txt).<br>
*/<br>
#include <boost/polygon/polygon.hpp><br>
#include <cassert><br>
namespace gtl = boost::polygon;<br>
using namespace boost::polygon::operators;<br><br>
int main() {<br>
//lets construct a 10x10 rectangle shaped polygon<br>
typedef gtl::polygon_data<int> Polygon;<br>
typedef gtl::polygon_traits<Polygon>::point_type Point;<br>
Point pts[] = {gtl::construct<Point>(0, 0),<br>
gtl::construct<Point>(10, 0),<br>
gtl::construct<Point>(10, 10),<br>
gtl::construct<Point>(0, 10) };<br>
Polygon poly;<br>
gtl::set_points(poly, pts, pts+4);<br>
<br>
//now lets see what we can do with this polygon<br>
assert(gtl::area(poly) == 100.0f);<br>
assert(gtl::contains(poly, gtl::construct<Point>(5, 5)));<br>
assert(!gtl::contains(poly, gtl::construct<Point>(15, 5)));<br>
gtl::rectangle_data<int> rect;<br>
assert(gtl::extents(rect, poly)); //get bounding box of poly<br>
assert(gtl::equivalence(rect, poly)); //hey, that's slick<br>
assert(gtl::winding(poly) == gtl::COUNTERCLOCKWISE);<br>
assert(gtl::perimeter(poly) == 40.0f);<br>
<br>
//add 5 to all coords of poly<br>
gtl::convolve(poly, gtl::construct<Point>(5, 5));<br>
//multiply all coords of poly by 2<br>
gtl::scale_up(poly, 2);<br>
gtl::set_points(rect, gtl::point_data<int>(10, 10),<br>
gtl::point_data<int>(30, 30));<br>
assert(gtl::equivalence(poly, rect));<br>
return 0;<br>
}<br>
//Now you know how to use the built in polygon data type<br>
</font></p>
<table class="docinfo" rules="none" frame="void" id="table1">
<colgroup>
<col class="docinfo-name"><col class="docinfo-content">
</colgroup>
<tbody vAlign="top">
<tr>
<th class="docinfo-name">Copyright:</th>
<td>Copyright � Intel Corporation 2008-2010.</td>
</tr>
<tr class="field">
<th class="docinfo-name">License:</th>
<td class="field-body">Distributed under the Boost Software License,
Version 1.0. (See accompanying file <tt class="literal">
<span class="pre">LICENSE_1_0.txt</span></tt> or copy at
<a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>)</td>
</tr>
</table>
</body>
</html>