source: trunk/MagicSoft/slalib/v2tp.c@ 7489

Last change on this file since 7489 was 732, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaV2tp ( float v[3], float v0[3], float *xi, float *eta, int *j )
4/*
5** - - - - - - - -
6** s l a V 2 t p
7** - - - - - - - -
8**
9** Given the direction cosines of a star and of the tangent point,
10** determine the star's tangent-plane coordinates.
11**
12** (single precision)
13**
14** Given:
15** v float[3] direction cosines of star
16** v0 float[3] direction cosines of tangent point
17**
18** Returned:
19** *xi,*eta float tangent plane coordinates of star
20** j int status: 0 = OK
21** 1 = error, star too far from axis
22** 2 = error, antistar on tangent plane
23** 3 = error, antistar too far from axis
24**
25** Notes:
26**
27** 1 If vector v0 is not of unit length, or if vector v is of zero
28** length, the results will be wrong.
29**
30** 2 If v0 points at a pole, the returned xi,eta will be based on the
31** arbitrary assumption that the RA of the tangent point is zero.
32**
33** 3 This routine is the Cartesian equivalent of the routine slaS2tp.
34**
35** Last revision: 27 November 1996
36**
37** Copyright P.T.Wallace. All rights reserved.
38*/
39#define TINY 1e-6f
40{
41 float x, y, z, x0, y0, z0, r2, r, w, d;
42
43
44 x = v[0];
45 y = v[1];
46 z = v[2];
47 x0 = v0[0];
48 y0 = v0[1];
49 z0 = v0[2];
50 r2 = x0 * x0 + y0 * y0;
51 r = (float) sqrt ( (double) r2 );
52 if ( r == 0.0f ) {
53 r = 1e-20f;
54 x0 = r;
55 }
56 w = x * x0 + y * y0;
57 d = w + z * z0;
58 if ( d > TINY ) {
59 *j = 0;
60 } else if ( d >= 0.0f ) {
61 *j = 1;
62 d = TINY;
63 } else if ( d > -TINY ) {
64 *j = 2;
65 d = -TINY;
66 } else {
67 *j = 3;
68 }
69 d *= r;
70 *xi = ( y * x0 - x * y0 ) / d;
71 *eta = ( z * r2 - z0 * w ) / d;
72}
Note: See TracBrowser for help on using the repository browser.