DGtal 1.4.0
Loading...
Searching...
No Matches
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
41using namespace DGtal;
42using namespace Z2i;
43
45
47 std::uniform_real_distribution<double>& unif,
48 std::default_random_engine& re )
49{
50 double res;
51 do {
52 res = unif(re);
53 }
54 while ( res == Approx(0.) );
55 return res;
56}
57
59 std::uniform_real_distribution<double>& unif,
60 std::default_random_engine& re )
61{
62 return RealPoint(notNullValue(unif,re),notNullValue(unif,re));
63}
64
65TEST_CASE("Lemniscate2D")
66{
67 std::uniform_real_distribution<double> unif(-10000,10000);
68 std::default_random_engine re;
69
70 SECTION("center()")
71 {
72 const RealPoint center(unif(re),unif(re));
73 Shape shape( center, unif(re) );
74 REQUIRE( shape.center() == center );
75 }
76
77 SECTION("Lower and upper bounds")
78 {
79 Shape shape( unif(re), unif(re), unif(re) );
80 REQUIRE( shape.getLowerBound() <= shape.getUpperBound() );
81 }
82
83 SECTION("x() with Pi parameter.")
84 {
85 Shape shape( unif(re), unif(re), unif(re) );
86 REQUIRE_NOTHROW( shape.x(M_PI) );
87 }
88
89 SECTION("x() with Pi parameter -> division by 0.")
90 {
91 Shape shape( unif(re), unif(re), unif(re) );
92 REQUIRE_NOTHROW( shape.x(M_PI) );
93 }
94
95 SECTION("xp() with Pi parameter -> division by 0.")
96 {
97 Shape shape( unif(re), unif(re), unif(re) );
98 REQUIRE_NOTHROW( shape.xp(M_PI) );
99 }
100
101 SECTION("xpp() with Pi parameter -> division by 0.")
102 {
103 Shape shape( unif(re), unif(re), unif(re) );
104 REQUIRE_NOTHROW( shape.xp(M_PI) );
105 }
106}
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.
Aim: Implements basic operations that will be used in Point and Vector classes.
Space::RealPoint RealPoint
Definition StdDefs.h:97
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
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))