map(-30, -89.75, 89.75, 0, 360)
I’m looking for something like this where:
- -30 is the input value.
- -89.75 to 89.75 is the range of possible input values
- 0 – 360 is the final range to be mapped to
I was told there is a way to do this using http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-map
.. however its not readily apparent !
If I’m understanding correctly, I think you just want to uniformly map one range onto another. So, we just need to calculate how far through the input range it is, and return that fraction of the output range.
Also, I should note that map has a bit of a different meaning in ruby, and a more appropriate description would probably be transform.