 
     # find the largest depth
     maxDepth = Vec.dotProduct refNorm, reference.deepest
-    trimmed = []
-
-    # make sure the final points are not past this maximum depth
-    unless Vec.dotProduct(refNorm, clipped[0]) - maxDepth < 0
-      trimmed.push clipped[0]
-    unless Vec.dotProduct(refNorm, clipped[1]) - maxDepth < 0
-      trimmed.push clipped[1]
-
-    @debug.trimmed = trimmed
-
-    trimmed
+    contacts = []
+
+    # Calculate depth for each clipped point and return only those which are
+    # nonzero (that is, aren't on the other side of the reference edge)
+    for point in clipped
+      depth = Vec.dotProduct(refNorm, point) - maxDepth
+      if depth >= 0
+        contacts.push new Contact(point, minAxis, depth)
+
+    @debug.contacts = contacts
+
+    contacts
 
   # clip the line segment from v1 to v2 if they are beyond offset along normal
   clip: (v1, v2, normal, offset) ->


    ctx.restore()

window.Rotation =
  fromAngle: (angle) -> [Math.cos(angle), Math.sin(angle)]
  add: ([a,b],[c,d]) -> [a*c - b*d, a*d + c*b]

      Utils.debugLine ctx, inc.from, inc.to, "#66F"
    if clipped = @debug.clipped
      Utils.debugLine ctx, clipped[0], clipped[1], "#FF0"
    if contacts = @debug.contacts
      for contact in contacts
        Utils.debugContact ctx, contact, "#0F0"

  # Calculate contact points against another polygon.
  # from http://www.codezealot.org/archives/394 &c
