source: trunk/MagicSoft/slalib/tps2c.c@ 9330

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