source: trunk/MagicSoft/slalib/s2tp.c@ 9488

Last change on this file since 9488 was 731, 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 slaS2tp ( float ra, float dec, float raz, float decz,
4 float *xi, float *eta, int *j )
5/*
6** - - - - - - - -
7** s l a S 2 t p
8** - - - - - - - -
9**
10** Projection of spherical coordinates onto tangent plane
11** ('gnomonic' projection - 'standard coordinates').
12**
13** (single precision)
14**
15** Given:
16** ra,dec float spherical coordinates of point to be projected
17** raz,decz float spherical coordinates of tangent point
18**
19** Returned:
20** *xi,*eta float 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: 17 August 1999
27**
28** Copyright P.T.Wallace. All rights reserved.
29*/
30#define TINY 1e-6f
31{
32 float sdecz, sdec, cdecz, cdec, radif, sradif, cradif, denom;
33
34
35/* Trig functions */
36 sdecz = (float) sin ( decz );
37 sdec = (float) sin ( dec );
38 cdecz = (float) cos ( decz );
39 cdec = (float) cos ( dec );
40 radif = ra - raz;
41 sradif = (float) sin ( radif );
42 cradif = (float) 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.0f ) {
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.