Map range: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,371:
<lang frink>inverseMapRange[t, a1, a2, b1, b2] := a1 + a1 b1 (-1 b1 + b2)^-1 + -1 a2 b1 (-1 b1 + b2)^-1 + -1 a1 (-1 b1 + b2)^-1 t + a2 (-1 b1 + b2)^-1 t</lang>
 
=={{header|GDScriptFutureBasic}}==
<lang GDScript>func mapRange(s:float, a1:float, a2:float, b1:float, b2:float) -> float :
return b1 + ((b2-b1)/(a2-a1))*(s-a1)
 
for i in 11 :
print( "%2d %+.1f" % [i,mapRange(i,0.0,10.0,-1.0,0.0)] )
</lang>
 
{{out}}
<pre>
0 -1.0
1 -0.9
2 -0.8
3 -0.7
4 -0.6
5 -0.5
6 -0.4
7 -0.3
8 -0.2
9 -0.1
10 +0.0
</pre>
 
 
=={{header|Go}}==
<lang futurebasic>
include "NSLog.incl"
Line 1,425 ⟶ 1,401:
</pre>
 
=={{header|FutureBasicGDScript}}==
<lang GDScript>func mapRange(s:float, a1:float, a2:float, b1:float, b2:float) -> float :
return b1 + ((b2-b1)/(a2-a1))*(s-a1)
 
for i in 11 :
print( "%2d %+.1f" % [i,mapRange(i,0.0,10.0,-1.0,0.0)] )
</lang>
 
{{out}}
<pre>
0 -1.0
1 -0.9
2 -0.8
3 -0.7
4 -0.6
5 -0.5
6 -0.4
7 -0.3
8 -0.2
9 -0.1
10 +0.0
</pre>
 
 
=={{header|Go}}==
<lang futurebasic>
include "NSLog.incl"
Line 1,454:
10 maps to 0.0
</pre>
 
 
=={{header|Go}}==
717

edits