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 |
|
---|
22 | function nu = nuFromM(M,ecc,tol)
|
---|
23 |
|
---|
24 | if nargin < 2 || nargin > 3
|
---|
25 | error('Incorrect number of inputs, see help nuFromM.m')
|
---|
26 | elseif nargin == 2
|
---|
27 | tol = 10^-8;
|
---|
28 | end
|
---|
29 |
|
---|
30 | E = 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]
|
---|
34 | nu = atan2((sin(E)*(1-ecc^2)^.5),(cos(E)-ecc)); |
---|
Note: See
TracBrowser
for help on using the repository browser.