Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

How to make a range thats not 0-1 0-1

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
To adjust a value from the original range (min0 to max0) to the new range (min1 to max1), use this function:

f(v) = ((v - min0) / (max0 - min0)) * (max1 - min1) + min1

If min0 = 0, max0 = 0.7, min1 = 0 and max1 = 1, then the function would simplify to:

f(v) = ((v - 0) / (0.7 - 0)) * 1 + 0
= v / 0.7

Just as uavfun said.

Share this post


Link to post
Share on other sites
Basically what you have to do is scale the value so that it's in the given range. Here's a visual:

|----|----|
0 .4 .7

|----|----|
0 .5 1

Agony already posted the formula, I just thought I'd explain it a little more.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!