Or we could plot distance[theta] and examine it for a theta which gives a maximum value. And here too we see that at the midpoint between 0 and pi/2, i.e. Pi/4, we attain a maximum distance.
Input :=
Plot[distance[theta],{theta,0, Pi/2}]
Output =
-Graphics-