source: trunk/MagicSoft/slalib/dtpv2c.c@ 9541

Last change on this file since 9541 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaDtpv2c ( double xi, double eta, double v[3], double v01[3],
4 double v02[3], int *n )
5/*
6** - - - - - - - - - -
7** s l a D t p v 2 c
8** - - - - - - - - - -
9**
10** Given the tangent-plane coordinates of a star and its direction
11** cosines, determine the direction cosines of the tangent-point.
12**
13** (double precision)
14**
15** Given:
16** xi,eta double tangent plane coordinates of star
17** v double[3] direction cosines of star
18**
19** Returned:
20** v01 double[3] direction cosines of TP, solution 1
21** v02 double[3] direction cosines of TP, solution 2
22** *n int number of solutions:
23** 0 = no solutions returned (note 2)
24** 1 = only the first solution is useful (note 3)
25** 2 = both solutions are useful (note 3)
26**
27** Notes:
28**
29** 1 The vector v must be of unit length or the result will be wrong.
30**
31** 2 Cases where there is no solution can only arise near the poles.
32** For example, it is clearly impossible for a star at the pole
33** itself to have a non-zero xi value, and hence it is meaningless
34** to ask where the tangent point would have to be.
35**
36** 3 Also near the poles, cases can arise where there are two useful
37** solutions. The argument n indicates whether the second of the
38** two solutions returned is useful; n=1 indicates only one useful
39** solution, the usual case. Under these circumstances, the second
40** solution can be regarded as valid if the vector v02 is interpreted
41** as the "over-the-pole" case.
42**
43** 4 This routine is the Cartesian equivalent of the routine slaDtps2c.
44**
45** Last revision: 5 June 1995
46**
47** Copyright P.T.Wallace. All rights reserved.
48*/
49{
50 double x, y, z, rxy2, xi2, eta2p1, sdf, r2, r, c;
51
52
53 x = v[0];
54 y = v[1];
55 z = v[2];
56 rxy2 = x * x + y * y;
57 xi2 = xi * xi;
58 eta2p1 = eta*eta + 1.0;
59 sdf = z * sqrt ( xi2 + eta2p1 );
60 r2 = rxy2 * eta2p1 - z * z * xi2;
61 if ( r2 > 0.0 ) {
62 r = sqrt( r2 );
63 c = ( sdf * eta + r ) / ( eta2p1 * sqrt ( rxy2 * ( r2 + xi2 ) ) );
64 v01[0] = c * ( x * r + y * xi );
65 v01[1] = c * ( y * r - x * xi );
66 v01[2] = ( sdf - eta * r ) / eta2p1;
67 r = - r;
68 c = ( sdf * eta + r ) / ( eta2p1 * sqrt ( rxy2 * ( r2 + xi2 ) ) );
69 v02[0] = c * ( x * r + y * xi );
70 v02[1] = c * ( y * r - x * xi );
71 v02[2] = ( sdf - eta * r ) / eta2p1;
72 *n = ( fabs ( sdf ) < 1.0 ) ? 1 : 2;
73 } else {
74 *n = 0;
75 }
76}
Note: See TracBrowser for help on using the repository browser.