Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Notice that I'm definitely not an expert in math, and I'm going to use this function in a game for something connected to lights (however, is very math-specific, that's why I'm posting here and not on gamedev).

I need a function to "bind" every value between 3.5 and 70 to values between 0.5 and 1.5 Where 3.5 => 0.5 and 70 => 1.5. So for example the value 36.75 will be 1.0.

Also, if possible, I would like to change the first two values to have a different range and the other 2 values to a different range.

Are there any math function that satisfact what I'm asking (if exists)?

Sorry if it looks as an easy question for someone, but really I'm quite noob in math^^

share|improve this question
3  
You could perform linear interpolation, at the simplest: $$y=\frac{1.5-0.5}{70-3.5}(x-3.5)+0.5$$ –  J. M. Apr 24 '12 at 12:57
1  
Mhh that's interesting, I didn't think about it, why don't you put it as an answer? –  Fire-Dragon-DoL Apr 24 '12 at 13:04
    
Graph of a straight line passing through (0.5,3.5) and (1.5,70), thats what you need. –  Tomarinator Apr 27 '12 at 17:12

1 Answer 1

up vote 0 down vote accepted

I'm answering because J.M. didn't put it as an answer, by the way what is suggested is perfect and works well for my situation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.