DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions
DGtal::detail::NormalVectorFromDCA Struct Reference

#include <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 836 of file SegmentComputerEstimators.h.


Member Typedef Documentation

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

{
typedef typename DCA::ConstIterator ConstIterator;
typedef typename DCA::Pair Pair;
typedef typename DCA::Point Point;
typedef typename Point::Coordinate Coordinate;
if ( !aDCA.isStraight() )
{
//separating circle center
double c0, c1, r;
aDCA.getSeparatingCircle().getParameters(c0, c1, r);
//point
Pair pair = *it;
Point i = pair.first;
Point o = pair.second;
double m0 = NumberTraits<Coordinate>::castToDouble(i[0]+o[0]) / 2.0;
double m1 = NumberTraits<Coordinate>::castToDouble(i[1]+o[1]) / 2.0;
//normal vector
double v0 = m0 - c0;
double v1 = m1 - c1;
//norm
double n = std::sqrt(v0*v0 + v1*v1);
return Value( v0/n, v1/n );
}
else
{
//separating straight line and normal vector
double a, b, c;
aDCA.getGeometricalDSSPtr()->getParameters(a, b, c);
//norm
double n = std::sqrt(a*a + b*b);
return Value( a/n, b/n );
}
}

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