View Single Post
Old 04-23-2016, 02:58 AM   #195
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

This is of course not exactly what you want, just looks almost the same.
Saw function is from wikipedia formula I posted above (trigonometric version) and in lua looks like:

Code:
function saw(x,period)
  if x ~= nil and period ~= nil then return 
    0.5-(math.atan(1/math.tan((x*math.pi)/period)))/math.pi
  end
end
(I didn`t short it, just wrote directly as is)

Last edited by mpl; 04-23-2016 at 03:03 AM.
mpl is offline   Reply With Quote