| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
trigonometry.cpp
Go to the documentation of this file.
1
9 #include <math.h>
10 #include "trigonometry.h"
11 #include "utilities.h"
12
13 // Declaration of global variables
14 extern int verbose; // Level of output to the screen
15
27 double bcos(double x)
28 {
29 x = angle_set_negPI_to_PI (x);
30
31 if( fabs(x - M_PI_2) < TRIGPRECISION || fabs(x + M_PI_2) < TRIGPRECISION ) //x=+90 or -90 degrees
32 return (0.0);
33
34 return (cos(x));
35 }
36
48 double bsin(double x)
49 {
50 x = angle_set_negPI_to_PI (x);
51
52 if( fabs(x - M_PI) < TRIGPRECISION || fabs(x + M_PI) < TRIGPRECISION ) //x=180 or -180 degrees
53 return (0.0);
54
55 return sin(x);
56 }
57
71 double btan(double x)
72 {
73 x = angle_set_negPI_to_PI (x);
74
75 if( fabs(x - M_PI) < TRIGPRECISION || fabs(x + M_PI) < TRIGPRECISION ) //x=180 or -180 degrees
76 return (0.0);
77
78 return (tan(x));
79 }
80
89 double bacos(double x)
90 {
91 if ( x > 1 ) x = 1;
92 if ( x < -1 ) x = -1;
93
94 return (acos(x));
95 }
96
105 double basin(double x)
106 {
107 if ( x > 1 ) x = 1;
108 if ( x < -1 ) x = -1;
109
110 return (asin(x));
111 }
112
122 double batan2(double y, double x)
123 {
124 if ( fabs(x) < TRIGPRECISION ) //x lower than TRIGPRECISION
125 x = 0.0;
126
127 if( fabs(y) < TRIGPRECISION ) //y lower than TRIGPRECISION
128 y = 0.0;
129
130 return (atan2(y, x));
131 }
132
M_PI_2
#define M_PI_2
Definition: utilities.h:55
utilities.h
Header file for general utilities.
angle_set_negPI_to_PI
double angle_set_negPI_to_PI(double angle)
Returns an angle between -PI and PI.
Definition: utilities.cpp:565
bcos
double bcos(double x)
Avoid non-zero values for cos(PI/2) and cos(-PI/2).
Definition: trigonometry.cpp:27
M_PI
#define M_PI
Definition: utilities.h:52
TRIGPRECISION
#define TRIGPRECISION
Definition: trigonometry.h:9
verbose
int verbose
batan2
double batan2(double y, double x)
Sets small values to zero before calling atan2.
Definition: trigonometry.cpp:122
basin
double basin(double x)
Wrapper to avoid NaN's returned from asin.
Definition: trigonometry.cpp:105
trigonometry.h
Header file for trigonometry functions.
bsin
double bsin(double x)
Avoid non-zero values for sin(PI) and sin(-PI).
Definition: trigonometry.cpp:48
btan
double btan(double x)
Avoid non-zero values for tan(PI) and tan(-PI). ATTENTION: tan function return a bigg value for tan(P...
Definition: trigonometry.cpp:71
bacos
double bacos(double x)
Wrapper to avoid NaN's returned from acos.
Definition: trigonometry.cpp:89