source: trunk/MagicSoft/slalib/ds2tp.c@ 2619

Last change on this file since 2619 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaDs2tp ( double ra, double dec, double raz, double decz,
4 double *xi, double *eta, int *j )
5/*
6** - - - - - - - - -
7** s l a D s 2 t p
8** - - - - - - - - -
9**
10** Projection of spherical coordinates onto tangent plane
11** ('gnomonic' projection - 'standard coordinates').
12**
13** (double precision)
14**
15** Given:
16** ra,dec double spherical coordinates of point to be projected
17** raz,decz double spherical coordinates of tangent point
18**
19** Returned:
20** *xi,*eta double rectangular coordinates on tangent plane
21** *j int status: 0 = OK, star on tangent plane
22** 1 = error, star too far from axis
23** 2 = error, antistar on tangent plane
24** 3 = error, antistar too far from axis
25**
26** Last revision: 18 July 1996
27**
28** Copyright P.T.Wallace. All rights reserved.
29*/
30#define TINY 1e-6
31{
32 double sdecz, sdec, cdecz, cdec, radif, sradif, cradif, denom;
33
34
35/* Trig functions */
36 sdecz = sin ( decz );
37 sdec = sin ( dec );
38 cdecz = cos ( decz );
39 cdec = cos ( dec );
40 radif = ra - raz;
41 sradif = sin ( radif );
42 cradif = cos ( radif );
43
44/* Reciprocal of star vector length to tangent plane */
45 denom = sdec * sdecz + cdec * cdecz * cradif;
46
47/* Handle vectors too far from axis */
48 if ( denom > TINY ) {
49 *j = 0;
50 } else if ( denom >= 0.0 ) {
51 *j = 1;
52 denom = TINY;
53 } else if ( denom > -TINY ) {
54 *j = 2;
55 denom = -TINY;
56 } else {
57 *j = 3;
58 }
59
60/* Compute tangent plane coordinates (even in dubious cases) */
61 *xi = cdec * sradif / denom;
62 *eta = ( sdec * cdecz - cdec * sdecz * cradif ) / denom;
63}
Note: See TracBrowser for help on using the repository browser.