Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Vertices of Convex_hull_d

Subject: CGAL users discussion list

List archive

[cgal-discuss] Vertices of Convex_hull_d


Chronological Thread 
  • From: <>
  • To:
  • Subject: [cgal-discuss] Vertices of Convex_hull_d
  • Date: Tue, 2 Dec 2008 10:28:10 +0100 (CET)

Hi,

I'd like to find vertices of convex hull of points in arbitrary dimension
using
Convex_hull_d. I just tried the 9 points of square centered at the origin.
Obviously, I should get 4 points, but I'm getting 8. Any thought?
Here goes the code that I tried.

Thanks,

#include <iostream>
#include <vector>

#include <CGAL/Cartesian.h>
#include <CGAL/Convex_hull_d.h>
#include <CGAL/Cartesian_d.h>

using namespace std;
using namespace CGAL;

int main()
{

Convex_hull_d< Cartesian_d<double> > A(2);

vector< vector<int> > V;
vector<int> vi(DIM);

vi[0]=-1; vi[1]=1; V.push_back(vi);
vi[0]=0; vi[1]=1; V.push_back(vi);
vi[0]=1; vi[1]=1; V.push_back(vi);

vi[0]=-1; vi[1]=0; V.push_back(vi);
vi[0]=0; vi[1]=0; V.push_back(vi);
vi[0]=1; vi[1]=0; V.push_back(vi);

vi[0]=-1; vi[1]=-1; V.push_back(vi);
vi[0]=0; vi[1]=-1; V.push_back(vi);
vi[0]=1; vi[1]=-1; V.push_back(vi);

for( vector< vector<int> >::iterator it=V.begin(); it!=V.end(); it++
){
Point_d< Cartesian_d<double> >
pot(DIM,(*it).begin(),(*it).end());
A.insert(pot);
}

for( Convex_hull_d< Cartesian_d<double> >::Hull_vertex_iterator
it=A.hull_vertices_begin() ; it!=A.hull_vertices_end(); it++ )
cout << A.associated_point(it) << endl;

return 0;
}



Archive powered by MHonArc 2.6.16.

Top of Page