Computes the affine dimension of the convex hull of many small sets of lattice points and computes various statistics.
#include <iostream>
#include <format>
#include <vector>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/geometry/tools/GenericLatticeConvexHull.h"
{
typedef Space::Point
Point;
std::size_t nb_ok [ 4 ] = { 0, 0, 0, 0 };
std::size_t nb_per_dim [ 4 ] = { 0, 0, 0, 0 };
std::size_t nb_vertices[ 4 ] = { 0, 0, 0, 0 };
std::size_t nb_facets [ 4 ] = { 0, 0, 0, 0 };
const std::size_t nb = 100000;
for ( std::size_t n = 0; n < nb; ++n )
{
std::vector< Point > X;
int m = 2 + rand() % 9;
for ( int i = 0; i < m; i++ )
X.push_back(
Point{ rand() % 8, rand() % 8, rand() % 8 } );
QHull hull;
bool ok = hull.compute( X );
auto k = hull.affine_dimension;
nb_per_dim [ k ] += 1;
nb_vertices[ k ] += hull.positions.size();
nb_facets [ k ] += hull.facets.size();
nb_ok [ k ] += ok ? 1 : 0;
}
for ( auto k = 0; k < 4; k++ )
std::cout << std::setprecision(3) << ( 100.0 * nb_per_dim[ k ] ) / nb
<< "% are " << k << "-dimensional"
<< " #V=" << double( nb_vertices[ k ] ) / nb_per_dim[ k ]
<< " #F=" << double( nb_facets[ k ] ) / nb_per_dim[ k ]
<< " (" << nb_ok[ k ] << "/" << nb_per_dim[ k ] << ")\n";
return 0;
}
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Implements the quickhull algorithm by Barber et al. , a famous arbitrary dimensional convex hull...