source: trunk/MagicSoft/slalib/ampqk.c@ 18808

Last change on this file since 18808 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaAmpqk ( double ra, double da, double amprms[21],
4 double *rm, double *dm )
5/*
6** - - - - - - - - -
7** s l a A m p q k
8** - - - - - - - - -
9**
10** Convert star RA,Dec from geocentric apparent to mean place.
11**
12** The mean coordinate system is the post IAU 1976 system,
13** loosely called FK5.
14**
15** Use of this routine is appropriate when efficiency is important
16** and where many star positions are all to be transformed for
17** one epoch and equinox. The star-independent parameters can be
18** obtained by calling the slaMappa routine.
19**
20** Given:
21** ra double apparent RA (radians)
22** da double apparent Dec (radians)
23**
24** amprms double[21] star-independent mean-to-apparent parameters:
25**
26** (0) time interval for proper motion (Julian years)
27** (1-3) barycentric position of the Earth (AU)
28** (4-6) heliocentric direction of the Earth (unit vector)
29** (7) (grav rad Sun)*2/(Sun-Earth distance)
30** (8-10) abv: barycentric Earth velocity in units of c
31** (11) sqrt(1-v*v) where v=modulus(abv)
32** (12-20) precession/nutation (3,3) matrix
33**
34** Returned:
35** *rm double mean RA (radians)
36** *dm double mean Dec (radians)
37**
38** References:
39** 1984 Astronomical Almanac, pp B39-B41.
40** (also Lederle & Schwan, Astron. Astrophys. 134, 1-6, 1984)
41**
42** Notes:
43**
44** 1) The accuracy is limited by the routine slaEvp, called
45** by slaMappa, which computes the Earth position and
46** velocity using the methods of Stumpff. The maximum
47** error is about 0.3 milliarcsecond.
48**
49** 2) Iterative techniques are used for the aberration and
50** light deflection corrections so that the routines
51** slaAmp (or slaAmpqk) and slaMap (or slaMapqk) are
52** accurate inverses; even at the edge of the Sun's disc
53** the discrepancy is only about 1 nanoarcsecond.
54**
55** Called: slaDcs2c, slaDimxv, slaDvdv, slaDvn, slaDcc2s,
56** slaDranrm
57**
58** Last revision: 31 October 1993
59**
60** Copyright P.T.Wallace. All rights reserved.
61*/
62{
63 double gr2e; /* (grav rad Sun)*2/(Sun-Earth distance) */
64 double ab1; /* sqrt(1-v*v) where v=modulus of Earth vel */
65 double ehn[3]; /* Earth position wrt Sun (unit vector, FK5) */
66 double abv[3]; /* Earth velocity wrt SSB (c, FK5) */
67 double p[3], p1[3], p2[3], p3[3]; /* work vectors */
68 double ab1p1, p1dv, p1dvp1, w, pde, pdep1;
69 int i, j;
70
71/* Unpack some of the parameters */
72 gr2e = amprms[7];
73 ab1 = amprms[11];
74 for ( i = 0; i < 3; i++ ) {
75 ehn[i] = amprms[i + 4];
76 abv[i] = amprms[i + 8];
77 }
78
79/* Apparent RA,Dec to Cartesian */
80 slaDcs2c ( ra, da, p3 );
81
82/* Precession and nutation */
83 slaDimxv ( (double(*)[3]) &amprms[12], p3, p2 );
84
85/* Aberration */
86 ab1p1 = ab1 + 1.0;
87 for ( i = 0; i < 3; i++ ) {
88 p1[i] = p2[i];
89 }
90 for ( j = 0; j < 2; j++ ) {
91 p1dv = slaDvdv ( p1, abv );
92 p1dvp1 = 1.0 + p1dv;
93 w = 1.0 + p1dv / ab1p1;
94 for ( i = 0; i < 3; i++ ) {
95 p1[i] = ( p1dvp1 * p2[i] - w * abv[i] ) / ab1;
96 }
97 slaDvn ( p1, p3, &w );
98 for ( i = 0; i < 3; i++ ) {
99 p1[i] = p3[i];
100 }
101 }
102
103/* Light deflection */
104 for ( i = 0; i < 3; i++ ) {
105 p[i] = p1[i];
106 }
107 for ( j = 0; j < 5; j++ ) {
108 pde = slaDvdv ( p, ehn );
109 pdep1 = 1.0 + pde;
110 w = pdep1 - gr2e * pde;
111 for ( i = 0; i < 3; i++ ) {
112 p[i] = ( pdep1 * p1[i] - gr2e * ehn[i] ) / w;
113 }
114 slaDvn ( p, p2, &w );
115 for ( i = 0; i < 3; i++ ) {
116 p[i] = p2[i];
117 }
118 }
119
120/* Mean RA,Dec */
121 slaDcc2s ( p, rm, dm );
122 *rm = slaDranrm ( *rm );
123}
Note: See TracBrowser for help on using the repository browser.