Look at the problem as if it was a parallelogram. It's technically not but the principle will apply. So once you set the distances of A, B, C and D, you need to adjust the sides to bring the diagonals to become equal. In this case, you slide both A and D to the left while maintaining the distances between A/B and C/D. At some point the diagonals will equal and you stop. This will take some iteration but should work.