Pythagoras theorem plays a part and you might like to rotate the square through 90 degrees about B.