18 for (
unsigned int s = 0; s < poly.
num_sheets(); ++s )
19 for (
unsigned int i = 0, j = (
unsigned int)(poly[s].size()-1); i < poly[s].size(); j=i++ )
20 area += poly[s][j].x() * poly[s][i].y() - poly[s][i].x() * poly[s][j].y();
32 for (
unsigned int s = 0; s < poly.
num_sheets(); ++s ){
33 for (
unsigned int i = 0, j = (
unsigned int)(poly[s].size()-1); i < poly[s].size(); j=i++ ){
34 T w = poly[s][j].x() * poly[s][i].y() - poly[s][i].x() * poly[s][j].y();
35 x += (poly[s][j].x() + poly[s][i].x())*w;
36 y += (poly[s][j].y() + poly[s][i].y())*w;
52 return area<0 ? -area : area;
67 for (
unsigned int t = 0; t < poly.
num_sheets(); ++t)
73 for (
unsigned int i = 0, j = (
unsigned int)(test_pgon.size()-1); i < test_pgon.size(); j=i++ )
74 t_area += test_pgon[j].x() * test_pgon[i].y() - test_pgon[i].x() * test_pgon[j].y();
79 T x = test_pgon[0].x();
80 T y = test_pgon[0].y();
81 for (
unsigned int s = 0; s < poly.
num_sheets(); ++s)
88 unsigned int n = (
unsigned int)(pgon.size());
90 for (
unsigned int i = 0, j = n-1; i < n; j = i++)
92 if ((((pgon[i].y() <= y) && (y < pgon[j].y())) || ((pgon[j].y() <= y) && (y < pgon[i].y()))) &&
93 (x < (pgon[j].x() - pgon[i].x()) * (y - pgon[i].y()) / (pgon[j].y() - pgon[i].y()) + pgon[i].x()))
101 if ( (!is_hole && t_area < 0) || (is_hole && t_area > 0))
116 return wh.first * wh.second;
119 #undef VGL_AREA_INSTANTIATE 120 #define VGL_AREA_INSTANTIATE(T) \ 121 template T vgl_area(vgl_polygon<T > const&); \ 122 template T vgl_area_signed(vgl_polygon<T > const&); \ 123 template T vgl_area_enforce_orientation(vgl_polygon<T > const&); \ 124 template vgl_point_2d<T > vgl_centroid(vgl_polygon<T > const&); \ 125 template T vgl_area( const vgl_box_2d<T>& box ); \ 126 template T vgl_area( const vgl_oriented_box_2d<T>& obox ) 127 #endif // vgl_area_hxx_ a point in 2D nonhomogeneous space
vgl_point_2d< T > vgl_centroid(vgl_polygon< T > const &poly)
The area weighted center of a polygon.
Type width() const
Get width of this box (= x dimension).
std::pair< T, T > width_height() const
return width (first) and height (second).
T vgl_area_signed(vgl_polygon< T > const &poly)
Computes the signed area of a polygon.
Contains class to represent a cartesian 2D bounding box.
Type height() const
Get height of this box (= y dimension).
T vgl_area_enforce_orientation(vgl_polygon< T > const &poly)
The orientation enforced area of a polygon.
std::vector< point_t > sheet_t
unsigned int num_sheets() const
T vgl_area(vgl_polygon< T > const &poly)
The area of a polygon.
An orienteded box in 2-d.