Taking the correct branches of the tangent. Let the center ( P x , P y ) of the rotation have distances d A and d B to the two midpoints. Assuming clockwise rotation (otherwise switch the sign of π π / 2 ):