Home > atmlab > geodetic > geodetic2cart.m

geodetic2cart

PURPOSE ^

GEODETIC2CART converts from geodetic to a geocentric cartesian coordinates

SYNOPSIS ^

function [x, y, z] = geodetic2cart(h,lat,lon,ellipsoid)

DESCRIPTION ^

 GEODETIC2CART   converts from geodetic to a geocentric cartesian coordinates

   The geodetic coordinates refer to the reference ellipsoid 
   specified by input ellipsoid. 

   See CART2GEOCENTRIC for a defintion of the geocentric coordinate system.

 FORMAT [x, y, z] = geodetic2cart(h,lat,lon[,ellipsoid])
 
 OUT    x    Coordinate in x dimension
        y    Coordinate in y dimension
        z    Coordinate in z dimension

 IN     h         Geodetic height (height above the reference ellipsoid)
        lat       Geodetic latitude
        lon       Geodetic longitude
 OPT    ellipsoid a vector with the form [semimajor axis; eccentricity]
                  specifying the ellipsoid. Default is WGS84.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

geodetic2cart.m

SOURCE CODE ^

0001 % GEODETIC2CART   converts from geodetic to a geocentric cartesian coordinates
0002 %
0003 %   The geodetic coordinates refer to the reference ellipsoid
0004 %   specified by input ellipsoid.
0005 %
0006 %   See CART2GEOCENTRIC for a defintion of the geocentric coordinate system.
0007 %
0008 % FORMAT [x, y, z] = geodetic2cart(h,lat,lon[,ellipsoid])
0009 %
0010 % OUT    x    Coordinate in x dimension
0011 %        y    Coordinate in y dimension
0012 %        z    Coordinate in z dimension
0013 %
0014 % IN     h         Geodetic height (height above the reference ellipsoid)
0015 %        lat       Geodetic latitude
0016 %        lon       Geodetic longitude
0017 % OPT    ellipsoid a vector with the form [semimajor axis; eccentricity]
0018 %                  specifying the ellipsoid. Default is WGS84.
0019 
0020 % History: created by Bengt Rydberg 2011-10-31
0021 
0022 function [x, y, z] = geodetic2cart(h,lat,lon,ellipsoid)
0023 
0024 if nargin<4
0025   ellipsoid = ellipsoidmodels( 'WGS84' );
0026 end 
0027 
0028 a      = ellipsoid(1);
0029 e2     = ellipsoid(2) ^ 2;
0030 sinphi = sind( lat );
0031 cosphi = cosd( lat );
0032 N      = a ./ sqrt(1 - e2 * sinphi.^2);
0033 x      = (N + h) .* cosphi .* cosd(lon);
0034 y      = (N + h) .* cosphi .* sind(lon);
0035 z      = (N*(1 - e2) + h) .* sinphi;
0036

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