Map range: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Changed to Wren S/H) |
(Added Easylang) |
||
Line 1,140: | Line 1,140: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
See [[#Pascal]]. |
See [[#Pascal]]. |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight> |
|||
func map_range a1 a2 b1 b2 s . |
|||
return b1 + (s - a1) * (b2 - b1) / (a2 - a1) |
|||
. |
|||
for i = 0 to 10 |
|||
print i & " -> " & map_range 0 10 -1 0 i |
|||
. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
0 -> -1 |
|||
1 -> -0.90 |
|||
2 -> -0.80 |
|||
3 -> -0.70 |
|||
4 -> -0.60 |
|||
5 -> -0.50 |
|||
6 -> -0.40 |
|||
7 -> -0.30 |
|||
8 -> -0.20 |
|||
9 -> -0.10 |
|||
10 -> 0 |
|||
</pre> |
|||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |
||
EchoLisp provides several native interpolation functions: smoothstep, s-curve, .. and '''linear''' which performs linear interpolation. |
EchoLisp provides several native interpolation functions: smoothstep, s-curve, .. and '''linear''' which performs linear interpolation. |