transformations: standardize parameter passing by reference (#33469)

pass parameters by reference
This commit is contained in:
Dean Lee
2024-09-08 08:06:57 +08:00
committed by GitHub
parent 606943010e
commit b286a2f0e5
5 changed files with 56 additions and 56 deletions
+9 -9
View File
@@ -25,8 +25,8 @@ static Geodetic to_radians(Geodetic geodetic){
}
ECEF geodetic2ecef(Geodetic g){
g = to_radians(g);
ECEF geodetic2ecef(const Geodetic &geodetic) {
auto g = to_radians(geodetic);
double xi = sqrt(1.0 - esq * pow(sin(g.lat), 2));
double x = (a / xi + g.alt) * cos(g.lat) * cos(g.lon);
double y = (a / xi + g.alt) * cos(g.lat) * sin(g.lon);
@@ -34,7 +34,7 @@ ECEF geodetic2ecef(Geodetic g){
return {x, y, z};
}
Geodetic ecef2geodetic(ECEF e){
Geodetic ecef2geodetic(const ECEF &e) {
// Convert from ECEF to geodetic using Ferrari's methods
// https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ferrari.27s_solution
double x = e.x;
@@ -61,10 +61,10 @@ Geodetic ecef2geodetic(ECEF e){
return to_degrees({lat, lon, h});
}
LocalCoord::LocalCoord(Geodetic g, ECEF e){
LocalCoord::LocalCoord(const Geodetic &geodetic, const ECEF &e) {
init_ecef << e.x, e.y, e.z;
g = to_radians(g);
auto g = to_radians(geodetic);
ned2ecef_matrix <<
-sin(g.lat)*cos(g.lon), -sin(g.lon), -cos(g.lat)*cos(g.lon),
@@ -73,7 +73,7 @@ LocalCoord::LocalCoord(Geodetic g, ECEF e){
ecef2ned_matrix = ned2ecef_matrix.transpose();
}
NED LocalCoord::ecef2ned(ECEF e) {
NED LocalCoord::ecef2ned(const ECEF &e) {
Eigen::Vector3d ecef;
ecef << e.x, e.y, e.z;
@@ -81,7 +81,7 @@ NED LocalCoord::ecef2ned(ECEF e) {
return {ned[0], ned[1], ned[2]};
}
ECEF LocalCoord::ned2ecef(NED n) {
ECEF LocalCoord::ned2ecef(const NED &n) {
Eigen::Vector3d ned;
ned << n.n, n.e, n.d;
@@ -89,12 +89,12 @@ ECEF LocalCoord::ned2ecef(NED n) {
return {ecef[0], ecef[1], ecef[2]};
}
NED LocalCoord::geodetic2ned(Geodetic g) {
NED LocalCoord::geodetic2ned(const Geodetic &g) {
ECEF e = ::geodetic2ecef(g);
return ecef2ned(e);
}
Geodetic LocalCoord::ned2geodetic(NED n){
Geodetic LocalCoord::ned2geodetic(const NED &n) {
ECEF e = ned2ecef(n);
return ::ecef2geodetic(e);
}