homog2d library
Functions
showcase4b.cpp File Reference

Generates rotating rectangle and its bounding circle. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates rotating rectangle and its bounding circle.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto nbim = 25; // nb images
14  auto Hdraw = Homogr().setScale(30).addTranslation(10,10);
15 
16  auto r_w0 = 2;
17  auto r_h0 = 1;
18  auto x0 = 3.;
19  auto k=1.8;
20 
21  for( int i=0; i<nbim; i++ )
22  {
23  auto angle = i*360./nbim;
24  auto angle_r = angle * M_PI / 180.;
25  auto x1 = std::cos(angle_r)*k;
26  auto y1 = std::sin(angle_r)*k;
27  auto r_w = r_w0 + std::sin( 2.*M_PI*i/nbim );
28 
29  FRect rect( Point2d( x1+x0, y1+x0), r_w, r_h0 );
30 
31  auto cir_b = rect.getBoundingCircle();
32  auto cir_i = rect.getInscribedCircle();
33 
34  img::Image<img::SvgImage> imb( 250, 200 );
35 
36  (Hdraw * cir_b).draw( imb, img::DrawParams().setColor(50,250,50) );
37  (Hdraw * cir_i).draw( imb, img::DrawParams().setColor(50,25,250) );
38  (Hdraw * rect).draw( imb, img::DrawParams().setColor(250,25,25) );
39 
40  std::ostringstream ossb;
41  ossb << "showcase4b_" << std::setfill('0') << std::setw(2) <<i << ".svg";
42  imb.write( ossb.str() );
43  }
44 }
Circle_< FPT > getBoundingCircle() const
Return circle passing through 4 points of flat rectangle.
Definition: homog2d.hpp:2783
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
#define M_PI
Definition: homog2d.hpp:235
FRect rect
Definition: homog2d_test.cpp:4038
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
Circle_< FPT > getInscribedCircle() const
Return circle inscribed in rectangle.
Definition: homog2d.hpp:2791
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
DrawParams & setColor(uint8_t r, uint8_t g, uint8_t b)
Definition: homog2d.hpp:605
Here is the call graph for this function: