source: trunk/MagicSoft/slalib/afin.c@ 4308

Last change on this file since 4308 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaAfin ( char *string, int *iptr, float *a, int *j )
4/*
5** - - - - - - - -
6** s l a A f i n
7** - - - - - - - -
8**
9** Sexagesimal character string to angle.
10**
11** (single precision)
12**
13** Given:
14** string c*(*) string containing deg, arcmin, arcsec fields
15** iptr int where to start decode (1st = 1)
16**
17** Returned:
18** iptr int advanced past the decoded angle
19** a float angle in radians
20** j int status: 0 = OK
21** +1 = default, A unchanged
22** -1 = bad degrees )
23** -2 = bad arcminutes ) (note 3)
24** -3 = bad arcseconds )
25**
26** Example:
27**
28** argument before after
29**
30** string '-57 17 44.806 12 34 56.7' unchanged
31** iptr 1 16 (points to 12...)
32**
33** a ? -1.00000f
34** j ? 0
35**
36** A further call to slaAfin, without adjustment of iptr, will
37** decode the second angle, 12deg 34min 56.7sec.
38**
39** Notes:
40**
41** 1) The first three "fields" in string are degrees, arcminutes,
42** arcseconds, separated by spaces or commas. The degrees field
43** may be signed, but not the others. The decoding is carried
44** out by the dfltin routine and is free-format.
45**
46** 2) Successive fields may be absent, defaulting to zero. For
47** zero status, the only combinations allowed are degrees alone,
48** degrees and arcminutes, and all three fields present. If all
49** three fields are omitted, a status of +1 is returned and a is
50** unchanged. In all other cases a is changed.
51**
52** 3) Range checking:
53** The degrees field is not range checked. However, it is
54** expected to be integral unless the other two fields are absent.
55** The arcminutes field is expected to be 0-59, and integral if
56** the arcseconds field is present. If the arcseconds field
57** is absent, the arcminutes is expected to be 0-59.9999...
58** The arcseconds field is expected to be 0-59.9999...
59**
60** 4) Decoding continues even when a check has failed. Under these
61** circumstances the field takes the supplied value, defaulting
62** to zero, and the result a is computed and returned.
63**
64** 5) Further fields after the three expected ones are not treated
65** as an error. The pointer iptr is left in the correct state
66** for further decoding with the present routine or with slaDfltin
67** etc. See the example, above.
68**
69** 6) If string contains hours, minutes, seconds instead of degrees
70** etc, or if the required units are turns (or days) instead of
71** radians, the result a should be multiplied as follows:
72** for to obtain multiply
73** string a in a by
74** d ' " radians 1 = 1.0f
75** d ' " turns 1/2pi = 0.1591549430918953358f
76** h m s radians 15 = 15.0f
77** h m s days 15/2pi = 2.3873241463784300365f
78**
79** Called: slaDfltin
80**
81** Last revision: 16 November 1993
82**
83** Copyright P.T.Wallace. All rights reserved.
84*/
85{
86 double ad;
87
88/* Call the double precision version */
89 slaDafin ( string, iptr, &ad, j );
90 if ( *j <= 0 ) *a = (float) ad;
91}
Note: See TracBrowser for help on using the repository browser.