homog2d library
Functions
showcase6.cpp File Reference

Generates a circle from 2/3 points. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates a circle from 2/3 points.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
13 {
14  auto nbim = 25; // nb images
15  auto Hdraw = Homogr().setScale(30).addTranslation(10,10);
16 
17  auto x0 = 3.;
18  auto k=1.8;
19 
20  Point2d p1( 2, 4 );
21  Point2d p2( 6, 5 );
22  Segment seg( 1., 1., 4.5, 2.8 );
23 
24  for( int i=0; i<nbim; i++ )
25  {
26  auto angle = i*360./nbim;
27  auto angle_r = angle * M_PI / 180.;
28  auto x1 = std::cos(angle_r)*k;
29  auto y1 = std::sin(angle_r)*k;
30 
31  Point2d p0( x1+x0, y1+x0);
32  std::vector<Point2d> v1{ p1, p2, p0 };
33  std::vector<Point2d> v2{ p1, p0 };
34  Circle cir1( p0,p1,p2);
35  Circle cir2( p0,p1 );
36 
37  auto v1d = Hdraw * v1;
38  auto v2d = Hdraw * v2;
39 
40  auto cir1d = Hdraw * cir1;
41  auto cir2d = Hdraw * cir2;
42  auto segd = Hdraw * seg;
43 
44  Image<img::SvgImage> im1( 250, 200 );
45 
46  auto dpinter= DrawParams().setPointStyle( PtStyle::Diam ).setColor( 20,250,20 );
47  auto int1 = cir1.intersects( seg );
48  auto int2 = cir2.intersects( seg );
49  if( int1() )
50  for( const auto pt: int1.get() )
51  draw( im1, Hdraw * pt, dpinter );
52  if( int2() )
53  for( const auto pt: int2.get() )
54  draw( im1, Hdraw * pt, dpinter );
55 
56  draw( im1, v1d );
57  cir2d.getBB().draw( im1, DrawParams().setColor(150,200,200) );
58 
59  segd.draw( im1, DrawParams().setColor(50,50,150) );
60  cir1d.draw( im1, DrawParams().setColor(250,0,0) );
61  cir2d.draw( im1, DrawParams().setColor(0,0,250) );
62 
63  std::ostringstream ossa;
64  ossa << "showcase6_" << std::setfill('0') << std::setw(2) << i << ".svg";
65  im1.write( ossa.str() );
66  }
67 }
A circle.
Definition: homog2d.hpp:378
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
#define M_PI
Definition: homog2d.hpp:235
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
DrawParams & setPointStyle(PtStyle ps)
Definition: homog2d.hpp:585
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
A line segment, oriented (OSegment_) or not (Segment_). Holds the two points.
Definition: homog2d.hpp:366
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
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: