Home > atmlab > geodetic > ellipsoidradii.m

ellipsoidradii

PURPOSE ^

ELLIPSOIDRADII Geocentric radius of a reference ellipsoid

SYNOPSIS ^

function r = ellipsoidradii(ellipsoid,lat)

DESCRIPTION ^

 ELLIPSOIDRADII   Geocentric radius of a reference ellipsoid

    Gives the distance from the Earth's centre and the reference ellipsoid
    as a function of geoCENTRIC latitude. 

    To obtain the radii for geoDETIC latitude, use *ellipsoidradii2*.

 FORMAT   r = ellipsoidradii( ellipsoid, lat_gd )
    
 OUT   r          Radii. See above.
 IN    ellipsoid  Model ellipsoid as returned by *ellipsoidmodels*.
       lat_gd     Geocentric latitudes.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

ellipsoidradii.m

SOURCE CODE ^

0001 % ELLIPSOIDRADII   Geocentric radius of a reference ellipsoid
0002 %
0003 %    Gives the distance from the Earth's centre and the reference ellipsoid
0004 %    as a function of geoCENTRIC latitude.
0005 %
0006 %    To obtain the radii for geoDETIC latitude, use *ellipsoidradii2*.
0007 %
0008 % FORMAT   r = ellipsoidradii( ellipsoid, lat_gd )
0009 %
0010 % OUT   r          Radii. See above.
0011 % IN    ellipsoid  Model ellipsoid as returned by *ellipsoidmodels*.
0012 %       lat_gd     Geocentric latitudes.
0013 
0014 % 2012-02-06   Created by Patrick Eriksson.
0015 
0016 
0017 function r = ellipsoidradii(ellipsoid,lat)
0018 
0019 % Check input                                                          %&%
0020 rqre_datatype( ellipsoid, @isvector );                                 %&%
0021 if length(ellipsoid) ~= 2                                              %&%
0022  error( 'The argument *ellipsoid* must be a vector of length 2' );     %&%
0023 end                                                                    %&%
0024 rqre_in_range( ellipsoid(2), 0, 1, 'element 2 of ellipsoid' );         %&%
0025 rqre_datatype( lat, @isnumeric );                                      %&%
0026 
0027 
0028 % Spherical case (all radii the same)
0029 if ellipsoid(2) == 0
0030   %
0031   r = repmat( ellipsoid(1), size(lat) );
0032 
0033 %
0034 else
0035   % A re-arranged form of the follwing expression is used:
0036   % r = ab/sqrt(b^2*cos(lat)^2+a^2*sin(lat)^2)
0037   %
0038   c = 1 - ellipsoid(2)^2;
0039   b = ellipsoid(1) * sqrt( c );
0040   %
0041   r = b ./ sqrt( c*cosd(lat).^2 + sind(lat).^2 );
0042 
0043 end

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