homog2d library
Functions
showcase8.cpp File Reference

Generates rotating point and draw the orthogonal segment to a line. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates rotating point and draw the orthogonal segment to a line.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto nbim = 25; // nb images
14  auto Hdraw = Homogr().addTranslation(3,2).addScale(40);
15  img::Image<img::SvgImage> im( 250, 200 );
16 
17  auto kx=1.5;
18  auto ky=2.;
19  for( int i=0; i<nbim; i++ )
20  {
21  auto angle = i*360./nbim;
22  auto angle_r = angle * M_PI / 180.;
23  auto x1 = std::cos(angle_r)*kx;
24  auto y1 = std::sin(angle_r)*ky;
25  Point2d pt( x1,y1);
26  auto pt_d = Hdraw * pt;
27 
28  Segment seg( -.7, -.2, +.8, +.3 );
29  auto li = seg.getLine();
30  auto li_d = Hdraw * li;
31 
32  Segment seg2( -.9, +1.4, +.45, +1.0 );
33  auto seg2_d = Hdraw * seg2;
34 
35  im.clear();
36  pt_d.draw( im, img::DrawParams().setColor(250,0,0) );
37  li_d.draw( im, img::DrawParams().setColor(0,250,0) );
38  seg2_d.draw( im, img::DrawParams().setColor(250,0,0) );
39 
40  auto sego = li_d.getOrthogSegment( pt_d );
41  sego.draw( im, img::DrawParams().setColor(20,0,250) );
42 
43  int segDistCase;
44  auto dist = seg2_d.distTo( pt_d, &segDistCase );
45  auto pts_seg2 = seg2_d.getPts();
46 
47  auto colA = img::DrawParams().setColor(250,250,0);
48  auto colB = img::DrawParams().setColor(0,250,250);
49  switch( segDistCase )
50  {
51  case -1:
52  Segment( pt_d, pts_seg2.first ).draw( im, colA );
53  break;
54  case +1:
55  Segment( pt_d, pts_seg2.second ).draw( im, colA );
56  break;
57  default:
58  auto s = seg2_d.getLine().getOrthogSegment( pt_d );
59  s.draw( im, colB );
60  }
61 
62  std::ostringstream oss;
63  oss << "showcase8_" << std::setfill('0') << std::setw(2) <<i << ".svg";
64  im.write( oss.str() );
65  }
66 }
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
Segment seg
Definition: homog2d_test.cpp:4033
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
#define M_PI
Definition: homog2d.hpp:235
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
Line2d li
Definition: homog2d_test.cpp:4035
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
HOMOG2D_INUMTYPE angle(const Ellipse_< FPT > &ell)
Return angle of ellipse (free function)
Definition: homog2d.hpp:10993
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
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
auto getLine() const
Returns supporting line.
Definition: homog2d.hpp:5252
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: