DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Data Fields
DGtal::FrechetShortcut< TIterator, TInteger >::Cone Class Reference

#include <FrechetShortcut.h>

Public Member Functions

 Cone ()
 Cone (double a0, double a1)
 Cone (double x, double y, double x0, double y0, double x1, double y1)
bool isEmpty ()
Coneoperator= (const Cone &c)
void intersectCones (Cone c)
Cone intersectConesSimple (Cone c)
Cone symmetricalCone ()
void selfDisplay (std::ostream &out)

Data Fields

double myMin
double myMax
bool myInf

Detailed Description

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
class DGtal::FrechetShortcut< TIterator, TInteger >::Cone

Class Cone: data structures and methods to handle the cone update used to test if the width of the shortcut is lower than the error.

Definition at line 253 of file FrechetShortcut.h.


Constructor & Destructor Documentation

template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone::Cone ( )
inline

Definition at line 351 of file FrechetShortcut.ih.

{
myInf = true;
myMin = 0;
myMax = 0;
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone::Cone ( double  a0,
double  a1 
)
inline

Constructor from two angles

Parameters:
twoangles a0 and a1

Definition at line 362 of file FrechetShortcut.ih.

References M_PI.

{
// angle0 and angle1 are ordered in direct orientation such that the angle between made by the two directions is lower than PI.
// case angle0-angle1 = PI -> infinite cone
if(fabs(fabs(angle0-angle1)-M_PI) < 0.00001)
{
// the orientation is supposed to be ok (depends on the points involved)
myMin = angle0;
myMax = angle1;
}
else
if(fabs(angle0-angle1)<M_PI)
{
if(angle0-angle1>0)
{
myMin = angle1;
myMax = angle0;
}
else
{
myMin = angle0;
myMax = angle1;
}
}
else
{
// the cone includes the direction of angle=0
if(angle0>angle1)
{
myMin = angle0;
myMax = angle1;
}
else
{
myMin = angle1;
myMax = angle0;
}
}
myInf = false;
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone::Cone ( double  x,
double  y,
double  x0,
double  y0,
double  x1,
double  y1 
)
inline

Constructor from three points x, x0, x1. The cone is defined by the two lines (xx0) and (xx1)

Parameters:
sixdoubles

Definition at line 408 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Tools::computeAngle().

{
double angle0 = Tools::computeAngle(x, y, x0, y0);
double angle1 = Tools::computeAngle(x, y, x1, y1);
assert(angle0 != -1 && angle1 != -1);
*this = Cone(angle0,angle1);
myInf = false;
}

Member Function Documentation

template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Cone::intersectCones ( Cone  c)
inline

Intersect two cones: modifies 'this'

Parameters:
ca cone to intersect with 'this'

Definition at line 454 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Cone::isEmpty(), and DGtal::FrechetShortcut< TIterator, TInteger >::Cone::symmetricalCone().

Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::computeNewCone().

{
Cone res;
// computes the intersection between the self cone and one half of another cone
// if they are disjoint, try the intersection with the other half
if(res.isEmpty())
{
Cone sym = c.symmetricalCone();
}
*this = res;
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone DGtal::FrechetShortcut< TIterator, TInteger >::Cone::intersectConesSimple ( Cone  c)
inline

Intersect two half cones

Parameters:
ca cone to intersection with 'this'
Returns:
a cone

Definition at line 475 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Tools::isBetween(), M_PI, DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myInf, DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMax, and DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMin.

{
Cone res;
// if the cone is infinite, the new cone is c
if(myInf)
{
res = c;
res.myInf = false;
}
else
// the directions of the new cone are not included in the old one
if(!Tools::isBetween(c.myMin, myMin, myMax, 2*M_PI) && !Tools::isBetween(c.myMax, myMin,
2*M_PI))
{
// first possibility: the cones are disjoint
if(!Tools::isBetween(myMin, c.myMin, c.myMax, 2*M_PI) && !Tools::isBetween(myMax, c.myMin,
c.myMax, 2*M_PI))
res = Cone(0,0);
else
// or the new cone includes the old one, nothing changes, the cone remains the same.
res = *this;
}
else
// the old cone is "cut" by the new one
if(Tools::isBetween(c.myMin, myMin, myMax, 2*M_PI))
if(Tools::isBetween(c.myMax, myMin, myMax, 2*M_PI))
res = c;
else
res = Cone(c.myMin, myMax);
else
res = Cone(myMin,c.myMax);
return res;
}
template<typename TIterator , typename TInteger >
bool DGtal::FrechetShortcut< TIterator, TInteger >::Cone::isEmpty ( )
inline

Test if the cone is empty

Returns:
true if empty, false otherwise

Definition at line 421 of file FrechetShortcut.ih.

Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::Cone::intersectCones(), DGtal::FrechetShortcut< TIterator, TInteger >::testUpdateWidth(), and DGtal::FrechetShortcut< TIterator, TInteger >::updateWidth().

{
if(myInf)
return false;
else
if(myMin==myMax)
return true;
else
return false;
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone & DGtal::FrechetShortcut< TIterator, TInteger >::Cone::operator= ( const Cone c)
inline

Assignement

Parameters:
canother cone
Returns:
a reference on 'this'

Definition at line 434 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myInf, DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMax, and DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMin.

{
myMin =c.myMin;
myMax=c.myMax;
myInf = c.myInf;
return *this;
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Cone::selfDisplay ( std::ostream &  out)
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 514 of file FrechetShortcut.ih.

{
out << "[Cone]" << endl;
if(myInf)
out << "Infinite" << endl;
else
out << "[Cone min = " << myMin << " max = " << myMax << "]" << endl;
out << "[End Cone]" << endl;
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Cone DGtal::FrechetShortcut< TIterator, TInteger >::Cone::symmetricalCone ( )
inline

Computes the symmetrical half cone

Parameters:
ca cone
Returns:
a cone

Definition at line 445 of file FrechetShortcut.ih.

References M_PI.

Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::Cone::intersectCones().

{
Cone cnew(myMin+M_PI,myMax+M_PI);
return cnew;
}

Field Documentation

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
bool DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myInf
template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
double DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMax
template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
double DGtal::FrechetShortcut< TIterator, TInteger >::Cone::myMin

The documentation for this class was generated from the following files: