32 #if defined( CINDER_MSW ) || defined( CINDER_WINRT )
42 static T
acos (T
x) {return ::acos (
double(x));}
43 static T
asin (T
x) {return ::asin (
double(x));}
44 static T
atan (T
x) {return ::atan (
double(x));}
45 static T
atan2 (T
y, T
x) {return ::atan2 (
double(y),
double(x));}
46 static T
cos (T
x) {return ::cos (
double(x));}
47 static T
sin (T
x) {return ::sin (
double(x));}
48 static T
tan (T
x) {return ::tan (
double(x));}
49 static T
cosh (T
x) {return ::cosh (
double(x));}
50 static T
sinh (T
x) {return ::sinh (
double(x));}
51 static T
tanh (T
x) {return ::tanh (
double(x));}
52 static T
exp (T
x) {return ::exp (
double(x));}
53 static T
log (T
x) {return ::log (
double(x));}
54 static T
log10 (T
x) {return ::log10 (
double(x));}
58 T rval( ::
modf (
double(x),&ival));
62 static T
pow (T
x, T
y) {return ::pow (
double(x),
double(y));}
63 static T
sqrt (T
x) {return ::sqrt (
double(x));}
64 #if defined( _MSC_VER )
65 static T
cbrt( T
x ) {
return ( x > 0 ) ? (
::pow( x, 1.0 / 3.0 )) : (- ::
pow( -x, 1.0 / 3.0 ) ); }
67 static T
cbrt( T x ) { return ::cbrt( x ); }
69 static T
ceil (T x) {return ::ceil (
double(x));}
70 static T
abs (T x) {return ::fabs (
double(x));}
71 static T
floor (T x) {return ::floor (
double(x));}
72 static T
fmod (T x, T
y) {return ::fmod (
double(x),
double(y));}
73 static T
hypot (T x, T
y) {return ::hypot (
double(x),
double(y));}
74 static T
signum (T x) {
return ( x >0.0 ) ? 1.0 : ( ( x < 0.0 ) ? -1.0 : 0.0 ); }
75 static T
min(T x, T
y) {
return ( x < y ) ? x :
y; }
76 static T
max(T x, T
y) {
return ( x > y ) ? x :
y; }
84 static float acos (
float x) {return ::acosf (x);}
85 static float asin (
float x) {return ::asinf (x);}
86 static float atan (
float x) {return ::atanf (x);}
87 static float atan2 (
float y,
float x) {return ::atan2f (y, x);}
88 static float cos (
float x) {return ::cosf (x);}
89 static float sin (
float x) {return ::sinf (x);}
90 static float tan (
float x) {return ::tanf (x);}
91 static float cosh (
float x) {return ::coshf (x);}
92 static float sinh (
float x) {return ::sinhf (x);}
93 static float tanh (
float x) {return ::tanhf (x);}
94 static float exp (
float x) {return ::expf (x);}
95 static float log (
float x) {return ::logf (x);}
96 static float log10 (
float x) {return ::log10f (x);}
97 static float modf (
float x,
float *
y) {return ::modff (x, y);}
98 static float pow (
float x,
float y) {return ::powf (x, y);}
99 static float sqrt (
float x) {return ::sqrtf (x);}
100 #if defined( _MSC_VER )
101 static float cbrt(
float x ) {
return ( x > 0 ) ? (::powf( x, 1.0
f / 3.0
f )) : (- ::powf( -x, 1.0
f / 3.0
f ) ); }
103 static float cbrt (
float x) { return ::cbrtf( x ); }
105 static float ceil (
float x) {return ::ceilf (x);}
106 static float abs (
float x) {return ::fabsf (x);}
107 static float floor (
float x) {return ::floorf (x);}
108 static float fmod (
float x,
float y) {return ::fmodf (x, y);}
109 #if !defined(_MSC_VER)
110 static float hypot (
float x,
float y) {return ::hypotf (x, y);}
112 static float hypot (
float x,
float y) {return ::sqrtf(x*x + y*y);}
114 static float signum (
float x) {
return ( x > 0.0
f ) ? 1.0f : ( ( x < 0.0f ) ? -1.0
f : 0.0
f ); }
115 static float min(
float x,
float y) {
return ( x < y ) ? x :
y; }
116 static float max(
float x,
float y) {
return ( x > y ) ? x :
y; }
121 #define M_PI 3.14159265358979323846
125 #define EPSILON EPSILON_VALUE
129 return x * 0.017453292519943295769f;
134 return x * 0.017453292519943295769;
139 return x * 57.295779513082321f;
144 return x * 57.295779513082321;
147 template<
typename T,
typename L>
148 T
lerp(
const T &
a,
const T &
b, L factor )
150 return a + ( b -
a ) * factor;
154 T
lmap(T
val, T inMin, T inMax, T outMin, T outMax)
156 return outMin + (outMax - outMin) * ((val - inMin) / (inMax - inMin));
159 template<
typename T,
typename L>
162 L t1 =
static_cast<L
>(1.0) -
t;
163 return a*(t1*t1*t1) + b*(3*t*t1*t1) + c*(3*t*t*t1) + d*(t*t*t);
166 template<
typename T,
typename L>
169 L t1 =
static_cast<L
>(1.0) -
t;
170 return a*(t1*t1*t1) + b*(3*t*t1*t1) + c*(3*t*t*t1) + d*(t*t*t);
176 if( val < minVal )
return minVal;
177 else if( val > maxVal )
return maxVal;
193 if( x * x < 1.19209290E-07F )
211 uint32_t isNotPowerOf2 = (x & (x - 1));
228 return ( x & ( x - 1 ) ) == 0;
234 if( a == 0 )
return (b == 0 ? -1 : 0 );
244 T radical = b * b - 4 * a *
c;
245 if( radical < 0 )
return 0;
248 result[0] = -b / (2 *
a);
253 result[0] = ( -b - srad ) / (2 * a);
254 result[1] = ( -b + srad ) / (2 * a);
255 if( a < 0 ) std::swap( result[0], result[1] );
259 template<
typename T,
int ORDER>
262 static_assert(ORDER > 2,
"ORDER must be greater than 2" );
266 rom[0][0] = ((T)0.5) * half * ( SPEEDFN(a)+SPEEDFN(b) );
267 for(
int i0=2, iP0=1; i0 <= ORDER; i0++, iP0 *= 2, half *= (T)0.5) {
270 for(
int i1 = 1; i1 <= iP0; i1++ )
271 sum += SPEEDFN(a + half*(i1-((T)0.5)));
274 rom[1][0] = ((T)0.5)*(rom[0][0] + half*
sum);
275 for(
int i2 = 1, iP2 = 4; i2 < i0; i2++, iP2 *= 4 )
276 rom[1][i2] = (iP2*rom[1][i2-1] - rom[0][i2-1])/(iP2-1);
277 for(
int i1 = 0; i1 < i0; i1++ )
278 rom[0][i1] = rom[1][i1];
281 return rom[0][ORDER-1];
289 #if defined( _MSC_VER ) && ( _MSC_VER < 1800 )
293 inline bool isfinite(
float arg ) {
return _finite( arg ) != 0; }
294 inline bool isfinite(
double arg ) {
return _finite( arg ) != 0; }
295 inline bool isnan(
float arg ) {
return _isnan( arg ) != 0; }
296 inline bool isnan(
double arg ) {
return _isnan( arg ) != 0; }
300 inline double round(
double x ) {
return floor( x < 0 ? x - 0.5 : x + 0.5 ); }
301 inline float roundf(
float x ) {
return floorf( x < 0 ? x - 0.5
f : x + 0.5
f ); }
302 inline long int lround(
double x ) {
return (
long int)( x < 0 ? x - 0.5 : x + 0.5 ); }
303 inline long int lroundf(
float x ) {
return (
long int)( x < 0 ? x - 0.5f : x + 0.5f ); }
306 #endif // defined( _MSC_VER ) && ( _MSC_VER < 1800 )
static T sqrt(T x)
Definition: CinderMath.h:63
static T ceil(T x)
Definition: CinderMath.h:69
static float ceil(float x)
Definition: CinderMath.h:105
static float pow(float x, float y)
Definition: CinderMath.h:98
GLenum GLint GLint y
Definition: GLee.h:987
static float abs(float x)
Definition: CinderMath.h:106
Definition: CinderMath.h:40
static T cos(T x)
Definition: CinderMath.h:46
static T log(T x)
Definition: CinderMath.h:53
float toDegrees(float x)
Definition: CinderMath.h:137
static float tanh(float x)
Definition: CinderMath.h:93
static float max(float x, float y)
Definition: CinderMath.h:116
T rombergIntegral(T a, T b, const std::function< T(T)> &SPEEDFN)
Definition: CinderMath.h:260
static float atan2(float y, float x)
Definition: CinderMath.h:87
T sinx_over_x(T x)
Definition: CinderMath.h:191
int int * max
Definition: GLee.h:17208
static T tanh(T x)
Definition: CinderMath.h:51
static T asin(T x)
Definition: CinderMath.h:43
static T modf(T x, T *iptr)
Definition: CinderMath.h:55
static T sin(T x)
Definition: CinderMath.h:47
static float sin(float x)
Definition: CinderMath.h:89
uint32_t nextPowerOf2(uint32_t x)
Definition: CinderMath.h:215
static float sqrt(float x)
Definition: CinderMath.h:99
uint32_t log2floor(uint32_t x)
Definition: CinderMath.h:200
T lerp(const T &a, const T &b, L factor)
Definition: CinderMath.h:148
static T pow(T x, T y)
Definition: CinderMath.h:62
static float floor(float x)
Definition: CinderMath.h:107
static T floor(T x)
Definition: CinderMath.h:71
static T fmod(T x, T y)
Definition: CinderMath.h:72
static T cosh(T x)
Definition: CinderMath.h:49
const double EPSILON_VALUE
Definition: CinderMath.h:124
static float sinh(float x)
Definition: CinderMath.h:92
static T sinh(T x)
Definition: CinderMath.h:50
static float acos(float x)
Definition: CinderMath.h:84
T lmap(T val, T inMin, T inMax, T outMin, T outMax)
Definition: CinderMath.h:154
GLuint GLfloat * val
Definition: GLee.h:14636
int solveCubic(T a, T b, T c, T d, T result[3])
Definition: CinderMath.cpp:33
static T max(T x, T y)
Definition: CinderMath.h:76
static T atan2(T y, T x)
Definition: CinderMath.h:45
float sum(const float *array, size_t length)
returns the sum of array
Definition: Dsp.cpp:175
static T acos(T x)
Definition: CinderMath.h:42
static float min(float x, float y)
Definition: CinderMath.h:115
static T abs(T x)
Definition: CinderMath.h:70
static float cos(float x)
Definition: CinderMath.h:88
static T clamp(T x, T min=0, T max=1)
Definition: CinderMath.h:77
static T hypot(T x, T y)
Definition: CinderMath.h:73
static float clamp(float x, float min=0, float max=1)
Definition: CinderMath.h:117
GLenum GLint x
Definition: GLee.h:987
int solveQuadratic(T a, T b, T c, T result[2])
Definition: CinderMath.h:240
static float atan(float x)
Definition: CinderMath.h:86
static T log10(T x)
Definition: CinderMath.h:54
static float log10(float x)
Definition: CinderMath.h:96
static float hypot(float x, float y)
Definition: CinderMath.h:110
static T tan(T x)
Definition: CinderMath.h:48
static T exp(T x)
Definition: CinderMath.h:52
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
static float log(float x)
Definition: CinderMath.h:95
static float cosh(float x)
Definition: CinderMath.h:91
static float cbrt(float x)
Definition: CinderMath.h:103
const GLubyte * c
Definition: GLee.h:8491
static T cbrt(T x)
Definition: CinderMath.h:67
float toRadians(float x)
Definition: CinderMath.h:127
static float modf(float x, float *y)
Definition: CinderMath.h:97
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
static T atan(T x)
Definition: CinderMath.h:44
static float asin(float x)
Definition: CinderMath.h:85
static T min(T x, T y)
Definition: CinderMath.h:75
static float exp(float x)
Definition: CinderMath.h:94
T bezierInterp(T a, T b, T c, T d, L t)
Definition: CinderMath.h:160
T constrain(T val, T minVal, T maxVal)
Definition: CinderMath.h:174
T bezierInterpRef(const T &a, const T &b, const T &c, const T &d, L t)
Definition: CinderMath.h:167
GLdouble GLdouble t
Definition: GLee.h:1426
bool isPowerOf2(size_t x)
Returns true if x is a power of two, false otherwise.
Definition: CinderMath.h:226
static T signum(T x)
Definition: CinderMath.h:74
GLclampf f
Definition: GLee.h:15307
static float tan(float x)
Definition: CinderMath.h:90
static float signum(float x)
Definition: CinderMath.h:114
uint32_t log2ceil(uint32_t x)
Definition: CinderMath.h:209
T fract(T x)
Returns the fractional part of x, calculated as x - floor( x )
Definition: CinderMath.h:183
static float fmod(float x, float y)
Definition: CinderMath.h:108
int solveLinear(T a, T b, T result[1])
Definition: CinderMath.h:232