homog2d library
Functions
showcase9.cpp File Reference

Generates two moving circles and the tangential segments. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates two moving circles and the tangential segments.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
13 {
14  auto nbim = 25; // nb images
15  auto rad_0 = 20;
16  auto x0 = 110;
17  auto y0 = 90;
18  auto k1=70;
19  auto k2=15;
20  uint8_t g = 180;
21  Circle cir1( 120, 80, 25 );
22 
23  for( int i=0; i<nbim; i++ )
24  {
25  auto angle = i * 2. * M_PI / nbim;
26  auto x1 = std::cos(angle)*k1;
27  auto y1 = std::sin(angle)*k1;
28  auto rad = rad_0 + std::sin(angle)*k2;
29 
30  Circle cir2( Point2d(x0+x1, y0+y1), rad );
31 
32  Image<img::SvgImage> im( 250, 220 );
33  auto seg = getSegment( cir1, cir2 ); //.draw( im, DrawParams().setColor(150,150,0) );
34  seg.draw( im, DrawParams().setColor(150,150,0) );
35 
36  cir1.draw( im, DrawParams().setColor(250,0,0) );
37  cir2.draw( im, DrawParams().setColor(0,0,250) );
38 
39  getBB(cir1, cir2).draw( im, DrawParams().setColor(g,g,g) );
40 
41  auto lightgray = DrawParams().setColor(200,200,200);
42  seg.getLine().getOrthogLine( seg.getPts().first ).draw( im, lightgray );
43  seg.getLine().getOrthogLine( seg.getPts().second ).draw( im, lightgray );
44 
45  auto segs = getTanSegs(cir1,cir2);
46  draw( im, segs.first, DrawParams().setColor(250,250,0) );
47  draw( im, segs.second, DrawParams().setColor(0,250,250) );
48  std::ostringstream oss;
49  oss << "showcase9_" << std::setfill('0') << std::setw(2) <<i << ".svg";
50  im.write( oss.str() );
51  }
52 }
A circle.
Definition: homog2d.hpp:378
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
Segment seg
Definition: homog2d_test.cpp:4033
#define M_PI
Definition: homog2d.hpp:235
void draw(img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const
Definition: homog2d.hpp:11868
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
std::pair< Segment_< FPT1 >, Segment_< FPT1 > > getTanSegs(const Circle_< FPT1 > &c1, const Circle_< FPT2 > &c2)
Free function, returns the pair of segments tangential to the two circles.
Definition: homog2d.hpp:10793
Segment_< typename T1::FType > getSegment(const T1 &c1, const T2 &c2)
Free function, returns segment between two circle centers (or ellipse)
Definition: homog2d.hpp:10688
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
PointPair_< FPT > getPts() const
Returns the points of segment as a std::pair.
Definition: homog2d.hpp:5197
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
auto getLine() const
Returns supporting line.
Definition: homog2d.hpp:5252
Here is the call graph for this function: