source: cpp/common/nonstd_math.h @ 113

Last change on this file since 113 was 109, checked in by sz, 10 years ago

source reorganization (see README)
new feature added: part/joint shapes (see frams/_demos/part_shapes.cpp)

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1#ifndef _NONSTD_MATH_H_
2#define _NONSTD_MATH_H_
3
4
5#ifdef _MSC_VER
6 #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define M_PI etc.
7 #include <math.h> //w vc2008 dzia³a³o tu <cmath>, ale w vc2010 juz nie bo "coœ" (jakiœ inny .h stl'a?) includuje wczeœniej <cmath> bez _USE_MATH_DEFINES, a <cmath> includuje <math.h> (ale tylko raz bo ma "include guards" jak kazdy .h)
8 #include <float.h>
9 #define isnan(x) _isnan(x)
10 #define finite(x) _finite(x)
11#else //m.in. __BORLANDC__
12 #include <math.h>
13#endif
14
15#ifdef _WIN32 //http://stackoverflow.com/questions/2170385/c-math-functions
16double round(double val);
17#endif
18
19
20//random number generator:
21#include "random.h"
22RandomGenerator& rndGetInstance();
23
24#define rnd01 (rndGetInstance().getDouble())
25#define rnd0N(limit) (rndGetInstance().getDouble()*(limit))
26#define randomN(limit) ((unsigned int)(rndGetInstance().getDouble()*(limit)))
27#define setRandomSeed(seed) rndGetInstance().setSeed(seed)
28#define setRandomRandomSeed() rndGetInstance().randomize()
29
30//floating point specific numbers
31#include "stdlib.h"
32
33#ifdef __BORLANDC__
34        #include <float.h>
35        #define isnan(x) _isnan(x) //http://stackoverflow.com/questions/570669/checking-if-a-double-or-float-is-nan-in-c
36        #define finite(x) _finite(x)
37#endif
38
39#ifdef IPHONE
40        #define finite(x) (!isinf(x))
41#endif
42
43
44#if defined SHP && !defined TIZEN
45 //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. Na szczêœcie jest w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp"
46 #define isnan(x) false //isnan() sie nie linkuje
47 #define finite(x) true //j.w.
48 //#include <cstdlib> //RAND_MAX defined incorrectly
49 //#ifdef BADA_SIMULATOR //...but only in simulator libs
50 // #undef RAND_MAX
51 // #define RAND_MAX 32768 //...this is the actual value used by rand()
52 //#endif
53#endif
54
55
56//handling floating point exceptions
57void fpExceptInit(); //call once, before ...Enable/Disable
58void fpExceptEnable();
59void fpExceptDisable();
60
61#endif
62
Note: See TracBrowser for help on using the repository browser.