optimize: implement scale and clamp lua functions in C

This commit is contained in:
Glenn Maynard
2005-08-23 06:14:11 +00:00
parent 49466a567d
commit ba8efe82a0
2 changed files with 8 additions and 14 deletions
@@ -30,16 +30,6 @@ function TableMetricLookup( t, group )
return ret
end
-- Scales x so that l1 corresponds to l2 and h1 corresponds to h2.
function scale( x, l1, h1, l2, h2 )
return (((x) - (l1)) * ((h2) - (l2)) / ((h1) - (l1)) + (l2))
end
-- Scales x so that l1 corresponds to l2 and h1 corresponds to h2.
function scale( x, l1, h1, l2, h2 )
return (((x) - (l1)) * ((h2) - (l2)) / ((h1) - (l1)) + (l2))
end
function split( delimiter, text )
local list = {}
local pos = 1
@@ -64,10 +54,6 @@ function join( delimiter, list )
return ret
end
function clamp(val,low,high)
return math.max( low, math.min(val,high) )
end
function wrap(val,n)
local x = val
Trace( "wrap "..x.." "..n )