homog2d library
Functions
showcase4a.cpp File Reference

Generates two moving objects and the common bounding box. More...

#include "../../homog2d.hpp"
Include dependency graph for showcase4a.cpp:

Functions

int main (int, const char **)
 

Detailed Description

Generates two moving objects and the common bounding box.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
13 {
14  auto nbim = 25; // nb images
15  auto Hdraw = Homogr().setScale(30).addTranslation(10,10);
16 
17  auto r_w0 = 2;
18  auto r_h0 = 1;
19  auto x0 = 3.;
20 // auto y0 = 1.;
21  auto k=1.8;
22  uint8_t g = 100;
23  for( int i=0; i<nbim; i++ )
24  {
25  auto angle = i * 2. * M_PI / nbim;
26  auto x1 = std::cos(angle)*k;
27  auto y1 = std::sin(angle)*k;
28  auto r_w = r_w0 + std::sin(angle);
29 
30  FRect obj1( Point2d( x1+x0, y1+x0), r_w, r_h0 );
31  Circle obj2( Point2d(-x1+x0,-y1+x0), 2.-.5*r_w );
32  auto bcir = obj1.getBoundingCircle();
33  auto cbb = getBB(obj2);
34 
35  auto obj1_d = Hdraw * obj1;
36  auto obj2_d = Hdraw * obj2;
37  auto bcir_d = Hdraw * bcir;
38  auto cbb_d = Hdraw * cbb;
39 
40  Image<img::SvgImage> ima( 250, 200 );
41 
42  obj1_d.draw( ima, DrawParams().setColor(250,0,0) );
43  obj2_d.draw( ima, DrawParams().setColor(0,0,250) );
44  bcir_d.draw( ima, DrawParams().setColor(100,250,100) );
45  obj2_d.getBB().draw( ima, DrawParams().setColor(100,50,200) );
46 
47  auto bb = getBB(obj1_d, obj2_d);
48  bb.draw( ima, DrawParams().setColor(g,g,g) );
49  bb.getBoundingCircle().draw( ima, DrawParams().setColor(50,50,125) );
50 
51  std::ostringstream ossa;
52  ossa << "showcase4a_" << std::setfill('0') << std::setw(2) <<i << ".svg";
53  ima.write( ossa.str() );
54  }
55 }
A circle.
Definition: homog2d.hpp:378
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
#define M_PI
Definition: homog2d.hpp:235
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
HOMOG2D_INUMTYPE angle(const Ellipse_< FPT > &ell)
Return angle of ellipse (free function)
Definition: homog2d.hpp:10993
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
A Flat Rectangle, modeled by its two opposite points.
Definition: homog2d.hpp:379
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
FRect_< HOMOG2D_INUMTYPE > getBB(const T &t)
Return Bounding Box of primitive or container holding primitives (free function)
Definition: homog2d.hpp:10312
Here is the call graph for this function: