For help approaching this piece, read the verbogeometry paper, where this piece is the worked example for the midpoint formula.