homog2d library
Functions
ellipse_speed_test.cpp File Reference

test app dedicated to measure speed improvements when using HOMOG2D_OPTIMIZE_SPEED More...

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

Functions

int main (int argc, const char **argv)
 

Detailed Description

test app dedicated to measure speed improvements when using HOMOG2D_OPTIMIZE_SPEED

Build and run with $ make speed-test

Function Documentation

◆ main()

int main ( int  argc,
const char **  argv 
)
13 {
14  size_t c1 = 0;
15  size_t c2 = 0;
16  size_t c3 = 0;
17  double range_center = 1000;
18  double esize = 500;
19 
20  size_t nb_runs = 1E7;
21  if( argc > 1 )
22  nb_runs = std::atoi( argv[1] );
23 
24  std::srand( std::time(nullptr) );
25  Point2d dummy_pt( range_center * std::rand() / RAND_MAX, range_center * std::rand() / RAND_MAX );
26 
27  std::cout << "-Running with n=" << nb_runs
28  << "\n-HOMOG2D_OPTIMIZE_SPEED: "
29 #ifdef HOMOG2D_OPTIMIZE_SPEED
30  << "YES"
31 #else
32  << "NO"
33 #endif
34  << "\n-HOMOG2D_NOCHECKS: "
35 #ifdef HOMOG2D_NOCHECKS
36  << "YES"
37 #else
38  << "NO"
39 #endif
40  << "\n Ellipse memory footprint=" << sizeof( Ellipse ) << '\n';
41 
42  for( size_t i=0; i<nb_runs; i++ )
43  {
44  auto x0 = range_center * std::rand() / RAND_MAX;
45  auto y0 = range_center * std::rand() / RAND_MAX;
46  auto a = esize * std::rand() / RAND_MAX + 1.;
47  auto b = esize * std::rand() / RAND_MAX + 1.;
48  auto angle = 2.0 * M_PI * std::rand() / RAND_MAX;
49  Ellipse ell( x0, y0, a, b, angle );
50 // std::cout << ell;
51  if( dummy_pt.isInside( ell ) )
52  c1++;
53  auto bb = ell.getOBB();
54  c2 += bb.size();
55 // if( dummy_pt.isInside(bb) )
56 // c2++;
57  auto center = ell.getCenter();
58  if( dummy_pt.distTo(center) < range_center )
59  c3++;
60 
61  }
62  std::cout << "Result: c1=" << c1 << " c2=" << c2 << " c3=" << c3 << '\n';
63 }
Point2d_< FPT > & center(Circle_< FPT > &cir)
Returns reference on center of circle (free function), non-const version.
Definition: homog2d.hpp:10934
Point2d_< FPT > getCenter() const
Returns center of ellipse.
Definition: homog2d.hpp:8581
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12402
#define M_PI
Definition: homog2d.hpp:235
CPolyline_< FPT > getOBB() const
Returns oriented bounding box of ellipse as a closed Polyline.
Definition: homog2d.hpp:8680
Ellipse as a conic in matrix form.
Definition: homog2d.hpp:380
HOMOG2D_INUMTYPE angle(const Ellipse_< FPT > &ell)
Return angle of ellipse (free function)
Definition: homog2d.hpp:10993
Ellipse ell
Definition: homog2d_test.cpp:4037
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: