proj home

Files   Classes   Functions   Hierarchy  

quickhull2D< PT, D > Class Template Reference

Compute the 2D convex hull of points. More...

#include <quickhull2D.h>

Collaboration diagram for quickhull2D< PT, D >:

List of all members.

Public Member Functions

 quickhull2D (vector< PT > const &_pts)
 Compute the convex hull of the point pts.

Public Attributes

vector< PT > const & pts
 Global points.
vector< uintboundary
 Points on the hull.


Detailed Description

template<typename PT, typename D>
class quickhull2D< PT, D >

Compute the 2D convex hull of points.

O(n^2) complexity in time (worst case).

Definition at line 21 of file quickhull2D.h.


Constructor & Destructor Documentation

template<typename PT , typename D >
quickhull2D< PT, D >::quickhull2D ( vector< PT > const &  _pts  )  [inline]

Compute the convex hull of the point pts.

Definition at line 110 of file quickhull2D.h.

References quickhull2D< PT, D >::boundary, halfspaceContainer< HS, PT >::isInsideOrOnBoundary(), and quickhull2D< PT, D >::pts.

00111   : pts(pts_)
00112 {
00113   uintc n(pts.size());
00114   if (n<3)
00115     return;
00116 
00117   uint x0;
00118   uint x1;
00119   findMinMax(x0,x1);
00120   boundary.push_back(x0);
00121   boundary.push_back(x1);
00122 
00123   assert(x0<n);
00124   assert(x1<n);
00125 
00126   list<uint> index;
00127   for (uint i=0; i<n; ++i)
00128   {
00129     if (i==x0)
00130       continue;
00131     if (i==x1)
00132       continue;
00133 
00134      index.push_back(i);
00135   }
00136 
00137   HSC * h1 = 
00138     new HSC( HS(pts[x0],pts[x1]) ,pts );
00139   h1->isInsideOrOnBoundary(index);
00140 
00141   HSC * h2 = 
00142     new HSC( HS(pts[x1],pts[x0]), pts );
00143   h2->isInsideOrOnBoundary(index);
00144 
00145   cs.push_back(h1);
00146   cs.push_back(h2);
00147 
00148   process();
00149 }


Member Data Documentation

template<typename PT, typename D>
vector< uint > quickhull2D< PT, D >::boundary

template<typename PT, typename D>
vector<PT> const& quickhull2D< PT, D >::pts

Global points.

Definition at line 46 of file quickhull2D.h.

Referenced by quickhull2D< PT, D >::quickhull2D().


The documentation for this class was generated from the following file:

Generated on Fri Mar 4 00:50:11 2011 for Chelton Evans Source by  doxygen 1.5.8