37#include "DGtal/base/Common.h"
38#include "DGtal/kernel/PointVector.h"
39#include "DGtal/shapes/fromPoints/CircleFrom3Points.h"
40#include "DGtal/shapes/fromPoints/CircleFrom2Points.h"
42#include "DGtal/io/boards/Board2D.h"
44#include "ConfigTest.h"
59template <
typename Coordinate>
60bool testCircleFrom3Points()
72 trace.
info() << o <<
" is at distance " << c.signedDistance(o) << endl;
73 if (c.signedDistance(o) != -4026300)
return false;
78 trace.
info() << o <<
" is at distance " << c.signedDistance(o) << endl;
79 if (c.signedDistance(o) != 442200)
return false;
84 trace.
info() << o <<
" is at distance " << c.signedDistance(o) << endl;
85 if (c.signedDistance(o) != 0)
return false;
87 c.getParameters(cx, cy, r);
88 if ( (cx != 5.0)||(cy != 0.0) )
91 trace.
info() <<
"(" << cx <<
"," << cy <<
") " << endl;
92 trace.
info() <<
"instead of (5,0)" << endl;
99 trace.
info() << o <<
" is at distance " << c.signedDistance(o) << endl;
100 if (c.signedDistance(o) != 0)
return false;
104 board <<
SetMode(o.className(),
"Grid") << o;
109 board <<
SetMode( c.className(),
"Arc" );
112 board <<
SetMode( c.className(),
"Sector" );
115 board <<
SetMode( c.className(),
"Annulus" );
118 board.
saveEPS(
"arcDisplay.eps");
127template <
typename Coordinate>
128bool testCircleFrom2Points()
141 trace.
info() << o <<
" is at distance " << c.signedDistance(o) << endl;
142 if (c.signedDistance(o) != 470)
return false;
155int main(
int argc,
char** argv )
159 for (
int i = 0; i < argc; ++i )
164 bool res = testCircleFrom3Points<int>()
165 && testCircleFrom3Points<double>()
166#ifdef WITH_BIGINTEGER
167 && testCircleFrom3Points<BigInteger>()
169 && testCircleFrom2Points<int>()
173 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: Represents a circle that passes through a given point and that is thus uniquely defined by two o...
Aim: Represents a circle uniquely defined by three 2D points and that is able to return for any given...
Aim: Implements basic operations that will be used in Point and Vector classes.
void beginBlock(const std::string &keyword="")
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
static void draw(DGtal::Board2D &board, const DGtal::DiscreteExteriorCalculus< dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger > &calculus)
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....