-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathshowcase13.cpp
51 lines (42 loc) · 1.41 KB
/
showcase13.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
\file
\brief Generates random points, the Convex Hull, the Bounding Box, the Minimum Enclosing Circle (MEC), and the extremum points
*/
//#define HOMOG2D_DEBUGMODE
#include "../../homog2d.hpp"
using namespace h2d;
int main( int, const char** )
{
auto nbim = 20; // nb images
auto cmax = 250;
auto cmin = 50;
auto nbpts_max = 50;
auto nbpts_min = 5;
auto extr_col = img::DrawParams().setColor(100,250,0).setPointStyle( img::PtStyle::Dot );
for( int i=0; i<nbim; i++ )
{
img::Image<img::SvgImage> im( cmax+30, cmax+30 );
int nbpts = 1.0*rand() / RAND_MAX * (nbpts_max-nbpts_min) + nbpts_min;
std::vector<Point2d> vec(nbpts);
auto it = std::begin(vec);
for( auto j=0; j<nbpts; j++ )
*it++ = Point2d(
1.0*rand() / RAND_MAX * (cmax-cmin) + cmin,
1.0*rand() / RAND_MAX * (cmax-cmin) + cmin
);
auto ch = convexHull( vec );
draw( im, vec );
ch.draw( im, img::DrawParams().setColor(250,100,100) );
getBB(vec).draw( im, img::DrawParams().setColor(100,100,250) );
Circle cir;
cir.set( vec ); // Minimum Enclosing Circle (MEC)
cir.draw( im, img::DrawParams().setColor(0,100,150) );
getTmPoint(vec).first.draw( im, extr_col );
getRmPoint(vec).first.draw( im, extr_col );
getLmPoint(vec).first.draw( im, extr_col );
getBmPoint(vec).first.draw( im, extr_col );
std::ostringstream oss;
oss << "showcase13_" << std::setfill('0') << std::setw(2) << i << ".svg";
im.write( oss.str() );
}
}