homog2d library
Functions
showcase7.cpp File Reference

shows isInside circles vs polyline More...

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

Functions

int main (int, const char **)
 

Detailed Description

shows isInside circles vs polyline

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto n = 25; // nb images
14  Circle cir( 3. );
15 
16  std::vector<Point2d> vpts{
17  { -1.0, 1.0 },
18  { -1.2, -0.7 },
19  { 1.8, -0.5 },
20  { 1.6, 1.1 },
21  { 0.5, 0.8 }
22  };
23  CPolyline pl( vpts );
24 
25  auto Hdraw = Homogr().addTranslation(7,6).addScale(15);
26 
27  img::Image<img::SvgImage> im( 300, 200 );
28 
29  auto col_outside = img::DrawParams().setColor(50,20,200);
30  auto col_inside = img::DrawParams().setColor(200,20,20).setThickness(2);
31  auto coeff_x = 1.12;
32  auto coeff_y = 1.16;
33  Homogr H1 = Homogr().addScale( coeff_x, coeff_y );
34  Homogr H2 = Homogr().addScale( 1./coeff_x, 1./coeff_y );
35 
36  for( int i=0; i<n; i++ )
37  {
38  im.clear();
39  auto pl2 = Hdraw * pl;
40  auto cir2 = Hdraw * cir;
41 
42  auto col_c = col_outside;
43  if( cir.isInside( pl ) )
44  col_c = col_inside;
45 
46  auto col_p = col_outside;
47  if( pl.isInside( cir ) )
48  col_p = col_inside;
49 
50  pl2.draw( im, col_p );
51  cir2.draw( im, col_c );
52 
53  auto inter = cir.intersects(pl);
54  if( inter() )
55  {
56  auto inter_pts = inter.get();
57  for( const auto& pt: inter.get() )
58  {
59  auto pt2 = Hdraw * pt;
60  pt2.draw( im );
61  }
62  }
63  if( i<n/2 )
64  pl = H1*pl;
65  else
66  pl = H2*pl;
67 
68  std::ostringstream oss;
69  oss << "showcase7_" << std::setfill('0') << std::setw(2) <<i << ".svg";
70  im.write( oss.str() );
71  }
72 }
A circle.
Definition: homog2d.hpp:378
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
A 2D homography, defining a planar transformation.
Definition: homog2d.hpp:369
DrawParams & setThickness(uint8_t t)
Definition: homog2d.hpp:600
void draw(img::Image< img::SvgImage > &im, img::DrawParams dp=img::DrawParams()) const
SVG draw function.
Definition: homog2d.hpp:4414
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
void draw(img::Image< cv::Mat > &, img::DrawParams=img::DrawParams()) const
Draw Circle (Opencv implementation)
Definition: homog2d.hpp:11907
img::Image< img::SvgImage > im(300, 400)
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
std::array< FPT, 3 > get() const
Definition: homog2d.hpp:4203
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Point2d pt
Definition: homog2d_test.cpp:4034
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function: