26 #include "HomgPoint2DCov.hh"
27 #include "HomgPoint2D.hh"
29 #include <Base/Debug/Exception.hh>
66 BEXCEPTION(
"not a covariance matrix "<<*
this);
75 BEXCEPTION(
"not a covariance matrix "<<*
this);
93 J[0][0] = J[1][1] = 1.0/p[2];
94 J[0][2] = -p[0]/p[2]/p[2];
95 J[1][2] = -p[1]/p[2]/p[2];
100 cout << __FILE__<<
":"<<__LINE__<<
" p " << p <<
" at infinity, doing nothing." << endl;
108 const double norm = p.
NormL2();
127 BEXCEPTION(
"Euclidean cov matrices can only be returned when homogenized: " << *
this);
130 res[0][0] = (*this)[0][0];
131 res[0][1] = (*this)[0][1];
132 res[1][0] = (*this)[1][0];
133 res[1][1] = (*this)[1][1];
142 (*this)[0][0] = m[0][0] ;
143 (*this)[0][1] = m[0][1] ;
144 (*this)[1][0] = m[1][0] ;
145 (*this)[1][1] = m[1][1] ;
147 BEXCEPTION(
"Not a covariance matrix, symmetry check failed: "<< *
this);
155 const double eps = 1e-10;
156 return (
Equal((*
this)[0][1], (*
this)[1][0], eps) &&
157 Equal((*
this)[0][2], (*
this)[2][0], eps) &&
158 Equal((*
this)[1][2], (*
this)[2][1], eps) );
162 (*this)[1][0] = (*this)[0][1] = ((*this)[0][1] + (*this)[1][0])/2.0;
163 (*this)[2][0] = (*this)[0][2] = ((*this)[0][2] + (*this)[2][0])/2.0;
164 (*this)[2][1] = (*this)[1][2] = ((*this)[1][2] + (*this)[2][1])/2.0;
169 (*this)[0][0] = m[0][0];
170 (*this)[1][1] = m[1][1];
171 (*this)[2][2] = m[2][2];
172 (*this)[1][0] = (*this)[0][1] = (m[0][1] + m[1][0])/2.0;
173 (*this)[2][0] = (*this)[0][2] = (m[0][2] + m[2][0])/2.0;
174 (*this)[2][1] = (*this)[1][2] = (m[1][2] + m[2][1])/2.0;
MatrixInitType
can be passed to matrix constructors to init the matrix with the most often used values ...
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
virtual ~HomgPoint2DCov()
Matrix2x2< double > GetEuclidean() const
void ScalarProduct(const Vector3< T > &argvec, T &result) const
scalar product (=inner product) of two vectors, storing the result in result
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
void OuterProduct(const Vector3< T > &v, Matrix3x3< T > &res) const
outer product, constructs a matrix.
void SetEuclidean(const Matrix2x2< double > &m)
void Homogenize(HomgPoint2D &p)
homogenizes p and *this
bool IsAtInfinity() const
is a 'fixed size' quadratic matrix of dim.
bool CheckSymmetry() const
checks whether matrix is symmetric
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
void MakeSymmetric()
averages transposed elements to make symmetric
void SetAndMakeSymmetric(const Matrix3x3< double > &m)
Sets from matrix and enforces symmetry.
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
double Normalize()
divide this by biggest absolute entry, returns biggest entry
bool IsHomogenized() const