source: trunk/MagicSoft/slalib/dtps2c.c@ 7468

Last change on this file since 7468 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaDtps2c ( double xi, double eta, double ra, double dec,
4 double *raz1, double *decz1,
5 double *raz2, double *decz2, int *n )
6/*
7** - - - - - - - - - -
8** s l a D t p s 2 c
9** - - - - - - - - - -
10**
11** From the tangent plane coordinates of a star of known RA,Dec,
12** determine the RA,Dec of the tangent point.
13**
14** (double precision)
15**
16** Given:
17** xi,eta double tangent plane rectangular coordinates
18** ra,dec double spherical coordinates
19**
20** Returned:
21** *raz1,*decz1 double spherical coordinates of TP, solution 1
22** *raz2,*decz2 double spherical coordinates of TP, solution 2
23** *n int number of solutions:
24** 0 = no solutions returned (note 2)
25** 1 = only the first solution is useful (note 3)
26** 2 = both solutions are useful (note 3)
27**
28**
29** Notes:
30**
31** 1 The raz1 and raz2 values are returned in the range 0-2pi.
32**
33** 2 Cases where there is no solution can only arise near the poles.
34** For example, it is clearly impossible for a star at the pole
35** itself to have a non-zero xi value, and hence it is
36** meaningless to ask where the tangent point would have to be
37** to bring about this combination of xi and dec.
38**
39** 3 Also near the poles, cases can arise where there are two useful
40** solutions. The argument n indicates whether the second of the
41** two solutions returned is useful; n=1 indicates only one useful
42** solution, the usual case; under these circumstances, the second
43** solution corresponds to the "over-the-pole" case, and this is
44** reflected in the values of raz2 and decz2 which are returned.
45**
46** 4 The decz1 and decz2 values are returned in the range +/-pi, but
47** in the usual, non-pole-crossing, case, the range is +/-pi/2.
48**
49** 5 This routine is the spherical equivalent of the routine slaDtpv2c.
50**
51** Called: slaDranrm
52**
53** Last revision: 5 June 1995
54**
55** Copyright P.T.Wallace. All rights reserved.
56*/
57{
58 double x2, y2, sd, cd, sdf, r2, r, s, c;
59
60 x2 = xi * xi;
61 y2 = eta * eta;
62 sd = sin ( dec );
63 cd = cos ( dec );
64 sdf = sd * sqrt ( 1.0 + x2 + y2 );
65 r2 = cd * cd * ( 1.0 + y2 ) - sd * sd * x2;
66 if ( r2 >= 0.0 ) {
67 r = sqrt ( r2 );
68 s = sdf - eta * r;
69 c = sdf * eta + r;
70 if ( xi == 0.0 && r == 0.0 ) {
71 r = 1.0;
72 }
73 *raz1 = slaDranrm ( ra - atan2 ( xi, r ) );
74 *decz1 = atan2 ( s, c );
75 r = -r;
76 s = sdf - eta * r;
77 c = sdf * eta + r;
78 *raz2 = slaDranrm ( ra - atan2 ( xi, r ) );
79 *decz2 = atan2 ( s, c );
80 *n = ( fabs ( sdf ) < 1.0 ) ? 1 : 2;
81 } else {
82 *n = 0;
83 }
84}
Note: See TracBrowser for help on using the repository browser.