Code covered by the BSD License  

Highlights from
Rise and Set of the Sun, Moon and Planets

Rise and Set of the Sun, Moon and Planets

by

 

05 Dec 2012 (Updated )

Topocentric rise and set of the Sun, Moon and planets. Source ephemeris is DE421 with NOVAS routines

angles (pos)
function [ra, dec] = angles (pos)

% this function converts a vector to angular quantities

% input

%  pos = position vector, equatorial rectangular coordinates

% output

%  ra  = right ascension in hours
%  dec = declination in degrees

% Celestial Computing with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

seccon = 206264.8062470964;

xyproj = sqrt(pos(1)^2 + pos(2)^2);

r = atan2(pos(2), pos(1));

d = atan2(pos(3), xyproj);

ra = r * seccon / 54000;

dec = d * seccon / 3600;

if (ra < 0)
   ra = ra + 24;
end

Contact us