Boost logo

Geometry :

Subject: [ggl] Iterating over polygon vertices.
From: Jack Liddle (jackliddlephysics)
Date: 2010-04-12 11:21:08


I have a polygon of type 'polygon_2d' and I want to be able to loop
over the vertices of the Polygon. I can't for the life of me figure
out how to get at the vertices making up the polygon.

I would for any assistance with this.


Jack Liddle

#include <iostream>
#include <stdio.h>
#include <vector>

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>

using namespace boost::geometry;
using namespace std;

int main()
   polygon_2d poly;

   append(poly, make<point_2d>(2.8, 1.9));
   append(poly, make<point_2d>(2.9, 2.4));
   append(poly, make<point_2d>(3.3, 2.2));
   append(poly, make<point_2d>(3.2, 1.8));
   append(poly, make<point_2d>(2.8, 1.9));

Geometry list run by mateusz at