homog2d library
Functions
showcase15.cpp File Reference

random points and a moving point, draw the nearest/farthest point segment More...

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

Functions

int main (int, const char **)
 

Detailed Description

random points and a moving point, draw the nearest/farthest point segment

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto nbim = 20; // nb images
14 
15  auto cmax = 300;
16  auto cmin = 20;
17 
18  int nbPts = 30;
19  std::vector<Point2d> vec(nbPts);
20  auto it = std::begin(vec);
21  for( auto i=0; i<nbPts; i++ )
22  *it++ = Point2d(
23  1.0*rand() / RAND_MAX * (cmax-cmin) + cmin,
24  1.0*rand() / RAND_MAX * (cmax-cmin) + cmin
25  );
26  auto k = 70.;
27  auto x0 = 150;
28  auto y0 = 150;
29 
30  for( int i=0; i<nbim; i++ )
31  {
32  img::Image<img::SvgImage> im( cmax+30, cmax+30 );
33 
34 
35  draw( im, vec );
36 
37  auto angle = i*360./nbim;
38  auto angle_r = angle * M_PI / 180.;
39  auto x1 = std::cos(angle_r)*k;
40  auto y1 = std::sin(angle_r)*k;
41  Point2d pt( x1+x0,y1+y0);
42  pt.draw( im, img::DrawParams().setColor(250,0,0).setPointStyle( img::PtStyle::Dot ) );
43  auto pidx = findNearestFarthestPoint( pt, vec );
44  Segment(vec[pidx.first], pt).draw( im, img::DrawParams().setColor( 250,0,0) );
45  Segment(vec[pidx.second], pt).draw( im, img::DrawParams().setColor( 0,250,0) );
46 
47  std::ostringstream oss;
48  oss << "showcase15_" << std::setfill('0') << std::setw(2) << i << ".svg";
49  im.write( oss.str() );
50  }
51 }
auto findNearestFarthestPoint(const Point2d_< FPT > &pt, const T &cont)
Returns indexes of points in container cont that are nearest/farthest.
Definition: homog2d.hpp:11167
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
#define M_PI
Definition: homog2d.hpp:235
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
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
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
Point2d pt
Definition: homog2d_test.cpp:4034
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: