File: lonlat.c

package info (click to toggle)
astronomical-almanac 5.6-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,104 kB
  • ctags: 414
  • sloc: ansic: 14,727; makefile: 170; xml: 109; sh: 1
file content (58 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (5)
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

/* Display ecliptic longitude and latitude for
 * equinox of date.  Input is equatorial rectangular
 * coordinates for equinox J2000.
 */

#include "kep.h"

int lonlat( pp, J, polar, ofdate )
double pp[], J, polar[];
int ofdate; /* 1 means precess from J2000 to date J.  */
{
double s[3], x, y, z, yy, zz, r;
int i;

/* Make local copy of position vector
 * and calculate radius.
 */
r = 0.0;
for( i=0; i<3; i++ )
	{
	x = pp[i];
	s[i] = x;
	r += x * x;
	}
r = sqrt(r);

/* Precess to equinox of date J
 */
if( ofdate )
	precess( s, J, -1 );

/* Convert from equatorial to ecliptic coordinates
 */
epsiln(J);
yy = s[1];
zz = s[2];
x  = s[0];
y  =  coseps * yy  +  sineps * zz;
z  = -sineps * yy  +  coseps * zz;

yy = zatan2( x, y );
zz = asin( z/r );

polar[0] = yy;
polar[1] = zz;
polar[2] = r;

if( prtflg == 0 )
	return(0);

printf( "ecliptic long" );
dms( yy );
printf( " lat" );
dms( zz );
printf( " rad %.6E\n", r );
return(0);
}