DGtal  1.0.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 830 of file SegmentComputerEstimators.h.

## ◆ Value

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

Definition at line 833 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 850 of file SegmentComputerEstimators.h.

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 std::decay< T >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:154
MyPointD Point
Definition: testClone2.cpp:383

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