homog2d library
Functions
showcase3.cpp File Reference

Generates a rotating polygon with a crossing line, computes the intersection points. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates a rotating polygon with a crossing line, computes the intersection points.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto n = 25; // nb images
14  CPolyline pl;
15  std::vector<Point2d> vpts{
16  { 5,5 },
17  { 7,3 },
18  { 6, 2 },
19  { 7.5, 1. },
20  { 4, 0 },
21  { 5.5, 2.5 },
22  { 4., 1.2 },
23  { 3., 2.2 },
24  { 3.6, 4.1 },
25  { 1.6, 5.4 }
26  };
27  pl.set( vpts );
28 
29  auto Hdraw = Homogr().setScale(30).addTranslation(10,30);
30 
31  Line2d li(1,1,6,3);
32  img::Image<img::SvgImage> img2( 300, 250 );
33 
34  Homogr H;
35  H.addTranslation(-4,-3).addRotation(360./n/180*M_PI ).addTranslation(4,3);
36 
37  for( int i=0; i<n; i++ )
38  {
39  pl = H*pl;
40  img2.clear();
41  auto pl2 = Hdraw * pl;
42  pl2.draw( img2, img::DrawParams().setColor(250,0,20) );
43  pl2.getBB().draw( img2, img::DrawParams().setColor(150,150,120) );
44  draw( img2, Hdraw * li, img::DrawParams().setColor(120,250,220) );
45  auto pts = pl.intersects(li);
46  auto pts2 = Hdraw * pts.get();
47  draw( img2, pts2 );
48  std::ostringstream ossa;
49  ossa << "showcase3_" << std::setfill('0') << std::setw(2) <<i << ".svg";
50  img2.write( ossa.str() );
51  }
52 }
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
#define M_PI
Definition: homog2d.hpp:235
A 2D homography, defining a planar transformation.
Definition: homog2d.hpp:369
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
Line2d li
Definition: homog2d_test.cpp:4035
Hmatrix_ & addTranslation(T tx, T ty)
Adds a translation tx,ty to the matrix.
Definition: homog2d.hpp:1830
void set(const CONT &vec)
Set from vector/array/list of points (discards previous points)
Definition: homog2d.hpp:6461
Hmatrix_ & addRotation(T theta)
Adds a rotation with an angle theta (radians) to the matrix.
Definition: homog2d.hpp:1854
void clear()
Clear all (does not change the "open/close" status).
Definition: homog2d.hpp:6375
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
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: