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

Last change on this file since 2937 was 2818, checked in by cmv, 20 years ago

Update de Xephem 3.7 cmv 21/08/2005

File size: 2.2 KB
RevLine 
[1457]1#include <math.h>
2
[2818]3/* @(#) $Id: actan.c,v 1.5 2005-08-21 10:02:36 cmv Exp $ */
[1457]4
[1719]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
[1457]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 */
[2818]67static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: actan.c,v $ $Date: 2005-08-21 10:02:36 $ $Revision: 1.5 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.