Skip to content

Commit

Permalink
Adds calibu::GetAxesLengths.
Browse files Browse the repository at this point in the history
  • Loading branch information
chachi committed May 13, 2014
1 parent 9d05b10 commit 119dd57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/calibu/conics/Conic.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ std::pair<Eigen::Vector3d,Eigen::Matrix3d > PlaneFromConics(
CALIBU_EXPORT
Conic UnmapConic( const Conic& c, const CameraModelInterface& cam );

/** Returns the major and minor axes lengths of the conic */
CALIBU_EXPORT
Eigen::Vector2d GetAxesLengths(const Conic& c);

}
13 changes: 13 additions & 0 deletions src/conics/Conic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ using namespace Eigen;

namespace calibu {

Eigen::Vector2d GetAxesLengths(const Conic& c) {
// Extract and scale the eigenvalues to get the major, minor axes lengths
Eigen::Vector2d eigenval = c.C.topLeftCorner<2, 2>().eigenvalues().real();

// See
// http://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections
// for explanation of matrix C and its relation to the axes
double det_ratio = -c.C.determinant() /
c.C.topLeftCorner<2, 2>().determinant();
return Eigen::Vector2d(sqrt(det_ratio / eigenval[0]),
sqrt(det_ratio / eigenval[1]));
}

double Distance( const Conic& c1, const Conic& c2, double circle_radius )
{
const Matrix3d Q = c1.Dual * c2.C;
Expand Down

0 comments on commit 119dd57

Please sign in to comment.