         p2.y = entityCoordinate(entity2, "bottom") - MARGIN
 
   return [p1,p2]
+
+horizontal_relationship_y_coordinate = (entity1, entity2) ->
+  e1 = entityBox(entity1)
+  e2 = entityBox(entity2)
+  height1 = e1.height()
+  height2 = e2.height()
+  top1 = e1.offset().top
+  top2 = e2.offset().top
+  center1 = top1 + height1 / 2
+  center2 = top2 + height2 / 2
+  offset = center2 - center1
+  offset_max = (height1 + height2) / 2 - MARGIN * 2
+  relationship_coord = center1 + (height1 / 2 - MARGIN) * offset / offset_max
+  return Math.abs(relationship_coord)
+
+vertical_relationship_y_coordinate = (entity1, entity2) ->
+  e1 = entityBox(entity1)
+  e2 = entityBox(entity2)
+  width1 = e1.width()
+  width2 = e2.width()
+  left1 = e1.offset().left
+  left2 = e2.offset().left
+  center1 = left1 + width1 / 2
+  center2 = left2 + width2 / 2
+  offset = center2 - center1
+  offset_max = (width1 + width2) / 2 - MARGIN * 2
+  relationship_coord = center1 + (width1 / 2 - MARGIN) * offset / offset_max
+  return Math.abs(relationship_coord)
 
 closer_to_vertical_than_horizontal = (entity1, entity2) ->
   entity_positions = [[0,0],[0,1],[1,1],[1,0]]

    p2.y = entityCoordinate(entity2, p2.side)

    if fully_vertical(entity1, entity2)
      p1.x = Math.round((center1.x + center2.x) / 2)
      p2.x = p1.x
    else
      if center1.x < center2.x

    $('.entity').on eventType, (event, ui) ->
      drawRelationshipsFromEntity(event.currentTarget)

entityBox = (entity_id) ->
  e = $('#entity' + entity_id).parent()

entityCoordinates = (entity_id, xloc, yloc) ->
  e = entityBox(entity_id)
  x = Math.round(e.offset().left + e.width() * xloc)
  y = Math.round(e.offset().top  + e.height() * yloc)
  return {x:x, y:y}

entityCoordinate = (entity_id, side) ->
  e = entityBox(entity_id)
  switch side
    when "left"   then coord = e.offset().left
    when "right"  then coord = e.offset().left + e.width()
