source: Sophya/trunk/SophyaExt/XephemAstroLib/actan.c@ 3654

Last change on this file since 3654 was 3654, checked in by cmv, 16 years ago

mise a niveau Xephem 3.7.4, cmv 16/07/2009

File size: 2.2 KB
Line 
1#include <math.h>
2
3/* @(#) $Id: actan.c,v 1.8 2009-07-16 10:34:35 cmv Exp $ */
4
5/* commonly in math.h, but not in strict ANSI C */
6#ifndef M_PI
7#define M_PI 3.14159265358979323846
8#define M_PI_2 1.57079632679489661923
9#endif
10
11double
12actan(double sinx, double cosx)
13{
14 double ret;
15
16 ret = 0.0;
17 if(cosx < 0.0) {
18 ret = M_PI;
19 } else if(cosx == 0.0) {
20 if(sinx < 0.0) {
21 return 3.0 * M_PI_2;
22 } else if(sinx == 0.0) {
23 return ret;
24 } else /* sinx > 0.0 */ {
25 return M_PI_2;
26 }
27 } else /* cosx > 0.0 */ {
28 if(sinx < 0.0) {
29 ret = 2.0 * M_PI;
30 } else if(sinx == 0.0) {
31 return ret;
32 }
33 }
34
35 return ret + atan(sinx / cosx);
36}
37
38
39#if 0
40
41#define D(X) (180.0 * (X) / M_PI)
42
43void main() {
44 double a, b;
45
46 a = 0.0; b = 2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
47 a = 1.0; b = 2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
48 a = 2.0; b = 2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
49 a = 2.0; b = 1.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
50 a = 2.0; b = 0.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
51 a = 2.0; b = -1.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
52 a = 2.0; b = -2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
53 a = 1.0; b = -2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
54 a = 0.0; b = -2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
55 a = -1.0; b = -2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
56 a = -2.0; b = -2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
57 a = -2.0; b = -1.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
58 a = -2.0; b = 0.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
59 a = -2.0; b = 1.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
60 a = -2.0; b = 2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
61 a = -1.0; b = 2.0; printf("actan(%f, %f) = %f\n", a, b, D(actan(a, b)));
62}
63
64#endif /* 0 */
65
66/* For RCS Only -- Do Not Edit */
67static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: actan.c,v $ $Date: 2009-07-16 10:34:35 $ $Revision: 1.8 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.