A library that maps one range onto another range.
Revision 2:ac294c579449, committed 2019-12-27
- Comitter:
- drorbalbul
- Date:
- Fri Dec 27 17:52:39 2019 +0000
- Parent:
- 1:dad975e2e150
- Commit message:
- cantran for noam
Changed in this revision
Map.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Map.cpp Wed Sep 28 04:02:59 2016 +0200 +++ b/Map.cpp Fri Dec 27 17:52:39 2019 +0000 @@ -10,5 +10,12 @@ float Map::Calculate(float inVal) { - return ( (inVal - _inMin)*(_outMax - _outMin)/(_inMax - _inMin) + _outMin ); + float rval = (inVal - _inMin)*(_outMax - _outMin)/(_inMax - _inMin) + _outMin ; + if (rval < _outMin) { + rval = _outMin; + } + if (rval > _outMax) { + rval = _outMax; + } + return rval; }