homog2d library
Functions
showcase20.cpp File Reference

Three circles, one fixed and two whose center rotates. Fixed radius. It shows the line formed by intersections points. The three lines intersect at same point (black). More...

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

Functions

int main (int, const char **)
 

Detailed Description

Three circles, one fixed and two whose center rotates. Fixed radius. It shows the line formed by intersections points. The three lines intersect at same point (black).

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
14 {
15  auto nbim = 25; // nb images
16 
17  uint8_t m = 240;
18 
19  CPolyline pol( 50, 3 );
20  pol.translate( 150, 160 );
21  auto pts = pol.getPts();
22  auto pt0 = pts[0];
23  auto pt1 = pts[1];
24  auto pt2 = pts[2];
25 
26  auto k1=6;
27  auto k2=12;
28 
29  auto rad0 = 65;
30  auto rad1 = 70;
31  auto rad2 = 83;
32  for( int i=0; i<nbim; i++ )
33  {
34  Image<img::SvgImage> im( 320, 320 );
35 
36  auto angle = 2. * M_PI * i / nbim;
37  auto xr1 = std::cos(angle)*k1;
38  auto yr1 = std::sin(angle)*k1;
39  auto xr2 = std::cos(angle)*k2;
40  auto yr2 = std::sin(angle)*k2;
41 
42  Point2d p2( pt2 );
43  Point2d p1( pt1 );
44  p1.translate( xr1, -yr1 );
45  p2.translate( xr2, yr2 );
46 
47  Circle cir1( p1, rad1 );
48  Circle cir2( p2, rad2 );
49  Circle cir0( pt0, rad0 );
50 
51  std::array<Circle,3> arr;
52  arr[0] = cir0;
53  arr[1] = cir1;
54  arr[2] = cir2;
55  draw( im, getBB( arr ), DrawParams().setColor(220,220,220) );
56 
57 #if 0
58  p1.draw( im, DrawParams().setColor(250,0,0) );
59  p2.draw( im, DrawParams().setColor(0,0,250) );
60  pt0.draw( im, DrawParams().setColor(0,250,0) );
61 #endif
62  auto int01 = cir0.intersects(cir1).get();
63  auto int02 = cir0.intersects(cir2).get();
64  auto int12 = cir2.intersects(cir1).get();
65 
66  auto li01 = int01[0] * int01[1];
67  auto li02 = int02[0] * int02[1];
68  auto li12 = int12[0] * int12[1];
69 
70  li01.draw( im, DrawParams().setColor(m,m,0) );
71  li02.draw( im, DrawParams().setColor(0,m,m) );
72  li12.draw( im, DrawParams().setColor(m,0,m) );
73 
74  draw( im, getTanSegs( cir0, cir1 ), DrawParams().setColor(m,m,m/3) );
75  draw( im, getTanSegs( cir0, cir2 ), DrawParams().setColor(m/3,m,m) );
76  draw( im, getTanSegs( cir1, cir2 ), DrawParams().setColor(m,m/3,m) );
77 
78  cir0.draw( im, DrawParams().setColor(0,250,0) );
79  cir1.draw( im, DrawParams().setColor(250,0,0) );
80  cir2.draw( im, DrawParams().setColor(0,0,250) );
81 
82  auto centerpt = li01 * li02;
83  centerpt.draw( im, DrawParams().setColor(0,0,0).setPointStyle(PtStyle::Dot) );
84 
85  std::ostringstream oss;
86  oss << "showcase20_" << std::setfill('0') << std::setw(2) << i << ".svg";
87  im.write( oss.str() );
88  }
89 }
A circle.
Definition: homog2d.hpp:378
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
#define M_PI
Definition: homog2d.hpp:235
CPolyline pol(5, 5u)
void translate(TX dx, TY dy)
Translate Polyline using dx, dy.
Definition: homog2d.hpp:6411
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
std::vector< Point2d_< FPT > > & getPts()
Returns the points (reference)
Definition: homog2d.hpp:6295
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
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
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: