   center1 = entityCoordinates(entity1, 0.5, 0.5)
   center2 = entityCoordinates(entity2, 0.5, 0.5)
 
-  if vertical(center1, center2)
+  if closer_to_vertical_than_horizontal(entity1, entity2)
+
     if center1.y < center2.y
       p1.side = "bottom"
       p2.side = "top"

    p1.x = entityCoordinate(entity1, p1.side)
    p2.x = entityCoordinate(entity2, p2.side)

    p1.y = interpolate(center1.x, center1.y, center2.x, center2.y, p1.x)
    p2.y = interpolate(center1.x, center1.y, center2.x, center2.y, p2.x)

  return [p1,p2]

vertical = (coord1, coord2) ->
  return Math.abs(coord1.y - coord2.y) > Math.abs(coord1.x - coord2.x)

# Calculate y3 to pair with given x3 and to make (x3,y3) fall on the line from (x1,y1) to (x2,y2)
interpolate = (x1,y1,x2,y2,x3) ->


  $('#relationship' + relationship).attr('d', svg_path)

MARGIN = 15

relationshipEndpoints = (entity1, entity2) ->
  p1 = {}
  p2 = {}
