27 #include "../common/MatrixUtils.h"
34 #include <boost/numeric/ublas/matrix.hpp>
46 static std::string name(
"ThirdDegreePolynomial" );
57 const double& pt1Y,
double& pt2X,
double& pt2Y )
const
59 assert( isValid( params ) );
87 const double& pt2Y,
double& pt1X,
double& pt1Y )
const
89 assert( isValid( params ) );
133 const unsigned int tiepointsSize = params.
m_tiePoints.size();
134 if( tiepointsSize < getMinRequiredTiePoints() )
return false;
136 boost::numeric::ublas::matrix< double > W( tiepointsSize, 10 );
137 boost::numeric::ublas::matrix< double > WI( tiepointsSize, 10 );
138 boost::numeric::ublas::matrix< double > X( tiepointsSize, 1 );
139 boost::numeric::ublas::matrix< double > XI( tiepointsSize, 1 );
140 boost::numeric::ublas::matrix< double > Y( tiepointsSize, 1 );
141 boost::numeric::ublas::matrix< double > YI( tiepointsSize, 1 );
143 for (
unsigned int tpIdx = 0 ; tpIdx < tiepointsSize ; ++tpIdx )
148 W( tpIdx, 1 ) = pt1.
x;
149 W( tpIdx, 2 ) = pt1.
y;
150 W( tpIdx, 3 ) = pt1.
x * pt1.
x;
151 W( tpIdx, 4 ) = pt1.
x * pt1.
y;
152 W( tpIdx, 5 ) = pt1.
y * pt1.
y;
153 W( tpIdx, 6 ) = pt1.
x * pt1.
x * pt1.
x;
154 W( tpIdx, 7 ) = pt1.
x * pt1.
x * pt1.
y;
155 W( tpIdx, 8 ) = pt1.
x * pt1.
y * pt1.
y;
156 W( tpIdx, 9 ) = pt1.
y * pt1.
y * pt1.
y;
161 WI( tpIdx, 1 ) = pt2.
x;
162 WI( tpIdx, 2 ) = pt2.
y;
163 WI( tpIdx, 3 ) = pt2.
x * pt2.
x;
164 WI( tpIdx, 4 ) = pt2.
x * pt2.
y;
165 WI( tpIdx, 5 ) = pt2.
y * pt2.
y;
166 WI( tpIdx, 6 ) = pt2.
x * pt2.
x * pt2.
x;
167 WI( tpIdx, 7 ) = pt2.
x * pt2.
x * pt2.
y;
168 WI( tpIdx, 8 ) = pt2.
x * pt2.
y * pt2.
y;
169 WI( tpIdx, 9 ) = pt2.
y * pt2.
y * pt2.
y;
171 X( tpIdx, 0 ) = pt2.
x;
173 XI( tpIdx, 0 ) = pt1.
x;
175 Y( tpIdx, 0 ) = pt2.
y;
177 YI( tpIdx, 0 ) = pt1.
y;
182 boost::numeric::ublas::matrix< double > PinvW;
185 boost::numeric::ublas::matrix< double > PinvWI;
188 boost::numeric::ublas::matrix< double >
A( boost::numeric::ublas::prod( PinvW, X ) );
190 boost::numeric::ublas::matrix< double > AI( boost::numeric::ublas::prod( PinvWI, XI ) );
192 boost::numeric::ublas::matrix< double > B( boost::numeric::ublas::prod( PinvW, Y ) );
194 boost::numeric::ublas::matrix< double > BI( boost::numeric::ublas::prod( PinvWI, YI ) );
~ThirdDegreePolynomialGT()
Destructor.
ThirdDegreePolynomialGT()
Default constructor.
bool getPseudoInverseMatrix(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
Pseudo matrix inversion.
unsigned int getMinRequiredTiePoints() const
Returns the minimum number of required tie-points for the current transformation. ...
void inverseMap(const GTParameters ¶ms, const double &pt2X, const double &pt2Y, double &pt1X, double &pt1Y) const
Inverse mapping (from pt2 space into pt1 space).
GeometricTransformation * clone() const
Creat a clone copy of this instance.
Third Degree Polynomial Geometric transformation.
Third Degree Polynomial Geometric transformation.
An utility struct for representing 2D coordinates.
bool computeParameters(GTParameters ¶ms) const
Calculate the transformation parameters following the new supplied tie-points.
bool isValid() const
Tells if the current instance has a valid transformation.
std::vector< TiePoint > m_tiePoints
Tie points.
const std::string & getName() const
Returns the current transformation name.
GTParameters m_internalParameters
The current internal parameters.
std::vector< double > m_inverseParameters
Transformation numeric inverse parameters.
2D Geometric transformation base class.
std::vector< double > m_directParameters
Transformation numeric direct parameters.
2D Geometric transformation parameters.
void directMap(const GTParameters ¶ms, const double &pt1X, const double &pt1Y, double &pt2X, double &pt2Y) const
Direct mapping (from pt1 space into pt2 space).