DGtal  0.9.2
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

 typedef PointVector<2,double> DGtal::detail::NormalVectorFromDCA::Value

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
 it position where the estimation has to be done aDCA an instance of segment computer devoted to the DCA recognition.
Template Parameters
 DCA a 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
858  {
859  //separating circle center
860  double 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;