How the endpoint formula works
If M is the midpoint and A is the known endpoint, then the unknown endpoint B = 2M - A. This works for each coordinate independently: Bx = 2*Mx - Ax, By = 2*My - Ay.
The formula is derived by rearranging the midpoint equation M = (A+B)/2 to solve for B.
B = 2M - A
The missing endpoint equals twice the midpoint minus the known endpoint.