DGtal  1.2.0
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 829 of file SegmentComputerEstimators.h.

◆ Value

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

Definition at line 832 of file SegmentComputerEstimators.h.

◆ operator()()

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 849 of file SegmentComputerEstimators.h.

851  {
852  typedef typename DCA::Pair Pair;
853  typedef typename DCA::Point Point;
854  typedef typename Point::Coordinate Coordinate;
855
857  {
858  //separating circle center
859  double c0, c1, r;
861  //point
862  Pair pair = *it;
863  Point i = pair.first;
864  Point o = pair.second;
865  double m0 = NumberTraits<Coordinate>::castToDouble(i[0]+o[0]) / 2.0;
866  double m1 = NumberTraits<Coordinate>::castToDouble(i[1]+o[1]) / 2.0;
867  //normal vector
868  double v0 = m0 - c0;
869  double v1 = m1 - c1;
870  //norm
871  double n = std::sqrt(v0*v0 + v1*v1);
872  return Value( v0/n, v1/n );
873  }
874  else
875  {
876  //separating straight line and normal vector
877  double a, b, c;