Estimates the parameters of a circle in 3D space from a set of points lying on the circle. More...
#include <FitCircle3D.hpp>
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. | |
T | 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. | |
T | getRadius () const |
Returns the radius of the circle. | |
T | 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 |
Estimates the parameters of a circle in 3D space from a set of points lying on the circle.
T | scalar 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
Definition at line 118 of file FitCircle3D.hpp.
enum TRTK::Fit::Error [inherited] |
TRTK::FitCircle3D< T >::FitCircle3D | ( | ) |
Constructs an empty FitCircle3D object.
T | scalar type of the coordinates |
Definition at line 165 of file FitCircle3D.hpp.
TRTK::FitCircle3D< T >::FitCircle3D | ( | const std::vector< Coordinate< T > > & | points ) |
Constructs a FitCircle3D object.
T | scalar type of the coordinates |
[in] | points | Points lying on the circle. The points can be 3D or 4D homogeneous coordinates. |
Definition at line 182 of file FitCircle3D.hpp.
TRTK::FitCircle3D< T >::FitCircle3D | ( | const std::vector< Vector3T > & | points ) |
Constructs a FitCircle3D object.
T | scalar type of the coordinates |
[in] | points | Points lying on the circle. |
Definition at line 199 of file FitCircle3D.hpp.
TRTK::FitCircle3D< T >::FitCircle3D | ( | const std::vector< Vector4T, Eigen::aligned_allocator< Vector4T > > & | points ) |
Constructs an FitCircle3D object.
T | scalar type of the coordinates |
[in] | points | Points 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.
TRTK::FitCircle3D< T >::~FitCircle3D | ( | ) | [virtual] |
Destructs the FitCircle3D object.
T | scalar type of the coordinates |
Definition at line 233 of file FitCircle3D.hpp.
void TRTK::FitCircle3D< T >::compute | ( | ) | [virtual] |
Runs the fitting algorithm.
T | scalar type of the coordinates |
There must be at least 3 known points on the circle to perform the fitting.
ErrorObj | If there are not enough points to fit the circle, an error object is thrown and its error code is set to NOT_ENOUGH_POINTS . |
Implements TRTK::Fit3D< T >.
Definition at line 252 of file FitCircle3D.hpp.
const Coordinate< T > & TRTK::FitCircle3D< T >::getCenterPoint | ( | ) | const |
Returns the center point of the circle.
T | scalar type of the coordinates |
Definition at line 350 of file FitCircle3D.hpp.
T TRTK::FitCircle3D< T >::getDistanceTo | ( | const Coordinate< T > & | point ) | const [virtual] |
Returns the shortest distance from the circle to the given point.
T | scalar type of the coordinates |
[in] | point | A 2D coordinate. |
Implements TRTK::Fit3D< T >.
Definition at line 364 of file FitCircle3D.hpp.
const Coordinate< T > & TRTK::FitCircle3D< T >::getNormal | ( | ) | const |
Returns the normal of the plane the circle lies in.
T | scalar type of the coordinates |
Definition at line 404 of file FitCircle3D.hpp.
T TRTK::FitCircle3D< T >::getRadius | ( | ) | const |
Returns the radius of the circle.
T | scalar type of the coordinates |
Definition at line 423 of file FitCircle3D.hpp.
T TRTK::FitCircle3D< T >::getRMS | ( | ) | const [virtual] |
Returns the root mean square error.
T | scalar type of the coordinates |
Implements TRTK::Fit3D< T >.
Definition at line 435 of file FitCircle3D.hpp.
void TRTK::Fit3D< T >::setPoints | ( | const std::vector< Vector4T, Eigen::aligned_allocator< Vector4T > > & | points ) | [inherited] |
Sets the point set.
T | scalar type of the coordinates |
[in] | points | 4D homogeneous coordinates. |
void TRTK::Fit3D< T >::setPoints | ( | const std::vector< Vector3T > & | points ) | [inherited] |
void TRTK::Fit3D< T >::setPoints | ( | const std::vector< Coordinate< T > > & | points ) | [virtual, inherited] |
Sets the point set.
T | scalar type of the coordinates |
[in] | points | The points can either be plain 3D or 4D homogeneous coordinates. |
ErrorObj | If 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 >.
Documentation generated by Doxygen