source: trunk/MagicSoft/slalib/altaz.c@ 13250

Last change on this file since 13250 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaAltaz ( double ha, double dec, double phi,
4 double *az, double *azd, double *azdd,
5 double *el, double *eld, double *eldd,
6 double *pa, double *pad, double *padd )
7/*
8** - - - - - - - - -
9** s l a A l t a z
10** - - - - - - - - -
11**
12** Positions, velocities and accelerations for an altazimuth
13** telescope mount.
14**
15** (double precision)
16**
17** Given:
18** ha double hour angle
19** dec double declination
20** phi double latitude
21**
22** Returned:
23** *az double azimuth
24** *azd double " velocity
25** *azdd double " acceleration
26** *el double elevation
27** *eld double " velocity
28** *eldd double " acceleration
29** *pa double parallactic angle
30** *pad double " " velocity
31** *padd double " " acceleration
32**
33** Notes:
34**
35** 1) Natural units are used throughout. HA, DEC, PHI, AZ, EL
36** and ZD are in radians. The velocities and accelerations
37** assume constant declination and constant rate of change of
38** hour angle (as for tracking a star); the units of AZD, ELD
39** and PAD are radians per radian of HA, while the units of AZDD,
40** ELDD and PADD are radians per radian of HA squared. To
41** convert into practical degree- and second-based units:
42**
43** angles * 360/2pi -> degrees
44** velocities * (2pi/86400)*(360/2pi) -> degree/sec
45** accelerations * ((2pi/86400)**2)*(360/2pi) -> degree/sec/sec
46**
47** Note that the seconds here are sidereal rather than SI. One
48** sidereal second is about 0.99727 SI seconds.
49**
50** The velocity and acceleration factors assume the sidereal
51** tracking case. Their respective numerical values are (exactly)
52** 1/240 and (approximately) 1/3300236.9.
53**
54** 2) Azimuth is returned in the range 0-2pi; north is zero,
55** and east is +pi/2. Elevation and parallactic angle are
56** returned in the range +/-pi/2. Position angle is +ve
57** for a star west of the meridian and is the angle NP-star-zenith.
58**
59** 3) The latitude is geodetic as opposed to geocentric. The
60** hour angle and declination are topocentric. Refraction and
61** deficiencies in the telescope mounting are ignored. The
62** purpose of the routine is to give the general form of the
63** quantities. The details of a real telescope could profoundly
64** change the results, especially close to the zenith.
65**
66** 4) No range checking of arguments is carried out.
67**
68** 5) In applications which involve many such calculations, rather
69** than calling the present routine it will be more efficient to
70** use inline code, having previously computed fixed terms such
71** as sine and cosine of latitude, and (for tracking a star)
72** sine and cosine of declination.
73**
74** Defined in slamac.h: DPI, D2PI
75**
76** Last revision: 14 March 1997
77**
78** Copyright P.T.Wallace. All rights reserved.
79*/
80
81#define TINY 1e-30 /* Zone of avoidance around zenith/nadir */
82
83{
84 double sh, ch, sd, cd, sp, cp, chcd, sdcp, x, y, z, rsq, r, a, e,
85 c, s, q, qd, ad, ed, edr, add, edd, qdd;
86
87/* Useful functions */
88 sh = sin ( ha );
89 ch = cos ( ha );
90 sd = sin ( dec );
91 cd = cos ( dec );
92 sp = sin ( phi );
93 cp = cos ( phi );
94 chcd = ch * cd;
95 sdcp = sd * cp;
96 x = - chcd * sp + sdcp;
97 y = - sh * cd;
98 z = chcd * cp + sd * sp;
99 rsq = x * x + y * y;
100 r = sqrt ( rsq );
101
102/* Azimuth and elevation */
103 if ( rsq == 0.0 ) {
104 a = 0.0;
105 } else {
106 a = atan2 ( y, x );
107 }
108 if ( a < 0.0 ) a += D2PI;
109 e = atan2 ( z, r );
110
111/* Parallactic angle */
112 c = cd * sp - ch * sdcp;
113 s = sh * cp;
114 if ( c * c + s * s > 0.0 ) {
115 q = atan2 ( s, c );
116 } else {
117 q = DPI - ha;
118 }
119
120/* Velocities and accelerations (clamped at zenith/nadir) */
121 if ( rsq < TINY ) {
122 rsq = TINY;
123 r = sqrt ( rsq );
124 }
125 qd = - x * cp / rsq;
126 ad = sp + z * qd;
127 ed = cp * y / r;
128 edr = ed / r;
129 add = edr * ( z * sp + ( 2.0 - rsq ) * qd );
130 edd = - r * qd * ad;
131 qdd = edr * ( sp + 2.0 * z * qd );
132
133/* Results */
134 *az = a;
135 *azd = ad;
136 *azdd = add;
137 *el = e;
138 *eld = ed;
139 *eldd = edd;
140 *pa = q;
141 *pad = qd;
142 *padd = qdd;
143}
Note: See TracBrowser for help on using the repository browser.