Interval Map
January 21, 2018
Many programs require a mathematical function capable of mapping an interval of numbers linearly onto another interval. A map function maps one interval linearly onto another.
map(x):[a,b]→[c,d]map(x)=b−ad−c(x−a)+cExample
The interval [0,10] can be mapped to [0,100] using map.
map(x)map(0)map(10)=10x=0=100Derivation
The map function can be thought of as a linear function that passes through the points (a,c) and (b,d). This means that the function should map a to c and b to d.
map(a)map(b)=c=dWith two points the slope can be obtained and the function can be written and simplified.
map(x)−cmap(x)=b−ad−c(x−a)=b−ad−c(x−a)+cThe function can be verified to ensure a correct mapping of a to c.
map(a)map(a)=b−ad−c(a−a)+c=cThe same can be done to ensure b maps to d.
map(b)map(b)map(b)=b−ad−c(b−a)+c=d−c+c=d