Home > atmlab > geodetic > geocentricposlos2cart.m

geocentricposlos2cart

PURPOSE ^

GEOCENTRICPOSLOS2CART converts from spherical POS/LOS to cartesian coordinates

SYNOPSIS ^

function [x,y,z,dx,dy,dz]=geocentricposlos2cart(r,lat,lon,za,aa)

DESCRIPTION ^

 GEOCENTRICPOSLOS2CART converts from spherical POS/LOS to cartesian coordinates

 See Contents for a defintion of the geocentric coordinate system. 
 The local LOS angles are defined following the EAST-NORTH-UP system:
         za    aa
         90    0   points towards north
         90    90  points towards east
         0     aa  points up
 
 FORMAT  [x,y,z,dx,dy,dz]=geocentricposlos2cart(r,lat,lon,za,az) 

 OUT     x    Coordinate in x dimension
         y    Coordinate in y dimension
         z    Coordinate in z dimension
         dx   LOS component in x dimension
         dy   LOS component in y dimension
         dz   LOS 

 IN      r    Radius 
         lat  Latitude
         lon  Longitude
         za   zenith angle
         aa   azimuth angle

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

geocentricposlos2cart.m

SOURCE CODE ^

0001 % GEOCENTRICPOSLOS2CART converts from spherical POS/LOS to cartesian coordinates
0002 %
0003 % See Contents for a defintion of the geocentric coordinate system.
0004 % The local LOS angles are defined following the EAST-NORTH-UP system:
0005 %         za    aa
0006 %         90    0   points towards north
0007 %         90    90  points towards east
0008 %         0     aa  points up
0009 %
0010 % FORMAT  [x,y,z,dx,dy,dz]=geocentricposlos2cart(r,lat,lon,za,az)
0011 %
0012 % OUT     x    Coordinate in x dimension
0013 %         y    Coordinate in y dimension
0014 %         z    Coordinate in z dimension
0015 %         dx   LOS component in x dimension
0016 %         dy   LOS component in y dimension
0017 %         dz   LOS
0018 %
0019 % IN      r    Radius
0020 %         lat  Latitude
0021 %         lon  Longitude
0022 %         za   zenith angle
0023 %         aa   azimuth angle
0024 
0025 % History: created by Bengt Rydberg 2011-10-31
0026 function [x,y,z,dx,dy,dz]=geocentricposlos2cart(r,lat,lon,za,aa)
0027 
0028 if any( r == 0 )
0029   error( 'This function is not handling the case of r = 0.' );  
0030 end
0031 rqre_in_range( lat, -90, 90 )
0032 rqre_in_range( lon, -360, 360 )
0033 rqre_in_range( za, 0, 180 )
0034 
0035 
0036 deg2rad = constants( 'DEG2RAD' );
0037 
0038 
0039 % For lat = +- 90 the azimuth angle gives the longitude along which the
0040 % LOS goes
0041 %
0042 if abs( lat ) > 90-1e-8
0043   %
0044   s = sign( lat );
0045   %
0046   x = 0;
0047   y = 0;
0048   z = s .* r;
0049   %
0050   dz = s .* cos( deg2rad .* za );
0051   dx = sin( deg2rad .* za );
0052   dy = dx .* sin( deg2rad .* aa );
0053   dx = dx .* cos( deg2rad .* aa );
0054 
0055 else
0056   %
0057   latrad = deg2rad * lat;
0058   lonrad = deg2rad * lon;
0059   zarad  = deg2rad * za;
0060   aarad  = deg2rad * aa;
0061   clear lat lon za aa;
0062   %
0063   coslat = cos( latrad );
0064   sinlat = sin( latrad );
0065   coslon = cos( lonrad );
0066   sinlon = sin( lonrad );
0067   cosza  = cos( zarad );
0068   sinza  = sin( zarad );
0069   cosaa  = cos( aarad );
0070   sinaa  = sin( aarad );
0071   clear latrad lonrad zarad aarad
0072   %
0073   % As in geocentric2cart, but uses local variables
0074   x = r .* coslat; 
0075   y = x .* sinlon;
0076   x = x .* coslon;
0077   z = r .* sinlat;  
0078   %
0079   dr     = cosza;
0080   clear cosza;
0081   dlat   = sinza .* cosaa;            % r-terms cancel out below
0082   clear cosaa;
0083   dlon   = sinza .* sinaa ./ coslat;
0084   clear sinza sinaa;
0085   %
0086   dx = coslat.*coslon.*dr - sinlat.*coslon.*dlat - coslat.*sinlon.*dlon;
0087   dz =         sinlat.*dr +         coslat.*dlat;
0088   dy = coslat.*sinlon.*dr - sinlat.*sinlon.*dlat + coslat.*coslon.*dlon;
0089 end
0090 
0091 
0092 
0093 
0094 
0095

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005