80 r =
sqrt(x * x + z * z);
84 if (absza < ANGTOL || absza > 180 -
ANGTOL) {
91 lat = lat - 360.0 *
Numeric(round((lat - lat0) / 360.0));
123 r =
sqrt(x * x + z * z);
127 if (absza < ANGTOL || absza > 180 -
ANGTOL) {
136 const Numeric coslat = cos(latrad);
137 const Numeric sinlat = sin(latrad);
138 const Numeric dr = coslat * dx + sinlat * dz;
150 if (std::isnan(za)) {
156 if (std::isnan(za)) {
187 assert(
abs(lat2 - lat1) <= 180);
195 l =
sqrt(dx * dx + dz * dz);
287 const Numeric a = dx * dx + dz * dz;
288 const Numeric b = 2 * (dx * (xl - xc) + dz * (zl - zc));
290 xc * xc + zc * zc + xl * xl + zl * zl - 2 * (xc * xl + zc * zl) - r * r;
363 assert(za >= -180 && za <= 180);
368 const Numeric coslat = cos(latrad);
369 const Numeric sinlat = sin(latrad);
370 const Numeric cosza = cos(zarad);
371 const Numeric sinza = sin(zarad);
380 dx = coslat * dr - sinlat * dlat;
381 dz = sinlat * dr + coslat * dlat;
441 r =
sqrt(x * x + y * y + z * z);
444 if (za0 < ANGTOL || za0 > 180 -
ANGTOL) {
455 bool ns_case =
false;
456 bool lon_flip =
false;
464 if (
abs(
abs(lon - lon0) - 180) < 5) {
478 const Numeric coslat = cos(latrad);
479 const Numeric sinlat = sin(latrad);
480 const Numeric coslon = cos(lonrad);
481 const Numeric sinlon = sin(lonrad);
489 if (std::isnan(za)) {
496 sqrt(
pow(x - x0, 2.0) +
pow(y - y0, 2.0) +
pow(z - z0, 2.0));
497 const Numeric r0 =
sqrt(x0 * x0 + y0 * y0 + z0 * z0);
524 const Numeric dlat = -sinlat * coslon / r * dx -
525 sinlat * sinlon / r * dy + coslat / r * dz;
526 const Numeric dlon = -sinlon / coslat / r * dx + coslon / coslat / r * dy;
530 if (std::isnan(aa)) {
536 }
else if (dlon < 0) {
573 r =
sqrt(x * x + y * y + z * z);
576 if (za0 < ANGTOL || za0 > 180 -
ANGTOL) {
590 if (
abs(lon - lon0) < 1) {
626 sph2cart(x1, y1, z1, r1, lat1, lon1);
627 sph2cart(x2, y2, z2, r2, lat2, lon2);
632 l =
sqrt(dx * dx + dy * dy + dz * dz);
670 poslos2cart(x, y, z, dx, dy, dz, r, lat, lon, za, aa);
672 l_tan =
sqrt(r * r - ppc * ppc);
836 const Numeric a = dx * dx + dy * dy + dz * dz;
837 const Numeric b = 2 * (dx * (xl - xc) + dy * (yl - yc) + dz * (zl - zc));
838 const Numeric c = xc * xc + yc * yc + zc * zc + xl * xl + yl * yl + zl * zl -
839 2 * (xc * xl + yc * yl + zc * zl) - r * r;
894 const Numeric cosdang = cos(dang);
895 const Numeric sindang = sin(dang);
897 const Numeric coslat = cos(latrad);
898 const Numeric sinlat = sin(latrad);
901 lat2 = sinlat * cosdang + coslat * sindang * cos(aarad);
902 lon2 = lon1 +
RAD2DEG * (atan2(sin(aarad) * sindang * coslat,
903 cosdang - sinlat * lat2));
941 const Numeric ldxyz =
sqrt(dx * dx + dy * dy + dz * dz);
949 const Numeric coslat = cos(latrad);
950 const Numeric sinlat = sin(latrad);
951 const Numeric coslon = cos(lonrad);
952 const Numeric sinlon = sin(lonrad);
954 const Numeric dr = coslat * coslon * dx + coslat * sinlon * dy + sinlat * dz;
956 -sinlat * coslon / r1 * dx - sinlat * sinlon / r1 * dy + coslat / r1 * dz;
957 const Numeric dlon = -sinlon / coslat / r1 * dx + coslon / coslat / r1 * dy;
961 if (std::isnan(aa)) {
967 }
else if (dlon < 0) {
1009 assert(
abs(lat) <= 90);
1011 assert(za >= 0 && za <= 180);
1035 const Numeric coslat = cos(latrad);
1036 const Numeric sinlat = sin(latrad);
1037 const Numeric coslon = cos(lonrad);
1038 const Numeric sinlon = sin(lonrad);
1039 const Numeric cosza = cos(zarad);
1040 const Numeric sinza = sin(zarad);
1041 const Numeric cosaa = cos(aarad);
1042 const Numeric sinaa = sin(aarad);
1051 const Numeric dlat = sinza * cosaa;
1052 const Numeric dlon = sinza * sinaa / coslat;
1054 dx = coslat * coslon * dr - sinlat * coslon * dlat - coslat * sinlon * dlon;
1055 dz = sinlat * dr + coslat * dlat;
1056 dy = coslat * sinlon * dr - sinlat * sinlon * dlat + coslat * coslon * dlon;
1086 if (atmosphere_dim == 1) {
1087 return refellipsoid[0];
1089 assert(rte_pos.
nelem() > 1);
1093 if (rte_pos[1] < lat_grid[0] || rte_pos[1] >
last(lat_grid)) {
1095 }
else if (atmosphere_dim == 3) {
1096 assert(rte_pos.
nelem() == 3);
1097 if (rte_pos[2] < lon_grid[0] || rte_pos[2] >
last(lon_grid)) {
1104 gridpos(gp_lat, lat_grid, rte_pos[1]);
1105 return refell2d(refellipsoid, lat_grid, gp_lat);
1107 return refell2r(refellipsoid, rte_pos[1]);
1136 assert(refellipsoid.
nelem() == 2);
1137 assert(refellipsoid[0] > 0);
1138 assert(refellipsoid[1] >= 0);
1139 assert(refellipsoid[1] < 1);
1141 if (refellipsoid[1] < 1e-7)
1143 return refellipsoid[0];
1147 const Numeric c = 1 - refellipsoid[1] * refellipsoid[1];
1153 return b /
sqrt(c * ct * ct + st * st);
1179 else if (gp.
fd[0] == 1)
1180 return refell2r(refellipsoid, lat_grid[gp.
idx + 1]);
1182 return gp.
fd[1] *
refell2r(refellipsoid, lat_grid[gp.
idx]) +
1213 slat * slat + cos(
DEG2RAD * lat1) * cos(
DEG2RAD * lat2) * slon * slon;
1243 assert(
abs(lat) <= 90);
1244 assert(
abs(lon) <= 360);
1249 x = r * cos(latrad);
1250 y = x * sin(lonrad);
1251 x = x * cos(lonrad);
1252 z = r * sin(latrad);
1279 longrid_out = longrid_in;
1280 if (longrid_in[longrid_in.
nelem() - 1] >= lon + 360.)
1281 longrid_out += -360.;
1282 else if (longrid_in[0] <= lon - 360.)
1283 longrid_out += 360.;
1302 throw std::runtime_error(
"Latitude values < -180.0 are not supported.");
1305 throw std::runtime_error(
"Latitude values > 180.0 are not supported.");
1320 while (lon > 360.0) {
INDEX Index
The type to use for all integer numbers and indices.
void latlon_at_aa(Numeric &lat2, Numeric &lon2, const Numeric &lat1, const Numeric &lon1, const Numeric &aa, const Numeric &ddeg)
latlon_at_aa
void los2xyz(Numeric &za, Numeric &aa, const Numeric &r1, const Numeric &lat1, const Numeric &lon1, const Numeric &x1, const Numeric &y1, const Numeric &z1, const Numeric &x2, const Numeric &y2, const Numeric &z2)
los2xyz
void distance2D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &r2, const Numeric &lat2)
distance2D
void pol2cart(Numeric &x, Numeric &z, const Numeric &r, const Numeric &lat)
pol2cart
void line_circle_intersect(Numeric &x, Numeric &z, const Numeric &xl, const Numeric &zl, const Numeric &dx, const Numeric &dz, const Numeric &xc, const Numeric &zc, const Numeric &r)
geomtanpoint2d
Numeric last(ConstVectorView x)
last
Numeric refell2d(ConstVectorView refellipsoid, ConstVectorView lat_grid, const GridPos gp)
refell2d
Index nelem() const
Returns the number of elements.
Structure to store a grid position.
Numeric sign(const Numeric &x)
sign
const Numeric ANGTOL
Width of zenith and nadir directions.
Numeric sphdist(const Numeric &lat1, const Numeric &lon1, const Numeric &lat2, const Numeric &lon2)
sphdist
void cart2poslos(Numeric &r, Numeric &lat, Numeric &za, const Numeric &x, const Numeric &z, const Numeric &dx, const Numeric &dz, const Numeric &ppc, const Numeric &lat0, const Numeric &za0)
cart2poslos
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
NUMERIC Numeric
The type to use for all floating point numbers.
void distance3D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &lon1, const Numeric &r2, const Numeric &lat2, const Numeric &lon2)
distance3D
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
Propagation path structure and functions.
Numeric pow(const Rational base, Numeric exp)
Power of.
void lon_shiftgrid(Vector &longrid_out, ConstVectorView longrid_in, const Numeric lon)
lon_shiftgrid
void cycle_lat_lon(Numeric &lat, Numeric &lon)
Cyclic latitude longitude coordinates.
void cart2pol(Numeric &r, Numeric &lat, const Numeric &x, const Numeric &z, const Numeric &lat0, const Numeric &za0)
cart2pol
A constant view of a Vector.
void cart2sph(Numeric &r, Numeric &lat, Numeric &lon, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &lat0, const Numeric &lon0, const Numeric &za0, const Numeric &aa0)
cart2sph
void sph2cart(Numeric &x, Numeric &y, Numeric &z, const Numeric &r, const Numeric &lat, const Numeric &lon)
sph2cart
const Numeric POLELAT
Size of north and south poles.
void geompath_tanpos_3d(Numeric &r_tan, Numeric &lat_tan, Numeric &lon_tan, Numeric &l_tan, const Numeric &r, const Numeric &lat, const Numeric &lon, const Numeric &za, const Numeric &aa, const Numeric &ppc)
geompath_tanpos_3d
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
void line_sphere_intersect(Numeric &x, Numeric &y, Numeric &z, const Numeric &xl, const Numeric &yl, const Numeric &zl, const Numeric &dx, const Numeric &dy, const Numeric &dz, const Numeric &xc, const Numeric &yc, const Numeric &zc, const Numeric &r)
geomtanpoint
Numeric geompath_l_at_r(const Numeric &ppc, const Numeric &r)
Calculates the length from the tangent point for the given radius.
Numeric sqrt(const Rational r)
Square root.
Numeric pos2refell_r(const Index &atmosphere_dim, ConstVectorView refellipsoid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView rte_pos)
pos2refell_r