DGtal  0.9.4beta
Public Types | Public Member Functions
DGtal::detail::DistanceFromDCA Struct Reference

#include <DGtal/geometry/curves/estimation/SegmentComputerEstimators.h>

Public Types

typedef std::pair< double, double > Value
 

Public Member Functions

template<typename DCA >
Value operator() (const typename DCA::ConstIterator &it, const DCA &aDCA, const double &aH) const
 

Detailed Description

Description of class 'DistanceFromDCA'

Aim: estimates the distance of a given pair of points to the separating circle of a DCA.

Definition at line 926 of file SegmentComputerEstimators.h.

Member Typedef Documentation

typedef std::pair<double,double> DGtal::detail::DistanceFromDCA::Value

Definition at line 929 of file SegmentComputerEstimators.h.

Member Function Documentation

template<typename DCA >
Value DGtal::detail::DistanceFromDCA::operator() ( const typename DCA::ConstIterator &  it,
const DCA &  aDCA,
const double &  aH 
) const
inline

Operator()

Returns
distances (in a pair) of the inner and outer points pointed by it to the separating circle of aDCA
Parameters
itposition where the estimation has to be done
aDCAan instance of segment computer devoted to the DCA recognition.
aHgrid step
Template Parameters
DCAa model of segment computer devoted to the DCA recognition, basically geometricDCA.

Definition at line 948 of file SegmentComputerEstimators.h.

References DGtal::NumberTraits< T >::castToDouble().

950  {
951  typedef typename DCA::Pair Pair;
952  typedef typename DCA::Point Point;
953  typedef typename Point::Coordinate Coordinate;
954 
955  if ( !aDCA.isStraight() )
956  {
957  //separating circle center
958  double c0, c1, r;
959  aDCA.getSeparatingCircle().getParameters(c0, c1, r);
960  //points
961  Pair pair = *it;
962  Point i = pair.first;
963  Point o = pair.second;
964  //distances
965  double distI0 = NumberTraits<Coordinate>::castToDouble(i[0]) - c0;
966  double distI1 = NumberTraits<Coordinate>::castToDouble(i[1]) - c1;
967  double distI = std::sqrt( distI0*distI0 + distI1*distI1 ) - r;
968  double distO0 = NumberTraits<Coordinate>::castToDouble(o[0]) - c0;
969  double distO1 = NumberTraits<Coordinate>::castToDouble(o[1]) - c1;
970  double distO = std::sqrt( distO0*distO0 + distO1*distO1 ) - r;
971  return Value( distI*aH, distO*aH );
972  }
973  else
974  {
975  //separating straight line
976  double a, b, c;
977  aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
978  //norm
979  double n = std::sqrt(a*a + b*b);
980  //points
981  Pair pair = *it;
982  Point i = pair.first;
983  Point o = pair.second;
984  //distances
985  double rI = NumberTraits<Coordinate>::castToDouble(i[0])*a +
987  double distI = rI / n;
988  double rO = NumberTraits<Coordinate>::castToDouble(o[0])*a +
990  double distO = rO / n;
991  return Value( distI*aH, distO*aH );
992  }
993  }
static double castToDouble(const T &aT)
Definition: NumberTraits.h:154

The documentation for this struct was generated from the following file: