27 #include "../common/MatrixUtils.h"
34 #include <boost/numeric/ublas/matrix.hpp>
46 static std::string name(
"RST" );
57 const double& pt1Y,
double& pt2X,
double& pt2Y )
const
59 assert( isValid( params ) );
70 const double& pt2Y,
double& pt1X,
double& pt1Y )
const
72 assert( isValid( params ) );
96 const unsigned int tiepointsSize = params.
m_tiePoints.size();
97 if( tiepointsSize < 2 )
return false;
99 boost::numeric::ublas::matrix< double >
A( 2 * tiepointsSize, 4 );
100 boost::numeric::ublas::matrix< double >
L( 2 * tiepointsSize, 1 );
101 unsigned int index1 = 0;
102 unsigned int index2 = 0;
104 for (
unsigned int tpIdx = 0 ; tpIdx < tiepointsSize ; ++tpIdx )
112 A( index1, 0 ) = x_y.
x;
113 A( index1, 1 ) = -1.0 * x_y.
y;
114 A( index1, 2 ) = 1.0;
115 A( index1, 3 ) = 0.0;
117 A( index2, 0 ) = x_y.
y;
118 A( index2, 1 ) = x_y.
x;
119 A( index2, 2 ) = 0.0;
120 A( index2, 3 ) = 1.0;
122 L( index1, 0 ) = u_v.
x;
123 L( index2, 0 ) = u_v.
y;
130 boost::numeric::ublas::matrix< double > At( boost::numeric::ublas::trans( A ) ) ;
133 boost::numeric::ublas::matrix< double > N( boost::numeric::ublas::prod( At, A ) );
136 boost::numeric::ublas::matrix< double > U( boost::numeric::ublas::prod( At, L ) );
139 boost::numeric::ublas::matrix< double > N_inv;
145 boost::numeric::ublas::matrix< double > X(
146 boost::numeric::ublas::prod( N_inv, U ) );
158 boost::numeric::ublas::matrix< double > XExpanded( 3, 3 );
159 XExpanded( 0, 0 ) = X(0,0);
160 XExpanded( 0, 1 ) = -1.0 * X(1,0);
161 XExpanded( 0, 2 ) = X(2,0);
162 XExpanded( 1, 0 ) = X(1,0);
163 XExpanded( 1, 1 ) = X(0,0);
164 XExpanded( 1, 2 ) = X(3,0);
165 XExpanded( 2, 0 ) = 0;
166 XExpanded( 2, 1 ) = 0;
167 XExpanded( 2, 2 ) = 1;
171 boost::numeric::ublas::matrix< double > XExpandedInv;
2D Rotation/scale/translation (rigid body) Geometric transformation.
std::vector< TiePoint > m_tiePoints
Tie points.
void inverseMap(const GTParameters ¶ms, const double &pt2X, const double &pt2Y, double &pt1X, double &pt1Y) const
Inverse mapping (from pt2 space into pt1 space).
std::vector< double > m_directParameters
Transformation numeric direct parameters.
RSTGT()
Default constructor.
const std::string & getName() const
Returns the current transformation name.
An utility struct for representing 2D coordinates.
void directMap(const GTParameters ¶ms, const double &pt1X, const double &pt1Y, double &pt2X, double &pt2Y) const
Direct mapping (from pt1 space into pt2 space).
2D Rotation/scale/translation(rigid body) Geometric transformation.
bool GetInverseMatrix(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
Matrix inversion.
std::vector< double > m_inverseParameters
Transformation numeric inverse parameters.
unsigned int getMinRequiredTiePoints() const
Returns the minimum number of required tie-points for the current transformation. ...
GeometricTransformation * clone() const
Creat a clone copy of this instance.
2D Geometric transformation parameters.
bool computeParameters(GTParameters ¶ms) const
Calculate the transformation parameters following the new supplied tie-points.