Files
qt6-migration-pipeline/external/GeographicLib/share/doc/GeographicLib-dev/example-Cartesian3.cpp
T
torsten 77c67c12ca Execute the same instructions but now for tools in folders you are getti
Entire-Metadata: .entire/metadata/fb87247f-2a75-407e-b336-cbc8c20ba5a6
Entire-Session: fb87247f-2a75-407e-b336-cbc8c20ba5a6
Entire-Strategy: manual-commit
2026-09-24 16:24:51 +00:00

37 lines
998 B
C++

// Example of using the Triaxial::Cartesian3 class.
#include <iostream>
#include <iomanip>
#include <exception>
#include <random>
#include <GeographicLib/Triaxial/Cartesian3.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
using Triaxial::Cartesian3;
Cartesian3 cart(3, 2, 1);
unsigned long long
s1 = std::random_device()(),
s2 = std::random_device()();
std::seed_seq seq{s1, s2};
std::mt19937 g(seq);
cout << "10 random points on the ellipsoid with semiaxes [3, 2, 1]\n"
<< "X Y Z beta omega\n" << fixed << setprecision(3);
Cartesian3::vec3 r;
Angle bet, omg;
for (int i = 0; i < 10; ++i) {
cart.cart2rand(g, r);
cart.cart2toany(r, Cartesian3::ELLIPSOIDAL, bet, omg);
cout << r[0] << " " << r[1] << " " << r[2] << " "
<< double(bet) << " " << double(omg) << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}