Home > atmlab > geoplots > atmplot_sph2cart.m

atmplot_sph2cart

PURPOSE ^

ATMPLOT_SPH2CART Plots a line given in spherical coordinates.

SYNOPSIS ^

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

DESCRIPTION ^

 ATMPLOT_SPH2CART   Plots a line given in spherical coordinates.

     The given line/points are plotted to current axes. No hold commando is 
     applied. Plot symbol, and additional plot arguments, can be selected
     by adding arguments after *lat*.

     Plotting is only performed if there are no output arguments. With
     output arguments, the function can be used for conversion inside
     other plotting functions.

     A scalar as input for either radius, latitude or longitude means that 
     that value shall be applied for all points. If radii, latitudes and
     longitudes are given as vectors, all vectors must have the same size.

     The data are plotted in such way that the observer is placed a bit
     above the Equator and a bit east from the lon=0.

 FORMAT   [x,y,z] = atmplot_sph2cart( r, lat, lon, [, varargin ] )
        
 OUT   x          The x-coordinate for the line to draw.
       y          The y-coordinate for the line to draw.
       z          The z-coordinate for the line to draw.
 IN    r          A single radius or a vector of radii.
       lat        A single latitude, or a vector of latitides.
       lon        A single longitudes, or a vector of longitudes.
 OPT   varargin   Arguments that are passed to the *plot* commando.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

atmplot_sph2cart.m

SOURCE CODE ^

0001 % ATMPLOT_SPH2CART   Plots a line given in spherical coordinates.
0002 %
0003 %     The given line/points are plotted to current axes. No hold commando is
0004 %     applied. Plot symbol, and additional plot arguments, can be selected
0005 %     by adding arguments after *lat*.
0006 %
0007 %     Plotting is only performed if there are no output arguments. With
0008 %     output arguments, the function can be used for conversion inside
0009 %     other plotting functions.
0010 %
0011 %     A scalar as input for either radius, latitude or longitude means that
0012 %     that value shall be applied for all points. If radii, latitudes and
0013 %     longitudes are given as vectors, all vectors must have the same size.
0014 %
0015 %     The data are plotted in such way that the observer is placed a bit
0016 %     above the Equator and a bit east from the lon=0.
0017 %
0018 % FORMAT   [x,y,z] = atmplot_sph2cart( r, lat, lon, [, varargin ] )
0019 %
0020 % OUT   x          The x-coordinate for the line to draw.
0021 %       y          The y-coordinate for the line to draw.
0022 %       z          The z-coordinate for the line to draw.
0023 % IN    r          A single radius or a vector of radii.
0024 %       lat        A single latitude, or a vector of latitides.
0025 %       lon        A single longitudes, or a vector of longitudes.
0026 % OPT   varargin   Arguments that are passed to the *plot* commando.
0027 
0028 % 2002-12-22   Created by Patrick Eriksson.
0029 
0030 
0031 function [x,y,z] = atmplot_sph2cart( r, lat, lon, varargin )
0032 
0033 
0034 %= Input
0035 %
0036 rqre_nargin( 3, nargin );
0037 
0038 
0039 DEG2RAD = constants( 'DEG2RAD' );
0040 
0041 
0042 [x,z,y] = sph2cart( DEG2RAD * lon, DEG2RAD * lat, r );
0043 
0044 if ~nargout
0045   
0046   plot3( z, x, y, varargin{:} );
0047   set( gca, 'Ydir', 'rev' );
0048   view([37 30]);
0049 
0050 end
0051

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