Krotos Modules 3
Loading...
Searching...
No Matches
Utilities.h
Go to the documentation of this file.
1//=====================================================================================
7//=====================================================================================
8
9#pragma once
10
11namespace krotos
12{
13
15 {
16 // if x is positive
17 if (x > 0)
18 {
19 // while x is even and larger than 1
20 while (((x % 2) == 0) && x > 1)
21 {
22 // divide by 2
23 x = x / 2;
24 }
25
26 // if x is a power of 2 x will now be equal to 1
27 return (x == 1);
28 }
29 else // otherwise, x is 0 or less, so return false
30 {
31 return false;
32 }
33 }
34
35 float phaseWrap(float p)
36 {
37 while (p <= (-M_PI))
38 {
39 p += static_cast<float>(2 * M_PI);
40 }
41
42 while (p > M_PI)
43 {
44 p -= static_cast<float>(2 * M_PI);
45 }
46
47 return p;
48 }
49} // namespace krotos
Definition AirAbsorptionFilter.cpp:2
float phaseWrap(float p)
Definition Utilities.h:35
bool isPositivePowerOfTwo(int x)
Definition Utilities.h:14
#define M_PI
Definition windowing.h:9