code: function getDistanceVector(position1, position2) {
    if (position1 && position2) {
      var x1 = position1.x,
          y1 = position1.y;
      var x2 = position2.x,
          y2 = position2.y;
  
  
      return { x: x2 - x1, y: y2 - y1 };
    } else {
      return { x: 0, y: 0 };
    }
  }
docs: Calculate the distance from the origin position to the destination position.