     if @buttons
       @buttons.setButton @state2id[newState]
 
+
+interpolateHyperbolic = (T) ->
+  [Trot, Tdx, Tdy] = M.hyperbolicDecompose T
+  #Real distance translated is acosh( sqrt(1+dx^2+dy^2))
+  Tr2 = Tdx**2 + Tdy**2
+  Tdist = Math.acosh Math.sqrt(Tr2+1.0)
+  Tr = Math.sqrt Tr2
+  if Tr < 1e-6
+    dirX = 0.0
+    dirY = 0.0
+  else
+    dirX = Tdx / Tr
+    dirY = Tdy / Tr
+
+  return (p) ->
+    rot = Trot * p
+    dist = Tdist * p
+    r = Math.sqrt(Math.cosh(dist)**2-1.0)
+    dx = r*dirX
+    dy = r*dirY
+    
+    M.mul M.translationMatrix(dx, dy), M.rotationMatrix(rot)  
+    
+  
 class Animator
   constructor: ->
     @reset

  if (handler = shortcuts[keyCode])?
    e.preventDefault()
    handler(e)
updateCanvasSize()
updateGrid()
updateMemoryButtons()
updatePlayButtons()
redraw()

updatePopulation = ->
  E('population').innerHTML = ""+cells.count
    

class MouseToolCombo extends MouseTool
  constructor: (@x0, @y0) ->
