# include & lt; Iostream>
# include "Eigen/Dense"
# include & lt; Vector>
# include & lt; Map>
# include & lt; Fstream>
# include & lt; Sstream>
Using namespace STD.
Using the namespace Eigen;
//read the file
Bool readCECFCoor (vector
The string fileName.//file name
Cout & lt; <"Both Please enter the path \ n";
Cin & gt;> The fileName.
Ifstream file (fileName);
if (! File. The is_open ()) {
Cout & lt; <"Unable to read the file" & lt;
}
The string line;
Vector
Double X=0.0;
Double Y=0.0;
Double Z=0.0;
Int counter=0;
String name="";
While (getline (file, line))
{
Istringstream iss (line);
Iss & gt;> The line;
String individualInfo="";
for (int i=0; I & lt; The line length (); I++)
{
If (line [I]==', ')
{
Name===0 if (counter) individualInfo;
If (counter==1) X=stod (individualInfo);
If (counter==2) Y=stod (individualInfo);
Cout & lt;
IndividualInfo="";
}
The else
{
IndividualInfo=individualInfo + line [I];
}
}
Z=stod (individualInfo);
Cout & lt;
Result. The push_back (tempCoor);
}
File. The close ();
return true;
}
Four parameters calculated for//
Bool computePara_4 (vector
Vector
Int originalCoor_n=originalCoor. The size ();
Int targetCoor_n=targetCoor. The size ();
If (originalCoor_n!=targetCoor_n)
{
Cout & lt; <"The source points coordinate points and the target coordinate system is not equal to! \ n "& lt;
}
If (originalCoor_n * 2-4 & lt; 0)
{
Cout & lt; <"Insufficient condition equation number! Can't solve! \n";
return false;
}
Int d=originalCoor_n;//point number
Int n=para. Precision. N=originalCoor_n * 2;//condition equation number
Para. Precision. R=para. Precision. N - 4;//redundancy
MatrixXd B (n, 4);//matrix
Matrix
Y_s MatrixXd x_s (d, 1), (d, 1), x_t (d, 1), y_t (d, 1);
for (int i=0; I & lt; d; I++)
{
X_s (I, 0)=originalCoor [I]. X.
Y_s (I, 0)=originalCoor [I] y;
X_t (I, 0)=targetCoor [I]. X.
Y_t (I, 0)=targetCoor [I] y;
}
L & lt;
B & lt;
Matrix
Para. Dx=x (0, 0);
Para. Dy=x (1, 0);
Para. R=x (2, 0).
Para. K=x (3, 0).
MatrixXd V (n, 1);
//calculate correct number V
V=- (MatrixXd: : Identity (n, n) - B * (B.t ranspose () * B). The inverse () * B.t ranspose ()) * L;
for (int i=0; I
CoorECEF_withname temp_e={V (I, 0), V (I + d, 0), 0, the name [I]}.
Para. Precision. E.p ush_back (temp_e);
}
//calculate the sigma0
Para. Precision. Sigma0=((V.t ranspose () * V)/para. Precision. R) (0, 0);
Para. Precision. Sigma0=SQRT (para. Precision. Sigma0);
return true;
}
Int main ()
{
Vector
Vector
ComputePara_4 (originalCoor targetCoor, para);
String hold;
Cin & gt;> Hold;
return 0;
}
CodePudding user response:
Int main (){
Vector
ReadCECFCoor (result);//two calls the function, good input different filename ah
Vector