DGtal 1.3.0
Loading...
Searching...
No Matches
Typedefs | Functions
testLemniscate2D.cpp File Reference
#include <iostream>
#include <random>
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/parametric/Lemniscate2D.h"

Go to the source code of this file.

Typedefs

typedef Z2i::Space Space
 
typedef Z2i::Point Point
 
typedef Z2i::RealPoint RealPoint
 
typedef Lemniscate2D< SpaceShape
 

Functions

double notNullValue (std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
 
RealPoint notNullRealPoint (std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
 
 TEST_CASE ("Lemniscate2D")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Adrien Krähenbühl (krahe.nosp@m.nbuh.nosp@m.l@uni.nosp@m.stra.nosp@m..fr ) Laboratoire ICube, UMR 7357, Université de Strasbourg, France
Date
2019/07/18

Functions for testing the methods of the Lemniscate2D shape. In particular, test the x(), xp() and xpp() methods for cases leadind to a division by 0.

This file is part of the DGtal library.

Definition in file testLemniscate2D.cpp.

Typedef Documentation

◆ Point

typedef Z2i::Point Point

Definition at line 45 of file testLemniscate2D.cpp.

◆ RealPoint

Definition at line 46 of file testLemniscate2D.cpp.

◆ Shape

Definition at line 48 of file testLemniscate2D.cpp.

◆ Space

typedef Z2i::Space Space

Definition at line 44 of file testLemniscate2D.cpp.

Function Documentation

◆ notNullRealPoint()

RealPoint notNullRealPoint ( std::uniform_real_distribution< double > &  unif,
std::default_random_engine &  re 
)

Definition at line 62 of file testLemniscate2D.cpp.

65{
67}
double notNullValue(std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
Z2i::RealPoint RealPoint
std::default_random_engine re
std::uniform_real_distribution< double > unif(-1000000., 1000000.)

References notNullValue(), re, and unif().

◆ notNullValue()

double notNullValue ( std::uniform_real_distribution< double > &  unif,
std::default_random_engine &  re 
)

Definition at line 50 of file testLemniscate2D.cpp.

53{
54 double res;
55 do {
56 res = unif(re);
57 }
58 while ( res == Approx(0.) );
59 return res;
60}

References re, and unif().

Referenced by notNullRealPoint().

◆ TEST_CASE()

TEST_CASE ( "Lemniscate2D"  )

Definition at line 69 of file testLemniscate2D.cpp.

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}
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Point center(const std::vector< Point > &points)
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References DGtal::Astroid2D< TSpace >::center(), DGtal::Astroid2D< TSpace >::getLowerBound(), DGtal::Astroid2D< TSpace >::getUpperBound(), re, REQUIRE(), SECTION(), unif(), DGtal::Astroid2D< TSpace >::x(), and DGtal::Astroid2D< TSpace >::xp().