81 r =
sqrt(x * x + z * z);
85 if (absza < ANGTOL || absza > 180 -
ANGTOL) {
92 lat = lat - 360.0 *
Numeric(round((lat - lat0) / 360.0));
124 r =
sqrt(x * x + z * z);
128 if (absza < ANGTOL || absza > 180 -
ANGTOL) {
137 const Numeric coslat = cos(latrad);
138 const Numeric sinlat = sin(latrad);
139 const Numeric dr = coslat * dx + sinlat * dz;
151 if (std::isnan(za)) {
157 if (std::isnan(za)) {
196 l =
sqrt(dx * dx + dz * dz);
288 const Numeric a = dx * dx + dz * dz;
289 const Numeric b = 2 * (dx * (xl - xc) + dz * (zl - zc));
291 xc * xc + zc * zc + xl * xl + zl * zl - 2 * (xc * xl + zc * zl) - r * r;
369 const Numeric coslat = cos(latrad);
370 const Numeric sinlat = sin(latrad);
371 const Numeric cosza = cos(zarad);
372 const Numeric sinza = sin(zarad);
381 dx = coslat * dr - sinlat * dlat;
382 dz = sinlat * dr + coslat * dlat;
442 r =
sqrt(x * x + y * y + z * z);
445 if (za0 < ANGTOL || za0 > 180 -
ANGTOL) {
456 bool ns_case =
false;
457 bool lon_flip =
false;
465 if (
abs(
abs(lon - lon0) - 180) < 5) {
479 const Numeric coslat = cos(latrad);
480 const Numeric sinlat = sin(latrad);
481 const Numeric coslon = cos(lonrad);
482 const Numeric sinlon = sin(lonrad);
490 if (std::isnan(za)) {
497 sqrt(
pow(x - x0, 2.0) +
pow(y - y0, 2.0) +
pow(z - z0, 2.0));
498 const Numeric r0 =
sqrt(x0 * x0 + y0 * y0 + z0 * z0);
525 const Numeric dlat = -sinlat * coslon / r * dx -
526 sinlat * sinlon / r * dy + coslat / r * dz;
527 const Numeric dlon = -sinlon / coslat / r * dx + coslon / coslat / r * dy;
531 if (std::isnan(aa)) {
537 }
else if (dlon < 0) {
559 const Numeric coslat = cos(latrad);
560 const Numeric sinlat = sin(latrad);
561 const Numeric coslon = cos(lonrad);
562 const Numeric sinlon = sin(lonrad);
564 const Numeric dr = coslat*coslon*dx + sinlat*dz + coslat*sinlon*dy;
565 const Numeric dlat = -sinlat*coslon/r*dx + coslat/r*dz - sinlat*sinlon/r*dy;
566 const Numeric dlon = -sinlon/coslat/r*dx + coslon/coslat/r*dy;
569 aa =
RAD2DEG * acos( r * dlat / sin( za ) );
573 if (std::isnan(aa)) {
578 }
else if (dlon < 0) {
613 r =
sqrt(x * x + y * y + z * z);
616 if (za0 < ANGTOL || za0 > 180 -
ANGTOL) {
630 if (
abs(lon - lon0) < 1) {
648 r =
sqrt(x * x + y * y + z * z);
677 Numeric x1, y1, z1, x2, y2, z2;
678 sph2cart(x1, y1, z1, r1, lat1, lon1);
679 sph2cart(x2, y2, z2, r2, lat2, lon2);
684 l =
sqrt(dx * dx + dy * dy + dz * dz);
722 poslos2cart(x, y, z, dx, dy, dz, r, lat, lon, za, aa);
724 l_tan =
sqrt(r * r - ppc * ppc);
876 const Vector& refellipsoid,
886 if (refellipsoid[1] < 1e-7) {
887 const Numeric p = x*dx + y*dy + z*dz;
889 const Numeric q = x*x + y*y + z*z - refellipsoid[0]*refellipsoid[0];
906 const Numeric c = refellipsoid[0] *
sqrt(1-refellipsoid[1]*refellipsoid[1]);
917 a2*dz2*y2 +
b2*c2*dx2 -
b2*dx2*z2 + 2*
b2*dx*dz*x*z -
918 b2*dz2*x2 - c2*dx2*y2 + 2*c2*dx*dy*x*y - c2*dy2*x2;
926 l = (val - abc) / mag;
928 l = (val + abc) / mag;
967 const Numeric a = dx * dx + dy * dy + dz * dz;
968 const Numeric b = 2 * (dx * (xl - xc) + dy * (yl - yc) + dz * (zl - zc));
969 const Numeric c = xc * xc + yc * yc + zc * zc + xl * xl + yl * yl + zl * zl -
970 2 * (xc * xl + yc * yl + zc * zl) - r * r;
1025 const Numeric cosdang = cos(dang);
1026 const Numeric sindang = sin(dang);
1028 const Numeric coslat = cos(latrad);
1029 const Numeric sinlat = sin(latrad);
1032 lat2 = sinlat * cosdang + coslat * sindang * cos(aarad);
1033 lon2 = lon1 +
RAD2DEG * (atan2(sin(aarad) * sindang * coslat,
1034 cosdang - sinlat * lat2));
1071 Numeric dx = x2 - x1, dy = y2 - y1, dz = z2 - z1;
1072 const Numeric ldxyz =
sqrt(dx * dx + dy * dy + dz * dz);
1080 const Numeric coslat = cos(latrad);
1081 const Numeric sinlat = sin(latrad);
1082 const Numeric coslon = cos(lonrad);
1083 const Numeric sinlon = sin(lonrad);
1085 const Numeric dr = coslat * coslon * dx + coslat * sinlon * dy + sinlat * dz;
1087 -sinlat * coslon / r1 * dx - sinlat * sinlon / r1 * dy + coslat / r1 * dz;
1088 const Numeric dlon = -sinlon / coslat / r1 * dx + coslon / coslat / r1 * dy;
1092 if (std::isnan(aa)) {
1098 }
else if (dlon < 0) {
1166 const Numeric coslat = cos(latrad);
1167 const Numeric sinlat = sin(latrad);
1168 const Numeric coslon = cos(lonrad);
1169 const Numeric sinlon = sin(lonrad);
1170 const Numeric cosza = cos(zarad);
1171 const Numeric sinza = sin(zarad);
1172 const Numeric cosaa = cos(aarad);
1173 const Numeric sinaa = sin(aarad);
1182 const Numeric dlat = sinza * cosaa;
1183 const Numeric dlon = sinza * sinaa / coslat;
1185 dx = coslat * coslon * dr - sinlat * coslon * dlat - coslat * sinlon * dlon;
1186 dz = sinlat * dr + coslat * dlat;
1187 dy = coslat * sinlon * dr - sinlat * sinlon * dlat + coslat * coslon * dlon;
1217 if (atmosphere_dim == 1) {
1218 return refellipsoid[0];
1224 if (rte_pos[1] < lat_grid[0] || rte_pos[1] >
last(lat_grid)) {
1226 }
else if (atmosphere_dim == 3) {
1228 if (rte_pos[2] < lon_grid[0] || rte_pos[2] >
last(lon_grid)) {
1235 gridpos(gp_lat, lat_grid, rte_pos[1]);
1236 return refell2d(refellipsoid, lat_grid, gp_lat);
1238 return refell2r(refellipsoid, rte_pos[1]);
1272 if (refellipsoid[1] < 1e-7)
1274 return refellipsoid[0];
1278 const Numeric c = 1 - refellipsoid[1] * refellipsoid[1];
1284 return b /
sqrt(
c * ct * ct + st * st);
1310 else if (gp.
fd[0] == 1)
1311 return refell2r(refellipsoid, lat_grid[gp.
idx + 1]);
1313 return gp.
fd[1] *
refell2r(refellipsoid, lat_grid[gp.
idx]) +
1344 slat * slat + cos(
DEG2RAD * lat1) * cos(
DEG2RAD * lat2) * slon * slon;
1380 x = r * cos(latrad);
1381 y = x * sin(lonrad);
1382 x = x * cos(lonrad);
1383 z = r * sin(latrad);
1412 longrid_out = longrid_in;
1413 if (longrid_in[longrid_in.
nelem() - 1] >= lon + 360.)
1414 longrid_out += -360.;
1415 else if (longrid_in[0] <= lon - 360.)
1416 longrid_out += 360.;
1435 "Latitude values < -180.0 are not supported.");
1437 "Latitude values > 180.0 are not supported.");
1451 while (lon > 360.0) {
1481 const Vector& refellipsoid ) {
1483 if (refellipsoid[1] < 1e-7)
1486 h = r - refellipsoid[0];
1495 const Numeric e2 = refellipsoid[1]*refellipsoid[1];
1497 while (
abs(B-B0)>1e-10) {
1498 N = refellipsoid[0] /
sqrt(1-e2*sin(B0)*sin(B0));
1499 h = sq / cos(B0) -
N;
1501 B0 = atan((z/sq) * 1/(1-e2*
N/(
N+h)));
1528 const Vector& refellipsoid ) {
1530 if (refellipsoid[1] < 1e-7)
1531 {
sph2cart(x, y, z, h+refellipsoid[0], lat, lon); }
1535 const Numeric e2 = refellipsoid[1]*refellipsoid[1];
1540 x = (
N + h) * coslat * cos(
DEG2RAD*lon);
1541 y = (
N + h) * coslat * sin(
DEG2RAD*lon);
1542 z = (
N*(1 - e2) + h) * sinlat;
1578 const Vector& refellipsoid ) {
1591 z = s * (h + refellipsoid[0]*
sqrt(1-refellipsoid[1]*refellipsoid[1]));
1612 dx = -sinlon*de - sinlat*coslon*dn + coslat*coslon*du;
1613 dy = coslon*de - sinlat*sinlon*dn + coslat*sinlon*du;
1614 dz = coslat* dn + sinlat* du;
1650 const Vector& refellipsoid ) {
1656 const Numeric coslat = cos(latrad);
1657 const Numeric sinlat = sin(latrad);
1658 const Numeric coslon = cos(lonrad);
1659 const Numeric sinlon = sin(lonrad);
1663 const Numeric de = -sinlon*dx + coslon*dy;
1664 const Numeric dn = -sinlat*coslon*dx - sinlat*sinlon*dy + coslat*dz;
1665 const Numeric du = coslat*coslon*dx + coslat*sinlon*dy + sinlat*dz;
base min(const Array< base > &x)
Min function.
A constant view of a Vector.
Index nelem() const noexcept
Returns the number of elements.
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR_IF(condition,...)
void distance3D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &lon1, const Numeric &r2, const Numeric &lat2, const Numeric &lon2)
distance3D
void distance2D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &r2, const Numeric &lat2)
distance2D
void cart2geodeticposlos(Numeric &h, Numeric &lat, Numeric &lon, Numeric &za, Numeric &aa, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &dx, const Numeric &dy, const Numeric &dz, const Vector &refellipsoid)
cart2geodeticposlos
void sph2cart(Numeric &x, Numeric &y, Numeric &z, const Numeric &r, const Numeric &lat, const Numeric &lon)
sph2cart
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 cart2poslos_plain(Numeric &r, Numeric &lat, Numeric &lon, Numeric &za, Numeric &aa, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &dx, const Numeric &dy, const Numeric &dz)
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
constexpr Numeric DEG2RAD
void pol2cart(Numeric &x, Numeric &z, const Numeric &r, const Numeric &lat)
pol2cart
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
void geodeticposlos2cart(Numeric &x, Numeric &y, Numeric &z, Numeric &dx, Numeric &dy, Numeric &dz, const Numeric &h, const Numeric &lat, const Numeric &lon, const Numeric &za, const Numeric &aa, const Vector &refellipsoid)
geodeticposlos2cart
void cart2geodetic(Numeric &h, Numeric &lat, Numeric &lon, const Numeric &x, const Numeric &y, const Numeric &z, const Vector &refellipsoid)
Conversion from cartesian to geodetic coordinates.
void cycle_lat_lon(Numeric &lat, Numeric &lon)
Cyclic latitude longitude coordinates.
Numeric pos2refell_r(const Index &atmosphere_dim, ConstVectorView refellipsoid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView rte_pos)
pos2refell_r
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
void line_refellipsoid_intersect(Numeric &l, const Vector &refellipsoid, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &dx, const Numeric &dy, const Numeric &dz)
geomtanpoint
constexpr Numeric RAD2DEG
Numeric sphdist(const Numeric &lat1, const Numeric &lon1, const Numeric &lat2, const Numeric &lon2)
sphdist
void latlon_at_aa(Numeric &lat2, Numeric &lon2, const Numeric &lat1, const Numeric &lon1, const Numeric &aa, const Numeric &ddeg)
latlon_at_aa
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
void lon_shiftgrid(Vector &longrid_out, ConstVectorView longrid_in, const Numeric lon)
lon_shiftgrid
void geodetic2cart(Numeric &x, Numeric &y, Numeric &z, const Numeric &h, const Numeric &lat, const Numeric &lon, const Vector &refellipsoid)
Conversion from geodetic to cartesian coordinates.
Numeric refell2d(ConstVectorView refellipsoid, ConstVectorView lat_grid, const GridPos gp)
refell2d
void cart2sph_plain(Numeric &r, Numeric &lat, Numeric &lon, const Numeric &x, const Numeric &y, const Numeric &z)
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 cart2pol(Numeric &r, Numeric &lat, const Numeric &x, const Numeric &z, const Numeric &lat0, const Numeric &za0)
cart2pol
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 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)
line_sphere_intersect
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
Numeric last(ConstVectorView x)
last
Numeric sign(const Numeric &x)
sign
void abs(Sparse &A, const Sparse &B)
Absolute value of sparse matrix elements.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
constexpr auto deg2rad(auto x) noexcept
Converts degrees to radians.
constexpr auto rad2deg(auto x) noexcept
Converts radians to degrees.
void zaaa2enu(Numeric &de, Numeric &dn, Numeric &du, const Numeric &za, const Numeric &aa)
Converts zenith and azimuth angles to ENU unit vector.
void enu2zaaa(Numeric &za, Numeric &aa, const Numeric &de, const Numeric &dn, const Numeric &du)
Converts ENU unit vector vector to zenith and azimuth.
Numeric geompath_l_at_r(const Numeric &ppc, const Numeric &r)
Calculates the length from the tangent point for the given radius.
Propagation path structure and functions.
constexpr Numeric POLELAT
Size of north and south poles.
constexpr Numeric ANGTOL
Width of zenith and nadir directions.
Numeric pow(const Rational base, Numeric exp)
Power of.
Numeric sqrt(const Rational r)
Square root.
Structure to store a grid position.
std::array< Numeric, 2 > fd