Posted By

oppey on 05/23/11


Tagged


Versions (?)

とある数字をとある範囲にスケールする


 / Published in: Objective C
 

  1. /*
  2.  float m = map(value, 0, 100, 0, width);
  3.  
  4.  Re-maps a number from one range to another.
  5.  In the example above, the number '25' is converted from a value
  6.  in the range 0..100 into a value that ranges from the left edge (0) to
  7.  the right edge (width) of the screen.
  8.  */
  9. -(float)map:(float)value currLow:(float)currLow currHigh:(float)currHigh tarLow:(float)tarLow tarHigh:(float)tarHigh{
  10. return tarLow + (tarHigh - tarLow) * ((value - currLow) / (currHigh - currLow));
  11. }
  12.  
  13.  

Report this snippet  

You need to login to post a comment.