View Single Post
  #2  
Old 03-28-2010, 06:04 AM
dwaik dwaik is offline
Member
 
Join Date: Feb 2010
Posts: 26
here you dont want to scale first, you need to get the full range [-5,5] if you can get it,
then you can use the mathmatical range scaling which:


to scale x form range [a-b] to range [c-d]

newX=(x-a)/(b-a) #here you will have your value in range [0-1]
finalValue=(newX*(d-c))+c #and here you will have your value in range [c-d]



which in your case if x was 2 in range [-5,5] and you need to change it to range [-450,450]

you can solve it as follows:
newX=(2-(-5))/(5-(-5)) #7/10=0.7 in range [0,1]
finalValue=(0.7*(450-(-450)))+(-450) #(0.7*900)-450=180 and thats it

hope that helps
Reply With Quote