DGtal  1.2.0
testLemniscate2D.cpp
Go to the documentation of this file.
1 
33 #include <iostream>
34 #include <random>
35 #include "DGtalCatch.h"
36 #include "DGtal/helpers/StdDefs.h"
37 #include "DGtal/shapes/parametric/Lemniscate2D.h"
38 
40 
41 using namespace DGtal;
42 using namespace Z2i;
43 
44 typedef Z2i::Space Space;
45 typedef Z2i::Point Point;
47 
49 
50 double notNullValue(
51  std::uniform_real_distribution<double>& unif,
52  std::default_random_engine& re )
53 {
54  double res;
55  do {
56  res = unif(re);
57  }
58  while ( res == Approx(0.) );
59  return res;
60 }
61 
63  std::uniform_real_distribution<double>& unif,
64  std::default_random_engine& re )
65 {
67 }
68 
69 TEST_CASE("Lemniscate2D")
70 {
71  std::uniform_real_distribution<double> unif(-10000,10000);
72  std::default_random_engine re;
73 
74  SECTION("center()")
75  {
76  const RealPoint center(unif(re),unif(re));
77  Shape shape( center, unif(re) );
78  REQUIRE( shape.center() == center );
79  }
80 
81  SECTION("Lower and upper bounds")
82  {
83  Shape shape( unif(re), unif(re), unif(re) );
84  REQUIRE( shape.getLowerBound() <= shape.getUpperBound() );
85  }
86 
87  SECTION("x() with Pi parameter.")
88  {
89  Shape shape( unif(re), unif(re), unif(re) );
90  REQUIRE_NOTHROW( shape.x(M_PI) );
91  }
92 
93  SECTION("x() with Pi parameter -> division by 0.")
94  {
95  Shape shape( unif(re), unif(re), unif(re) );
96  REQUIRE_NOTHROW( shape.x(M_PI) );
97  }
98 
99  SECTION("xp() with Pi parameter -> division by 0.")
100  {
101  Shape shape( unif(re), unif(re), unif(re) );
102  REQUIRE_NOTHROW( shape.xp(M_PI) );
103  }
104 
105  SECTION("xpp() with Pi parameter -> division by 0.")
106  {
107  Shape shape( unif(re), unif(re), unif(re) );
108  REQUIRE_NOTHROW( shape.xp(M_PI) );
109  }
110 }
RealPoint getLowerBound() const
Definition: Astroid2D.h:122
RealPoint x(const double t) const
RealVector xp(const double t) const
RealPoint center() const
Definition: Astroid2D.h:139
RealPoint getUpperBound() const
Definition: Astroid2D.h:131
Aim: Model of the concept StarShaped represents a lemniscate.
Definition: Lemniscate2D.h:62
Space::RealPoint RealPoint
Definition: StdDefs.h:97
SpaceND< 2, Integer > Space
Definition: StdDefs.h:75
Space::Point Point
Definition: StdDefs.h:95
DGtal is the top-level namespace which contains all DGtal functions and types.
TEST_CASE("Lemniscate2D")
RealPoint notNullRealPoint(std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
double notNullValue(std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
Lemniscate2D< Space > Shape
std::default_random_engine re
std::uniform_real_distribution< double > unif(-1000000., 1000000.)
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))