Code covered by the BSD License  

Highlights from
A MATLAB Script for Predicting Transits of Mercury and Venus

A MATLAB Script for Predicting Transits of Mercury and Venus

by

 

07 Dec 2012 (Updated )

Local circumstances of solar transits of the planets Mercury and Venus.

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