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

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

Public Types

typedef PointVector< 2, double > Value
 

Public Member Functions

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

Detailed Description

Description of class 'NormalVectorFromDCA'

Aim: estimates the normal at a given position from a geometricDCA.

Definition at line 830 of file SegmentComputerEstimators.h.

Member Typedef Documentation

Definition at line 833 of file SegmentComputerEstimators.h.

Member Function Documentation

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

Operator()

Returns
normal at it
Parameters
itposition where the estimation has to be done
aDCAan instance of segment computer devoted to the DCA recognition.
Template Parameters
DCAa model of segment computer devoted to the DCA recognition, basically geometricDCA.

Definition at line 850 of file SegmentComputerEstimators.h.

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

852  {
853  typedef typename DCA::Pair Pair;
854  typedef typename DCA::Point Point;
855  typedef typename Point::Coordinate Coordinate;
856 
857  if ( !aDCA.isStraight() )
858  {
859  //separating circle center
860  double c0, c1, r;
861  aDCA.getSeparatingCircle().getParameters(c0, c1, r);
862  //point
863  Pair pair = *it;
864  Point i = pair.first;
865  Point o = pair.second;
866  double m0 = NumberTraits<Coordinate>::castToDouble(i[0]+o[0]) / 2.0;
867  double m1 = NumberTraits<Coordinate>::castToDouble(i[1]+o[1]) / 2.0;
868  //normal vector
869  double v0 = m0 - c0;
870  double v1 = m1 - c1;
871  //norm
872  double n = std::sqrt(v0*v0 + v1*v1);
873  return Value( v0/n, v1/n );
874  }
875  else
876  {
877  //separating straight line and normal vector
878  double a, b, c;
879  aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
880  //norm
881  double n = std::sqrt(a*a + b*b);
882  return Value( a/n, b/n );
883  }
884  }
static double castToDouble(const T &aT)
Definition: NumberTraits.h:154

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