Technology sharing

UAV positioning of grounding movens scuta --- obtinens directionem movens et velocitas scopo

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Tabula contentorum

1. Introductio

Monoculari fuco utimur ad scopum mobilem in terra collocandum, aequis temporis intervallis imagines capiendo. .

2. Codicis explicatio

1. Notitia importata est fasciculus txt constans e nomine photo et tribus dimensivis notae scopo punctum, ut munus segmentationis chordae constituere necesse est ut notitias tabellae in tabella obtineant.

2. Definire pi valorem

3. Definire directionem calculi munus

4. Extract notitia requiritur ex file txt

5. Adice directionem mutationem angulum scopum inter adjacent photos

6. Adice movens distantiam et celeritatem scopum inter adjacent photos

3. The code ostentationem

4. Ex ostentationem

Omnes codices in hoc articulo ab CSDN usore CV-X.WANG praebentur. Quilibet homo vel coetus non licet actiones commercii et docendi.


1. Introductio

        Monoculari fuco utimur ad scopum mobilem in terra collocandum, aequis temporis intervallis imagines capiendo. .

2. Codicis explicatio

1. Notitia importata est fasciculus txt constans e nomine photo et tribus dimensivis notae scopo punctum, ut munus segmentationis chordae constituere necesse est ut notitias tabellae in tabella obtineant.

  1. //字符串分割
  2. vector<string> split(const string &s, char delimiter) {
  3. vector<string> tokens;
  4. string token;
  5. istringstream tokenStream(s);
  6. while (getline(tokenStream, token, delimiter)) {
  7. tokens.push_back(token);
  8. }
  9. return tokens;
  10. }

2. Definire pi valorem

#define M_PI       3.14159265358979323846   // pi

3. Definire directionem calculi munus

Ut directionem movens scopum obtineat in directum planum, hic articulus assumit methodum directionem 360°, quae communis est in campo militari. Hoc est, verus aquilo est directio 0°, et directio horologico 0-360°.

quidam,

duplex lon1_rad = lon1 * M_PI / 180.0;
duplex lat1_rad = lat1 * M_PI / 180.0;
duplex lon2_rad = lon2 * M_PI / 180.0;
geminus lat2_rad = lat2 * M_PI / 180.0;

Est in radiis.

  1. //方向函数
  2. double calculateDirectionAngle(double lon1, double lat1, double lon2, double lat2) {
  3. // Convert degrees to radians
  4. double lon1_rad = lon1 * M_PI / 180.0;
  5. double lat1_rad = lat1 * M_PI / 180.0;
  6. double lon2_rad = lon2 * M_PI / 180.0;
  7. double lat2_rad = lat2 * M_PI / 180.0;
  8. // Calculate delta longitude and convert to radians
  9. double delta_lon_rad = (lon2 - lon1) * M_PI / 180.0;
  10. // Calculate y and x components
  11. double y = sin(delta_lon_rad) * cos(lat2_rad);
  12. double x = cos(lat1_rad) * sin(lat2_rad) - sin(lat1_rad) * cos(lat2_rad) * cos(delta_lon_rad);
  13. // Calculate direction angle in radians
  14. double direction_rad = atan2(y, x);
  15. // Convert direction angle to degrees
  16. double direction_deg = direction_rad * 180.0 / M_PI;
  17. // Ensure direction angle is within [0, 360) degrees
  18. if (direction_deg < 0) {
  19. direction_deg += 360.0;
  20. }
  21. return direction_deg;
  22. }

4. Extract notitia requiritur ex file txt

  1. ifstream file("LBH.txt");
  2. if (!file.is_open()) {
  3. cerr << "Could not open the file!" << endl;
  4. return 1;
  5. }
  6. string line;
  7. // Skip the header line
  8. getline(file, line);
  9. vector<vector<string>> extractedData;
  10. // Read each line from the file
  11. while (getline(file, line)) {
  12. vector<string> columns = split(line, 't');
  13. if (columns.size() < 16) {
  14. cerr << "Invalid line format" << endl;
  15. continue;
  16. }
  17. // Extract the required columns: 0, 13, 14, 15
  18. vector<string> extractedColumns;
  19. extractedColumns.push_back(columns[0]); // Image Name
  20. extractedColumns.push_back(columns[13]); // Longitude
  21. extractedColumns.push_back(columns[14]); // Latitude
  22. extractedColumns.push_back(columns[15]); // Altitude
  23. extractedData.push_back(extractedColumns);
  24. }
  25. file.close();

5. Adice directionem mutationem angulum scopum inter adjacent photos

  1. cout << "Direction angles between adjacent image centers:" << endl;
  2. for (size_t i = 1; i < extractedData.size(); ++i) {
  3. //三角函数计算用弧度制
  4. double lon1 = (stod(extractedData[i - 1][1]))* M_PI/180; // Longitude
  5. double lat1 = (stod(extractedData[i - 1][2]))* M_PI / 180; // Latitude
  6. double lon2 = (stod(extractedData[i][1]))* M_PI / 180; // Longitude
  7. double lat2 = (stod(extractedData[i][2]))* M_PI / 180; // Latitude
  8. //计算方向变化角也要用弧度制
  9. double direction_angle = calculateDirectionAngle(lon1, lat1, lon2, lat2);
  10. cout << "lon1=" << lon1 << endl << "lat1=" << lat1 << endl << "lon2=" << lon2 << endl << "lat2=" << lat2 << endl;
  11. // Output Direction
  12. cout << "Direction from " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << direction_angle << " degrees" << endl;

6. Adice movens distantiam et celeritatem scopum inter adjacent photos

Quaeso note: Formula calculi pro longinquo quod hic egimus est:

Haec demonstratio simplicissima est. In ipsis adiunctis considerare oportet seriem conditionum ut systema coordinatum, mensurae spatium, etc., accuratiorem distantiam obtineant.

  1. double lon2_1 = lon2 - lon1;
  2. double lat2_1 = lat2 - lat1;
  3. double lon_ = lon2_1 / 2;//1/2的Δlon
  4. double lat_ = lat2_1 / 2; //1 / 2的Δlat
  5. double sin2lon_ = sin(lon_)*sin(lon_);//sin²(1/2Δlon)
  6. double sin2lat_ = sin(lat_)*sin(lat_); //sin²(1 / 2Δlat)
  7. double cos_lat1 = cos(lat1);
  8. double cos_lat2 = cos(lat2);
  9. double sqrtA = sqrt(sin2lat_+ cos_lat1* cos_lat2*sin2lon_);
  10. //cout << "Direction from " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "sqrtA =" << sqrtA << endl;
  11. double asinA = asin(sqrtA);
  12. //长半轴 短半轴 单位是m
  13. int a_r = 6378137.0;
  14. int b_r = 6356752;
  15. double Earth_R = (2 * a_r + b_r) / 3;
  16. double Distance = 2 * Earth_R*asinA;
  17. cout << "Distance From " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "=" << Distance <<" meter"<< endl;
  18. int time = 3;//拍照间隔 s
  19. double speed = Distance / time;
  20. cout << "Speed From " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "=" << speed << " meter per second" << endl;
  21. }

3. The code ostentationem

  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <vector>
  5. #include <cmath>
  6. using namespace std;
  7. #define M_PI 3.14159265358979323846 // pi
  8. // Function to split a string by a delimiter
  9. vector<string> split(const string &s, char delimiter) {
  10. vector<string> tokens;
  11. string token;
  12. istringstream tokenStream(s);
  13. while (getline(tokenStream, token, delimiter)) {
  14. tokens.push_back(token);
  15. }
  16. return tokens;
  17. }
  18. // direction angle in degrees
  19. //原理是 在平面上以正北方向为0°方向,顺时针为0-360°
  20. double calculateDirectionAngle(double lon1, double lat1, double lon2, double lat2) {
  21. // Convert degrees to radians
  22. double lon1_rad = lon1 * M_PI / 180.0;
  23. double lat1_rad = lat1 * M_PI / 180.0;
  24. double lon2_rad = lon2 * M_PI / 180.0;
  25. double lat2_rad = lat2 * M_PI / 180.0;
  26. // Calculate delta longitude and convert to radians
  27. double delta_lon_rad = (lon2 - lon1) * M_PI / 180.0;
  28. // Calculate y and x components
  29. double y = sin(delta_lon_rad) * cos(lat2_rad);
  30. double x = cos(lat1_rad) * sin(lat2_rad) - sin(lat1_rad) * cos(lat2_rad) * cos(delta_lon_rad);
  31. // Calculate direction angle in radians
  32. double direction_rad = atan2(y, x);
  33. // Convert direction angle to degrees
  34. double direction_deg = direction_rad * 180.0 / M_PI;
  35. // Ensure direction angle is within [0, 360) degrees
  36. if (direction_deg < 0) {
  37. direction_deg += 360.0;
  38. }
  39. return direction_deg;
  40. }
  41. int main() {
  42. ifstream file("LBH.txt");
  43. if (!file.is_open()) {
  44. cerr << "Could not open the file!" << endl;
  45. return 1;
  46. }
  47. string line;
  48. // Skip the header line
  49. getline(file, line);
  50. vector<vector<string>> extractedData;
  51. // Read each line from the file
  52. while (getline(file, line)) {
  53. vector<string> columns = split(line, 't');
  54. if (columns.size() < 16) {
  55. cerr << "Invalid line format" << endl;
  56. continue;
  57. }
  58. // Extract the required columns: 0, 13, 14, 15
  59. vector<string> extractedColumns;
  60. extractedColumns.push_back(columns[0]); // Image Name
  61. extractedColumns.push_back(columns[13]); // Longitude
  62. extractedColumns.push_back(columns[14]); // Latitude
  63. extractedColumns.push_back(columns[15]); // Altitude
  64. extractedData.push_back(extractedColumns);
  65. }
  66. file.close();
  67. // Calculate direction angles between adjacent image centers
  68. cout << "Direction angles between adjacent image centers:" << endl;
  69. for (size_t i = 1; i < extractedData.size(); ++i) {
  70. //三角函数计算用弧度制
  71. double lon1 = (stod(extractedData[i - 1][1]))* M_PI/180; // Longitude
  72. double lat1 = (stod(extractedData[i - 1][2]))* M_PI / 180; // Latitude
  73. double lon2 = (stod(extractedData[i][1]))* M_PI / 180; // Longitude
  74. double lat2 = (stod(extractedData[i][2]))* M_PI / 180; // Latitude
  75. //计算方向变化角也要用弧度制
  76. double direction_angle = calculateDirectionAngle(lon1, lat1, lon2, lat2);
  77. cout << "lon1=" << lon1 << endl << "lat1=" << lat1 << endl << "lon2=" << lon2 << endl << "lat2=" << lat2 << endl;
  78. // Output Direction
  79. cout << "Direction from " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << direction_angle << " degrees" << endl;
  80. double lon2_1 = lon2 - lon1;
  81. double lat2_1 = lat2 - lat1;
  82. double lon_ = lon2_1 / 2;//1/2的Δlon
  83. double lat_ = lat2_1 / 2; //1 / 2的Δlat
  84. double sin2lon_ = sin(lon_)*sin(lon_);//sin²(1/2Δlon)
  85. double sin2lat_ = sin(lat_)*sin(lat_); //sin²(1 / 2Δlat)
  86. double cos_lat1 = cos(lat1);
  87. double cos_lat2 = cos(lat2);
  88. double sqrtA = sqrt(sin2lat_+ cos_lat1* cos_lat2*sin2lon_);
  89. //cout << "Direction from " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "sqrtA =" << sqrtA << endl;
  90. double asinA = asin(sqrtA);
  91. //长半轴 短半轴 单位是m
  92. int a_r = 6378137.0;
  93. int b_r = 6356752;
  94. double Earth_R = (2 * a_r + b_r) / 3;
  95. double Distance = 2 * Earth_R*asinA;
  96. cout << "Distance From " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "=" << Distance <<" meter"<< endl;
  97. int time = 3;//拍照间隔 s
  98. double speed = Distance / time;
  99. cout << "Speed From " << extractedData[i - 1][0] << " to " << extractedData[i][0] << ": " << "=" << speed << " meter per second" << endl;
  100. }
  101. //cin.get();
  102. return 0;
  103. }

4. Ex ostentationem

Omnes codices in hoc articulo ab CSDN usore CV-X.WANG praebenturcuivis personae vel coetus non licet mercaturam ac docendi actionem exercere, et quaevis auctoritas vel partialis auctoritas obtinere debet.