This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
implementation_unwrap_modulo [2018/09/19 17:11] supergnu old revision restored (2018/09/19 14:52) |
implementation_unwrap_modulo [2018/09/19 17:11] (current) supergnu |
||
---|---|---|---|
Line 4: | Line 4: | ||
It's an easy piece of code but handy to have it around off the shelf: | It's an easy piece of code but handy to have it around off the shelf: | ||
<code C unwrap.c> | <code C unwrap.c> | ||
- | int unwrap(int *values, int numberOfValues, | + | int unwrap(int *values, int numberOfValues, |
{ | { | ||
- | for (int i = 0; i < numberOfValues; | + | |
+ | | ||
{ | { | ||
- | while(values[i] | + | while(abs(values[i-1] - values[i]) > modulo/2) |
{ | { | ||
- | (values[i] > modulo/2) ? values[i] | + | (values[i-1] > values[i]) ? add += modulo : add -= modulo; //could be faster if i kept the phase between samples |
- | } | + | |
+ | } // issue, there' | ||
+ | add = 0; | ||
} | } | ||
} | } | ||
</ | </ |