Pages: [1]   Go Down
Author Topic: multiMap() function - integer linear interpolation  (Read 3632 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13478
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


After playing with my Sharp distancesensor - SHARP 2Y0A02 F 9Y - I needed a mapping from measurements upon centimeters. As the functions I found did not cover the whole range with the accuracy needed I decided to write a linear interpolation function. There was allready one on the playground called reMap() but that used floats, so I redid it in integer to improve performance and robustness. Furthermore I added some snippets how multiMap() can be used.

All remarks, improvements or good examples are - as allways - welcome.

Rob
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like a good idea, where's the code?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13478
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry - code and example snippets can be found on the playground - http://arduino.cc/playground/Main/MultiMap

Rob
[update 30-1-2011]
 - didn't post the code here as small optimizations are planned
[update 2-2-2011]
- code on playground updated.

« Last Edit: February 01, 2011, 06:17:11 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13478
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[update 23-03-2011]
- added float version
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: