source: proiecte/SolarSim/Matlab/nuFromM.m @ 152

Last change on this file since 152 was 152, checked in by (none), 14 years ago
File size: 1.3 KB
Line 
1%Kepler Orbit Anomaly true mean
2% Richard Rieber
3% September 27, 2006
4% rrieber@gmail.com
5%
6% Revision 9/25/07 - Fixed a grusome error in the default tolerance.
7%                    Changed from 10^8 radians to 10^-8 radians.  Whoops.
8%
9% function nu = nuFromM(M,ecc,tol)
10%
11% Purpose:  This function calculates the true anomaly (nu) of a position in an orbit given
12%           the mean anomaly of the position (M) and the eccentricity (ecc) of the orbit.
13%           This uses another function, calcEA.
14%           
15% Inputs:  M   - mean anomaly of position in radians
16%          ecc - eccentricity of orbit
17%          tol - A tolerance for calculating the eccentric anomaly (see help calcEA.m)
18%                Default is 10^-8 radians [OPTIONAL]
19%
20% Output:  nu  - true anomaly of position in radians
21
22function nu = nuFromM(M,ecc,tol)
23
24if nargin < 2 || nargin > 3
25    error('Incorrect number of inputs, see help nuFromM.m')
26elseif nargin == 2
27    tol = 10^-8;
28end
29
30E = CalcEA(M,ecc,tol);  %Determining eccentric anomaly from mean anomaly
31
32% Since tan(x) = sin(x)/cos(x), we can use atan2 to ensure that the angle for nu
33% is in the correct quadrant since we know both sin(nu) and cos(nu).  [see help atan2]
34nu = atan2((sin(E)*(1-ecc^2)^.5),(cos(E)-ecc));
Note: See TracBrowser for help on using the repository browser.