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

TRTK::FitCircle3D< T > Class Template Reference

Estimates the parameters of a circle in 3D space from a set of points lying on the circle. More...

#include <FitCircle3D.hpp>

Inheritance diagram for TRTK::FitCircle3D< T >:
Collaboration diagram for TRTK::FitCircle3D< 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::Vector4T Vector4T
 4D column vector with value type T.
typedef super::Matrix3T Matrix3T
 3 x 3 matrix with value type T.
typedef super::ArrayXT ArrayXT
 General-purpose array of arbitrary size with value type T.
typedef super::MatrixXT MatrixXT
 Matrix of arbitrary size with value type T.
typedef super::VectorXT VectorXT
 Column vector of arbitrary size with value type T.
typedef super::Matrix2T Matrix2T
 2 x 2 matrix with value type T.
enum  Error {
  DATA_POINTS_TOO_SIMILAR, INFINITY_NOT_AVAILABLE, NAN_NOT_AVAILABLE, NOT_ENOUGH_POINTS,
  UNKNOWN_ERROR, WRONG_POINT_SIZE
}

Public Member Functions

 FitCircle3D ()
 Constructs an empty FitCircle3D object.
 FitCircle3D (const std::vector< Coordinate< T > > &points)
 Constructs a FitCircle3D object.
 FitCircle3D (const std::vector< Vector3T > &points)
 Constructs a FitCircle3D object.
 FitCircle3D (const std::vector< Vector4T, Eigen::aligned_allocator< Vector4T > > &points)
 Constructs an FitCircle3D object.
virtual ~FitCircle3D ()
 Destructs the FitCircle3D object.
void compute ()
 Runs the fitting algorithm.
const Coordinate< T > & getCenterPoint () const
 Returns the center point of the circle.
getDistanceTo (const Coordinate< T > &point) const
 Returns the shortest distance from the circle to the given point.
const Coordinate< T > & getNormal () const
 Returns the normal of the plane the circle lies in.
unsigned getNumberPointsRequired () const
 Returns the minimum number of data points required to compute a model.
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< Vector3T > &)
 Sets the point set.
void setPoints (const std::vector< Vector4T, Eigen::aligned_allocator< Vector4T > > &)
 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::FitCircle3D< T >

Estimates the parameters of a circle in 3D space from a set of points lying on the circle.

Template Parameters:
Tscalar type of the coordinates

This class allows estimating the center point, the radius and the normal vector of a circle in 3D space from known points on the circle.

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

 #include <iostream>

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

 using namespace std;
 using namespace TRTK;
 using namespace TRTK::Tools;

 int main()
 {
     typedef Coordinate<double> Coordinate;

     double pi = 3.1415926535;

     double radius = 10;
     Coordinate center_point = Coordinate(2, -1, 0);

     // Create some noisy points lying on a circle in the x-y-plane.

     vector<Coordinate> points;

     for (double phi = 0.0; phi < 2.0 * pi; phi += 0.1)
     {
         double x = radius * cos(phi) + 0.1 * randn();
         double y = radius * sin(phi) + 0.1 * randn();

         points.push_back(Coordinate(x, y, 0));
     }

     // Rotate the circle and move it to the above center point.

     Transform3D<double> transform;

     transform.rotateY(pi/2).rotateX(pi/2).translate(center_point);

     for (unsigned i = 0; i < points.size(); ++i)
     {
         points[i] = transform * points[i];
     }

     // Estimate the circle's parameters.

     FitCircle3D<double> fitCircle3D(points);
     fitCircle3D.compute();

     cout << "Center point: " << fitCircle3D.getCenterPoint() << endl;
     cout << "Normal:       " << fitCircle3D.getNormal() << endl;
     cout << "Radius:       " << fitCircle3D.getRadius() << endl;
 }

Output:

 Center point: (2, -0.94518, -0.0189328)
 Normal:       (-1, 4.50982e-011, 5.1715e-014)
 Radius:       9.99913
Author:
Christoph Haenisch, Fabian Killus
Version:
0.2.0
Date:
last changed on 2012-03-20

Definition at line 118 of file FitCircle3D.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::FitCircle3D< T >::FitCircle3D (  )

Constructs an empty FitCircle3D object.

Template Parameters:
Tscalar type of the coordinates

Definition at line 165 of file FitCircle3D.hpp.

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

Constructs a FitCircle3D object.

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

Definition at line 182 of file FitCircle3D.hpp.

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

Constructs a FitCircle3D object.

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

Definition at line 199 of file FitCircle3D.hpp.

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

Constructs an FitCircle3D object.

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

Definition at line 218 of file FitCircle3D.hpp.

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

Destructs the FitCircle3D object.

Template Parameters:
Tscalar type of the coordinates

Definition at line 233 of file FitCircle3D.hpp.


Member Function Documentation

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

Runs the fitting algorithm.

Template Parameters:
Tscalar type of the coordinates

There must be at least 3 known points on the circle to perform the fitting.

Exceptions:
ErrorObjIf there are not enough points to fit the circle, an error object is thrown and its error code is set to NOT_ENOUGH_POINTS.
See also:
setPoints(), getCenterPoint() and getRadius()

Implements TRTK::Fit3D< T >.

Definition at line 252 of file FitCircle3D.hpp.

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

Returns the center point of the circle.

Template Parameters:
Tscalar type of the coordinates

Definition at line 350 of file FitCircle3D.hpp.

template<class T >
T TRTK::FitCircle3D< 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::Fit3D< T >.

Definition at line 364 of file FitCircle3D.hpp.

template<class T >
const Coordinate< T > & TRTK::FitCircle3D< T >::getNormal (  ) const

Returns the normal of the plane the circle lies in.

Template Parameters:
Tscalar type of the coordinates

Definition at line 404 of file FitCircle3D.hpp.

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

Returns the radius of the circle.

Template Parameters:
Tscalar type of the coordinates

Definition at line 423 of file FitCircle3D.hpp.

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

Returns the root mean square error.

Template Parameters:
Tscalar type of the coordinates

Implements TRTK::Fit3D< T >.

Definition at line 435 of file FitCircle3D.hpp.

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

Sets the point set.

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

Definition at line 187 of file Fit3D.hpp.

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

Sets the point set.

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

Definition at line 168 of file Fit3D.hpp.

template<class T >
void TRTK::Fit3D< 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 3D or 4D homogeneous coordinates.
Exceptions:
ErrorObjIf there are any coordinates other than 3D or 4D coordinates, an error object is thrown and its error code is set to WRONG_POINT_SIZE.

Implements TRTK::Fit< T >.

Definition at line 135 of file Fit3D.hpp.


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