DGtal  1.5.beta
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.

Member Typedef Documentation

◆ Value

Member Function Documentation

◆ 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
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 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 
856  if ( !aDCA.isStraight() )
857  {
858  //separating circle center
859  double c0, c1, r;
860  aDCA.getSeparatingCircle().getParameters(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;
878  aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
879  //norm
880  double n = std::sqrt(a*a + b*b);
881  return Value( a/n, b/n );
882  }
883  }
static double castToDouble(const std::decay< T >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:164
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::NumberTraitsImpl< std::decay< T >::type >::castToDouble().


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