Home > atmlab > geodetic > geocentric2cart.m

geocentric2cart

PURPOSE ^

GEOCENTRIC2CART converts from spherical coordinate to a cartesian position

SYNOPSIS ^

function [x,y,z]=geocentric2cart(r,lat,lon)

DESCRIPTION ^

 GEOCENTRIC2CART   converts from spherical coordinate to a cartesian position

 See Contents.m for a defintion of the geocentric coordinate system
 
 FORMAT  [x,y,z]=geocentric2cart(r,lat,lon) 

 OUT     x    Coordinate in x dimension
         y    Coordinate in y dimension
         z    Coordinate in z dimension

 IN      r    Radius 
         lat  Latitude
         lon  Longitude

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

geocentric2cart.m

SOURCE CODE ^

0001 % GEOCENTRIC2CART   converts from spherical coordinate to a cartesian position
0002 %
0003 % See Contents.m for a defintion of the geocentric coordinate system
0004 %
0005 % FORMAT  [x,y,z]=geocentric2cart(r,lat,lon)
0006 %
0007 % OUT     x    Coordinate in x dimension
0008 %         y    Coordinate in y dimension
0009 %         z    Coordinate in z dimension
0010 %
0011 % IN      r    Radius
0012 %         lat  Latitude
0013 %         lon  Longitude
0014 
0015 % History: created by Bengt Rydberg 2011-10-31
0016 
0017 function [x,y,z]=geocentric2cart(r,lat,lon)
0018 
0019 if any( r == 0 )
0020   error( 'This set of functions are not handling the case of r = 0.' );  
0021 end
0022 
0023 deg2rad = constants( 'DEG2RAD' );
0024 
0025 latrad = deg2rad * lat;
0026 lonrad = deg2rad * lon;
0027 
0028 x = r .* cos( latrad );   % Common term for x and y
0029 y = x .* sin( lonrad );
0030 x = x .* cos( lonrad );
0031 z = r .* sin( latrad );
0032 
0033

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