You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Converts a value from its current range to a target range.
17
+
18
+
.DESCRIPTION
19
+
ConvertTo-Range converts a value from its position in a current range to the same relative position in a target range.
20
+
21
+
This function takes a current range (range 1), a target range (range 2), and a value in the current range. It returns the equivalent value in the target range.
22
+
23
+
For example, if the current range is 0-10, the target range is 20-30, and the value is 5, it returns 25, which is the equivalent value in the 20-30 range.
24
+
25
+
.PARAMETERValue
26
+
Specifies the integer value to be converted from the current range to the target range.
27
+
28
+
Although this value is evaluated based on its position in the current range, it can be any value, including a value outside of the current range and the target range.
29
+
30
+
.PARAMETERRange1_Start
31
+
Specifies the starting value in the current range. Enter an integer value. The value of Range1_Start can be less than or greater than the value of Range1_End.
32
+
33
+
.PARAMETERRange1_End
34
+
Specifies the ending value in the current range. Enter an integer value. The value of Range1_End can be less than or greater than the value of Range1_Start.
35
+
36
+
.PARAMETERRange2_Start
37
+
Specifies the starting value in the target range. Enter an integer value. The value of Range2_Start can be less than or greater than the value of Range2_End.
38
+
39
+
.PARAMETERRange2_End
40
+
Specifies the ending value in the target range. Enter an integer value. The value of Range2_End can be less than or greater than the value of Range2_Start.
This command maps the range 40-90 to the range 0-100. Then, given a value of 40 in the first range, it returns 0, the equivalent value in the second range.
This command demonstrates that the test value does not need to be within the starting or the target range. The resulting value in the target range is proportional to the input value in the current range.
53
+
54
+
.NOTES
55
+
Based on the map() method in the Java Processing library
56
+
https://processing.org/reference/map_.html
57
+
58
+
Thanks to Andy Cahn at Chrysalis Schools for the math help.
0 commit comments