90 r = sqrt( x*x + z*z );
94 if( absza < ANGTOL || absza > 180-
ANGTOL )
101 lat = lat - 360.0 *
Numeric( round( ( lat - lat0 ) / 360.0 ) );
137 r = sqrt( x*x + z*z );
141 if( absza < ANGTOL || absza > 180-
ANGTOL )
152 const Numeric coslat = cos( latrad );
153 const Numeric sinlat = sin( latrad );
154 const Numeric dr = coslat*dx + sinlat*dz;
164 za =
RAD2DEG * asin( ppc / r );
177 { za = -180.0 + za; }
208 assert(
abs( lat2 - lat1 ) <= 180 );
216 l = sqrt( dx*dx + dz*dz );
313 const Numeric a = dx*dx + dz*dz;
314 const Numeric b = 2*( dx*(xl-xc) + dz*(zl-zc) );
315 const Numeric c = xc*xc + zc*zc + xl*xl + zl*zl - 2*(xc*xl + zc*zl) - r*r;
322 const Numeric e = sqrt( d ) / a2;
333 { l =
min(l1,l2); assert( l>=0 ); }
366 x = r * cos( latrad );
367 z = r * sin( latrad );
397 assert( za >= -180 && za<=180 );
402 const Numeric coslat = cos( latrad );
403 const Numeric sinlat = sin( latrad );
404 const Numeric cosza = cos( zarad );
405 const Numeric sinza = sin( zarad );
414 dx = coslat * dr - sinlat * dlat;
415 dz = sinlat * dr + coslat * dlat;
477 r = sqrt( x*x + y*y + z*z );
480 if( za0 < ANGTOL || za0 > 180-
ANGTOL )
493 bool ns_case =
false;
494 bool lon_flip =
false;
503 if(
abs(lon-lon0) < 1 )
509 { lon = lon0 - 180; }
511 { lon = lon0 + 180; }
517 const Numeric coslat = cos( latrad );
518 const Numeric sinlat = sin( latrad );
519 const Numeric coslon = cos( lonrad );
520 const Numeric sinlon = sin( lonrad );
521 const Numeric dr = coslat*coslon*dx + coslat*sinlon*dy + sinlat*dz;
525 za =
RAD2DEG * asin( ppc / r );
532 assert(
abs( za -
RAD2DEG*acos(dr) ) < 1e-4 );
537 { aa =
RAD2DEG * atan2( dy, dx ); }
555 const Numeric dlat = -sinlat*coslon/r*dx - sinlat*sinlon/r*dy +
557 const Numeric dlon = -sinlon/coslat/r*dx + coslon/coslat/r*dy;
608 r = sqrt( x*x + y*y + z*z );
611 if( za0 < ANGTOL || za0 > 180-
ANGTOL )
628 if(
abs(lon-lon0) < 1 )
633 { lon = lon0 - 180; }
635 { lon = lon0 + 180; }
667 Numeric x1, y1, z1, x2, y2, z2;
668 sph2cart( x1, y1, z1, r1, lat1, lon1 );
669 sph2cart( x2, y2, z2, r2, lat2, lon2 );
674 l = sqrt( dx*dx + dy*dy + dz*dz );
716 poslos2cart( x, y, z, dx, dy, dz, r, lat, lon, za, aa );
718 l_tan = sqrt( r*r - ppc*ppc );
720 cart2sph( r_tan, lat_tan, lon_tan, x+dx*l_tan, y+dy*l_tan, z+dz*l_tan,
880 const Numeric a = dx*dx + dy*dy + dz*dz;
881 const Numeric b = 2*( dx*(xl-xc) + dy*(yl-yc) + dz*(zl-zc) );
882 const Numeric c = xc*xc + yc*yc + zc*zc +
883 xl*xl + yl*yl + zl*zl - 2*(xc*xl + yc*yl + zc*zl) - r*r;
890 const Numeric e = sqrt( d ) / a2;
901 { l =
min(l1,l2); assert( l>=0 ); }
940 const Numeric cosdang= cos( dang );
941 const Numeric sindang= sin( dang );
943 const Numeric coslat = cos( latrad );
944 const Numeric sinlat = sin( latrad );
947 lat2 = sinlat*cosdang + coslat*sindang*cos(aarad);
948 lon2 = lon1 +
RAD2DEG*( atan2( sin(aarad)*sindang*coslat,
949 cosdang-sinlat*lat2 ) );
990 Numeric dx = x2-x1, dy = y2-y1, dz = z2-z1;
991 const Numeric ldxyz = sqrt( dx*dx + dy*dy + dz*dz );
999 const Numeric coslat = cos( latrad );
1000 const Numeric sinlat = sin( latrad );
1001 const Numeric coslon = cos( lonrad );
1002 const Numeric sinlon = sin( lonrad );
1004 const Numeric dr = coslat*coslon*dx + coslat*sinlon*dy + sinlat*dz;
1005 const Numeric dlat = -sinlat*coslon/r1*dx - sinlat*sinlon/r1*dy +
1007 const Numeric dlon = -sinlon/coslat/r1*dx + coslon/coslat/r1*dy;
1063 assert(
abs( lat ) <= 90 );
1064 assert(
abs( lon ) <= 360 );
1065 assert( za >= 0 && za<=180 );
1080 dy = dx * sin(
DEG2RAD * aa );
1081 dx = dx * cos(
DEG2RAD * aa );
1091 const Numeric coslat = cos( latrad );
1092 const Numeric sinlat = sin( latrad );
1093 const Numeric coslon = cos( lonrad );
1094 const Numeric sinlon = sin( lonrad );
1095 const Numeric cosza = cos( zarad );
1096 const Numeric sinza = sin( zarad );
1097 const Numeric cosaa = cos( aarad );
1098 const Numeric sinaa = sin( aarad );
1107 const Numeric dlat = sinza * cosaa;
1108 const Numeric dlon = sinza * sinaa / coslat;
1110 dx = coslat*coslon * dr - sinlat*coslon * dlat - coslat*sinlon * dlon;
1111 dz = sinlat * dr + coslat * dlat;
1112 dy = coslat*sinlon * dr - sinlat*sinlon * dlat + coslat*coslon * dlon;
1140 const Index& atmosphere_dim,
1146 if( atmosphere_dim == 1 )
1147 {
return refellipsoid[0]; }
1150 assert( rte_pos.
nelem() > 1 );
1154 if( rte_pos[1] < lat_grid[0] || rte_pos[1] >
last(lat_grid) )
1156 else if( atmosphere_dim == 3 )
1158 assert( rte_pos.
nelem() == 3 );
1159 if( rte_pos[2] < lon_grid[0] || rte_pos[2] >
last(lon_grid) )
1166 gridpos( gp_lat, lat_grid, rte_pos[1] );
1167 return refell2d( refellipsoid, lat_grid, gp_lat );
1170 {
return refell2r( refellipsoid, rte_pos[1] ); }
1203 assert( refellipsoid.
nelem() == 2 );
1204 assert( refellipsoid[0] > 0 );
1205 assert( refellipsoid[1] >= 0 );
1206 assert( refellipsoid[1] < 1 );
1208 if( refellipsoid[1] < 1e-7 )
1210 return refellipsoid[0];
1215 const Numeric c = 1 - refellipsoid[1]*refellipsoid[1];
1216 const Numeric b = refellipsoid[0] * sqrt( c );
1221 return b / sqrt( c*ct*ct + st*st );
1251 else if( gp.
fd[0] == 1 )
1287 return RAD2DEG * 2 * atan2( sqrt(a), sqrt(1-a) );
1321 assert(
abs( lat ) <= 90 );
1322 assert(
abs( lon ) <= 360 );
1327 x = r * cos( latrad );
1328 y = x * sin( lonrad );
1329 x = x * cos( lonrad );
1330 z = r * sin( latrad );
1363 longrid_out = longrid_in;
1364 if (longrid_in[longrid_in.
nelem()-1] >= lon+360.)
1365 longrid_out += -360.;
1366 else if (longrid_in[0] <= lon-360.)
1367 longrid_out += 360.;
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
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.
void lon_shiftgrid(Vector &longrid_out, ConstVectorView longrid_in, const Numeric lon)
lon_shiftgrid
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
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 pos2refell_r(const Index &atmosphere_dim, ConstVectorView refellipsoid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView rte_pos)
pos2refell_r