   ctx.translate ctx.width/2, -ctx.height/2 # center the origin
 
 class Edge
-  constructor: (@vertex, @from, @to) ->
+  constructor: (@deepest, @from, @to) ->
     @vec = Vec.sub @to, @from
   dot: (other) ->
     Vec.dotProduct @vec, other


    points

  # Calculate the best edge (closest perpendicular edge given a separation axis)
  bestEdge: (minAxis) ->
    points = @points()

    # Find farthest vertex in the polygon along separation axis
    closestIndex = null
    maxProjection = -Infinity
    for vertex, i in points
      projection = Vec.dotProduct minAxis, vertex
      if projection > maxProjection
        maxProjection = projection
        closestIndex = i

    # Find edge which is most perpendicular to separation axis
    closest    = points[closestIndex]
    prevVertex = points[ (closestIndex - 1 + points.length) % points.length ]
    nextVertex = points[ (closestIndex + 1 + points.length) % points.length ]

    left = Vec.sub closest, prevVertex
    right = Vec.sub closest, nextVertex
    if Vec.dotProduct(right, minAxis) <= Vec.dotProduct(left, minAxis)
      new Edge closest, closest, nextVertex # right edge is better
    else
      new Edge closest, prevVertex, closest # left edge is better

  # Use Separating Axis Theorem to find minimum separation axis
  # from http://www.codezealot.org/archives/55 &c.

  controls = new KeyboardControls

  # dot = new Particle [100, ctx.height - 100]
  window.rect = new Rectangle 120, 100, [110, 50], 0, "#F00"
  rect2 = new Rectangle 120, 100, [0, 0], 0, "#00F"

  _.extend ctx,
    update: ->
