-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathshowcase4a.cpp
56 lines (45 loc) · 1.39 KB
/
showcase4a.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
51
52
53
54
55
/**
\file
\brief Generates two moving objects and the common bounding box
*/
//#define HOMOG2D_DEBUGMODE
#include "../../homog2d.hpp"
using namespace h2d;
using namespace h2d::img;
int main( int, const char** )
{
auto nbim = 25; // nb images
auto Hdraw = Homogr().setScale(30).addTranslation(10,10);
auto r_w0 = 2;
auto r_h0 = 1;
auto x0 = 3.;
// auto y0 = 1.;
auto k=1.8;
uint8_t g = 100;
for( int i=0; i<nbim; i++ )
{
auto angle = i * 2. * M_PI / nbim;
auto x1 = std::cos(angle)*k;
auto y1 = std::sin(angle)*k;
auto r_w = r_w0 + std::sin(angle);
FRect obj1( Point2d( x1+x0, y1+x0), r_w, r_h0 );
Circle obj2( Point2d(-x1+x0,-y1+x0), 2.-.5*r_w );
auto bcir = obj1.getBoundingCircle();
auto cbb = getBB(obj2);
auto obj1_d = Hdraw * obj1;
auto obj2_d = Hdraw * obj2;
auto bcir_d = Hdraw * bcir;
auto cbb_d = Hdraw * cbb;
Image<img::SvgImage> ima( 250, 200 );
obj1_d.draw( ima, DrawParams().setColor(250,0,0) );
obj2_d.draw( ima, DrawParams().setColor(0,0,250) );
bcir_d.draw( ima, DrawParams().setColor(100,250,100) );
obj2_d.getBB().draw( ima, DrawParams().setColor(100,50,200) );
auto bb = getBB(obj1_d, obj2_d);
bb.draw( ima, DrawParams().setColor(g,g,g) );
bb.getBoundingCircle().draw( ima, DrawParams().setColor(50,50,125) );
std::ostringstream ossa;
ossa << "showcase4a_" << std::setfill('0') << std::setw(2) <<i << ".svg";
ima.write( ossa.str() );
}
}