File size: 2,993 Bytes
5ab75a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function [ rsun ] = SunPos(JDut1)
% SunPos - Computes the sun-earth vector using the analytical formulation
% shown in the Astronomical Almanac (1992), producing a J2000 MEME vector
% with an accuracy of approximately 0.01 degree
% Syntax: rsun = SunPos(JDut1);
%
% =========================================================================
%
% Copyright (c)�2024�United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Input:
%    JDut1 - Julian Date (UT1)
%
% =========================================================================
%
% Output:
%    rsun - Sun-Earth vector in J2000 MEME
%
% =========================================================================
%
% References:
%   Algorithm from Fundamentals of Astrodynamics and Applications by 
%   David A. Vallado
% 
% =========================================================================
%
% Initial version: Nov�2024;� Latest update: Nov�2024
%
% ----------------- BEGIN CODE -----------------


    % AU to km conversion factor
    AU2KM = 149597870.700;

    % Computing Julian Centuries (UT1)
    Tut1 = JulianCenturies(JDut1);
    
    % Mean longitude of the sun (degs)
    lambdaMSun = 280.4606184 + 36000.77005361 .* Tut1;
    
    % ASSUMPTION: TDB approx. equals Tut1 - (SHOULD BE TT approx equals Tut1?)
    Ttdb = Tut1;
    
    % Mean anomaly of the sun
    Msun = 357.5277233 + 35999.05034 .* Ttdb;
    
    % Ecliptic longitude of the sun (the ecliptic latitude never exceeds
    % 0.000333 degrees and is usually assumed to be 0)
    lambdaEcliptic = lambdaMSun + 1.914666471 .* sind(Msun) + 0.019994643 .* sind(2 .* Msun);
    
    % Distance from the earth to the sun in AU
    r = 1.000140612 - 0.016708617 .* cosd(Msun) - 0.000139589 .* cosd(2 .* Msun);
    
    % Obliquity of the ecliptic
    eps = 23.439291 - 0.0130042 .* Ttdb;
    
    % Computing J2000 MEME vector components and converting to km
    rsun(:,1) = r .* cosd(lambdaEcliptic) .* AU2KM;
    rsun(:,2) = r .* cosd(eps) .* sind(lambdaEcliptic) .* AU2KM;
    rsun(:,3) = r .* sind(eps) .* sind(lambdaEcliptic) .* AU2KM;
    
end

% ----------------- END OF CODE ------------------
%
% Please record any changes to the software in the change history 
% shown below:
%
%---------------- CHANGE HISTORY --------------------
% Developer      |    Date     |     Description
%----------------------------------------------------
% N. Sabey       | Sept - 2014 |  Initial Development
% =========================================================================
%
% Copyright (c)�2024�United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================