What is the command to scale numbers? It’s map() in Processing. I need to get data from 0 to 1024 to scale to -1 to 1.
It doesn’t exist right now, except in externals like ofxTodd and ofxProcessing. Try this:
float ofMap(float x, float lowIn, float highIn, float lowOut, float highOut) {
return ((x - lowIn) / (highIn - lowIn)) * (highOut - lowOut) + lowOut;
}
I’m sure this will find its way into of soon enough. This time of the year, two years ago, it-found-its-way-into-Processing…
Thanks, I was wondering if I have to do it manually. This program is going to get rather function heavy then. The joys of translating accelerometer data.
wow kyle, so its almost thanks to you we have it in processing!
[quote author=“memo”]wow kyle, so its almost thanks to you we have it in processing!