Morph-SynRJ

view mth.h @ 0:22de913c2d84

morph-synrj intro
author "Cedric Pinson <cedric.pinson@alcove.fr> <mornifle@plopbyte.net>"
date Tue Nov 27 15:23:52 2007 +0100 (2007-11-27)
parents
children
line source
1 /** @file mth.h
2 *
3 * @brief mth facility
4 *
5 *****************************************************************************
6 *
7 * @author psc80
8 *
9 * @date Created 2001/05
10 *
11 * @version $Id: mth.h,v 1.4 2004/01/16 23:38:23 psc80 Exp $
12 *
13 ****************************************************************************/
15 #ifndef MTH_H
16 #define MTH_H
18 #include <cmath>
19 #include <cstdlib>
20 #include "sys_assert.h"
22 namespace mth {
24 typedef float Real_t;
26 const double PI=3.14159265358979323846;
27 const double TWOPI=2.0*PI;
28 const double EPSILON=1e-6;
32 /// Return the square root
33 float Sqrt(const float& _a);
34 double Sqrt(const double& _a);
38 float Abs(float _v);
42 /// Return the maximum value between 2 value
43 float Max(const float& a, const float& b);
46 /// Return the minimum value between 2 value
47 float Min(const float& a, const float& b);
50 float Pow(const float& _a,const float& _b);
52 /// Specialisation of pow for double
53 double Pow(const double& _a,const double& _b);
56 float Frac(const float& _x);
59 float Tan(float _a);
62 float Clamp(const float& _x,const float& _min,const float& _max);
64 /// Return the cos
65 float Cos(const float& _a);
67 /// Specialisation of cos for double
68 double Cos(const double& _a);
72 /// Return the sin
73 float Sin(const float& _a);
75 /// Specialisation of sin for double
76 double Sin(const double& _a);
80 /// Return the atan
81 float ATan(const float& _a);
83 /// Specialisation of atan for double
84 double ATan(const double& _a);
88 /// Return acos
89 float ACos(const float& _a);
91 /// Specialisation of acos for double
92 double ACos(const double& _a);
96 /// Return asin
97 float ASin(const float& _a);
99 /// Specialisation of asin for double
100 double ASin(const double& _a);
105 /// Return floor
106 float Floor(const float& _a);
108 /// Specialisation of floor for double
109 double Floor(const double& _a);
113 /// Return ceil
114 float Ceil(const float& _a);
116 /// Specialisation of ceil for double
117 double Ceil(const double& _a);
122 /// Return sign of a float
123 float Sign(const float& _a);
127 const unsigned int RANDOM_MAX=RAND_MAX;
130 /// floathe function returns a pseudo-random integer between 0 and RANDOM_MAX
131 int Rand();
134 int Random();
137 /** The SRand() function sets its argument as the seed for a new
138 * sequence of pseudo-random integers to be returned by rand(). These
139 * sequences are repeatable by calling srand() with the same seed value
140 */
141 void SRand(unsigned int _seed);
147 }
152 #endif