homog2d library
Functions
showcase22.cpp File Reference

offset polygon More...

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

Functions

int main (int, const char **)
 

Detailed Description

offset polygon

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
11 {
12  auto n = 15; // nb images
13  std::vector<Point2d> vpts{
14  { -1.0, 1.0 },
15  { -1.2, -0.7 },
16  { 1.9, -0.5 },
17  { 1.6, 1.6 },
18  { 0.5, 0.8 }
19  };
20  CPolyline p0( vpts );
21 
22  auto H1 = Homogr().addTranslation(7,6).addScale(15);
23  auto H2 = Homogr().addRotation(0.8).addScale(60).addTranslation(280,100);
24  auto pol1 = H1 * p0;
25  auto pol2 = H2 * p0;
26 
27  auto delta = 5.6;
28  img::Image<img::SvgImage> im( 500, 250 );
29 
30  std::vector<CPolyline> v_poly1, v_poly2;
31  v_poly1.push_back( pol1 );
32  v_poly2.push_back( pol2 );
33 
34  im.draw( pol1, img::DrawParams().setColor(250,0,0) );
35  im.draw( pol2, img::DrawParams().setColor(0,0,250) );
36  im.write( "showcase22_00.svg" );
37 
38  for( int i=1; i<n; i++ )
39  {
40  im.clear();
41  int c = 30;
42  for( int j=0; j<(int)v_poly1.size(); j++ ) // draw previous
43  {
44  im.draw( v_poly1.at(j), img::DrawParams().setColor(c,0,250-c) );
45  im.draw( v_poly2.at(j), img::DrawParams().setColor(250-c,c,0 ) );
46  c += 10;
47  }
48  v_poly1.push_back( v_poly1.at(i-1).getOffsetPoly( delta ) );
49  v_poly2.push_back( v_poly2.at(i-1).getOffsetPoly( -delta ) );
50  im.draw( v_poly1.back(), img::DrawParams().setColor(0,250,0) );
51  im.draw( v_poly2.back(), img::DrawParams().setColor(0,0,250) );
52 #if 0
53  auto segs1= v_poly1.back().getSegs();
54  auto segs2= v_poly2.back().getSegs();
55  for ( const auto& seg: segs2 )
56  im.draw( seg.getLine(), img::DrawParams().setColor(200,200,200) );
57 #endif
58 
59  getBB( pol2, v_poly1.back() ).draw( im, img::DrawParams().setColor(150,150,200) );
60  std::ostringstream oss;
61  oss << "showcase22_" << std::setfill('0') << std::setw(2) << i << ".svg";
62  im.write( oss.str() );
63  }
64 }
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
Segment seg
Definition: homog2d_test.cpp:4033
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
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
FRect_< HOMOG2D_INUMTYPE > getBB(const T &t)
Return Bounding Box of primitive or container holding primitives (free function)
Definition: homog2d.hpp:10312
DrawParams & setColor(uint8_t r, uint8_t g, uint8_t b)
Definition: homog2d.hpp:605
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
auto getLine() const
Returns supporting line.
Definition: homog2d.hpp:5252
Here is the call graph for this function: