Public Types | Public Member Functions | Public Attributes | Protected Attributes

TRTK::FitCircleInOrigin< T > Class Template Reference

Estimates the radius of a circle centered at the origin from a set of 2D points. More...

#include <FitCircleInOrigin.hpp>

Inheritance diagram for TRTK::FitCircleInOrigin< T >:
Collaboration diagram for TRTK::FitCircleInOrigin< T >:

List of all members.

Public Types

typedef super::Vector2T Vector2T
 2D column vector with value type T.
typedef super::Vector3T Vector3T
 3D column vector with value type T.
typedef super::MatrixXT MatrixXT
 Matrix of arbitrary size with value type T.
typedef super::Matrix2T Matrix2T
 2 x 2 matrix with value type T.
typedef super::VectorXT VectorXT
 Column vector of arbitrary size with value type T.
enum  Error {
  DATA_POINTS_TOO_SIMILAR, INFINITY_NOT_AVAILABLE, NAN_NOT_AVAILABLE, NOT_ENOUGH_POINTS,
  UNKNOWN_ERROR, WRONG_POINT_SIZE
}
typedef Eigen::Array< T,
Eigen::Dynamic, 1 > 
ArrayXT
 General-purpose array of arbitrary size with value type T.
typedef Eigen::Matrix< T, 4, 1 > Vector4T
 4D column vector with value type T.
typedef Eigen::Matrix< T, 3, 3 > Matrix3T
 3 x 3 matrix with value type T.

Public Member Functions

 FitCircleInOrigin ()
 Constructs an empty FitCircleInOrigin object.
 FitCircleInOrigin (const std::vector< Coordinate< T > > &points)
 Constructs a FitCircleInOrigin object.
 FitCircleInOrigin (const std::vector< Vector2T, Eigen::aligned_allocator< Vector2T > > &points)
 Constructs a FitCircleInOrigin object.
 FitCircleInOrigin (const std::vector< Vector3T > &points)
 Constructs an FitCircleInOrigin object.
virtual ~FitCircleInOrigin ()
 Destructs the FitCircleInOrigin object.
void compute ()
 Runs the fitting algorithm.
unsigned getNumberPointsRequired () const
 Returns the minimum number of data points required to compute a model.
const Coordinate< T > & getCenterPoint () const
 Returns the center point of the plane.
getDistanceTo (const Coordinate< T > &point) const
 Returns the shortest distance from the circle to the given point.
getRadius () const
 Returns the radius of the circle.
getRMS () const
 Returns the root mean square error.
void setPoints (const std::vector< Coordinate< T > > &)
 Sets the point set.
void setPoints (const std::vector< Vector2T, Eigen::aligned_allocator< Vector2T > > &)
 Sets the point set.
void setPoints (const std::vector< Vector3T > &)
 Sets the point set.

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW
typedef T 
value_type
 Internally used value type (should be a floating point type).

Protected Attributes

MatrixXT m_points

Detailed Description

template<class T>
class TRTK::FitCircleInOrigin< T >

Estimates the radius of a circle centered at the origin from a set of 2D points.

Template Parameters:
Tscalar type of the coordinates

This class allows estimating the radius of a circle from known points on the circle. The points may be erroneous since a least square fitting is done.

Here is an more elaborate example to see how to use the class:

 #include <iostream>

 #include <TRTK/FitCircleInOrigin.hpp>
 #include <TRTK/Tools.hpp>

 using namespace TRTK;

 int main()
 {
     double pi = 3.1415926535;

     std::vector<Coordinate<double> > circlePoints;

     //Construct some points lying on a circle.

     double radius = 7;

     for (double phi = 0.0; phi < 2.0 * pi; phi += pi/10)
     {
         using std::sin;
         using std::cos;
         using Tools::randn;

         double x = radius * cos(phi) + randn(0.0, 0.1);
         double y = radius * sin(phi) + randn(0.0, 0.1);

         Coordinate<double> point(x, y);
         circlePoints.push_back(point);
     }

     // Estimate the circle parameters.

     FitCircleInOrigin<double> fitCircleInOrigin(circlePoints);
     fitCircleInOrigin.compute();

     std::cout << "Radius: " << fitCircleInOrigin.getRadius() << std::endl;

     return 0;
 }

Output:

 Radius: 7.03625
Author:
Fabian Killus, Christoph Haenisch
Version:
0.2.0
Date:
last changed on 2012-03-20

Definition at line 105 of file FitCircleInOrigin.hpp.


Member Enumeration Documentation

template<class T>
enum TRTK::Fit::Error [inherited]
Enumerator:
DATA_POINTS_TOO_SIMILAR 

The data points are to similar.

INFINITY_NOT_AVAILABLE 

The type T cannot represent infinity (see std::numeric_limits<T>).

NAN_NOT_AVAILABLE 

The type T cannot represent NaN (see std::numeric_limits<T>).

NOT_ENOUGH_POINTS 

More points are required to estimate the transformation.

UNKNOWN_ERROR 

An unknown error occured.

WRONG_POINT_SIZE 

One or more points have a wrong size.

Definition at line 69 of file Fit.hpp.


Constructor & Destructor Documentation

template<class T >
TRTK::FitCircleInOrigin< T >::FitCircleInOrigin (  )

Constructs an empty FitCircleInOrigin object.

Template Parameters:
Tscalar type of the coordinates

Definition at line 149 of file FitCircleInOrigin.hpp.

template<class T >
TRTK::FitCircleInOrigin< T >::FitCircleInOrigin ( const std::vector< Coordinate< T > > &  points )

Constructs a FitCircleInOrigin object.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]pointsPoints lying on the circle. The points can be 2D or 3D homogeneous coordinates.

Definition at line 165 of file FitCircleInOrigin.hpp.

template<class T >
TRTK::FitCircleInOrigin< T >::FitCircleInOrigin ( const std::vector< Vector2T, Eigen::aligned_allocator< Vector2T > > &  points )

Constructs a FitCircleInOrigin object.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]pointsPoints lying on the circle.

Definition at line 181 of file FitCircleInOrigin.hpp.

template<class T >
TRTK::FitCircleInOrigin< T >::FitCircleInOrigin ( const std::vector< Vector3T > &  points )

Constructs an FitCircleInOrigin object.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]pointsPoints lying on the circle. The points are assumed to be homogeneous coordinates, whose third coordinate entry is equal to one.

Definition at line 199 of file FitCircleInOrigin.hpp.

template<class T >
TRTK::FitCircleInOrigin< T >::~FitCircleInOrigin (  ) [virtual]

Destructs the FitCircleInOrigin object.

Template Parameters:
Tscalar type of the coordinates

Definition at line 213 of file FitCircleInOrigin.hpp.


Member Function Documentation

template<class T >
void TRTK::FitCircleInOrigin< T >::compute (  ) [virtual]

Runs the fitting algorithm.

Template Parameters:
Tscalar type of the coordinates
Exceptions:
ErrorObjIf there are no points to fit the circle, an error object is thrown and its error code is set to NOT_ENOUGH_POINTS.
See also:
setPoints() and getRadius()

Implements TRTK::Fit2D< T >.

Definition at line 230 of file FitCircleInOrigin.hpp.

template<class T >
const Coordinate< T > & TRTK::FitCircleInOrigin< T >::getCenterPoint (  ) const

Returns the center point of the plane.

Template Parameters:
Tscalar type of the coordinates

Definition at line 269 of file FitCircleInOrigin.hpp.

template<class T >
T TRTK::FitCircleInOrigin< T >::getDistanceTo ( const Coordinate< T > &  point ) const [virtual]

Returns the shortest distance from the circle to the given point.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]pointA 2D coordinate.

Implements TRTK::Fit2D< T >.

Definition at line 283 of file FitCircleInOrigin.hpp.

template<class T >
T TRTK::FitCircleInOrigin< T >::getRadius (  ) const

Returns the radius of the circle.

Template Parameters:
Tscalar type of the coordinates

Definition at line 305 of file FitCircleInOrigin.hpp.

template<class T >
T TRTK::FitCircleInOrigin< T >::getRMS (  ) const [virtual]

Returns the root mean square error.

Template Parameters:
Tscalar type of the coordinates

Implements TRTK::Fit2D< T >.

Definition at line 317 of file FitCircleInOrigin.hpp.

template<class T >
void TRTK::Fit2D< T >::setPoints ( const std::vector< Vector2T, Eigen::aligned_allocator< Vector2T > > &  points ) [inherited]

Sets the point set.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]points2D coordinates.

Definition at line 163 of file Fit2D.hpp.

template<class T >
void TRTK::Fit2D< T >::setPoints ( const std::vector< Coordinate< T > > &  points ) [virtual, inherited]

Sets the point set.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]pointsThe points can either be plain 2D or 3D homogeneous coordinates.
Exceptions:
ErrorObjIf there are any coordinates other than 2D or 3D coordinates, an error object is thrown and its error code is set to WRONG_POINT_SIZE.

Implements TRTK::Fit< T >.

Definition at line 130 of file Fit2D.hpp.

template<class T >
void TRTK::Fit2D< T >::setPoints ( const std::vector< Vector3T > &  points ) [inherited]

Sets the point set.

Template Parameters:
Tscalar type of the coordinates
Parameters:
[in]points3D homogeneous coordinates.

Definition at line 182 of file Fit2D.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines