linmap()
Re-maps a number from one range to another.
Last updated
Re-maps a number from one range to another.
Last updated
value
the incoming value to be converted
start1
lower bound of the current range
stop1
higher bound of the current range
start2
lower bound of the newly mapped range
stop2
higher bound of the newly mapped range
withinBounds
boolean that specifies the behavior of the method if the mapped value is out of the bounds [start2, stop2]
Maps a value from one range to another, such that the proportions are the same.
For example, number 2.5 is mapped from the range [0, 10] to number 25 in the range [0, 100]. Why? Because in both cases, the value is fourth the distance away from the starting point of the range, and three fourths away from the ending point.
Mapping 2.5 from the range [0, 10] to the range [10, 20] would give 12.5 for the same reason.
mapping 2.5 from the range [0, 10] to the range [10, 30] would give 15 for the same reason.
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.