Let x be the length of the horizontal segment on the left, so that the whole horizontal line has length L + x.
Then x is the hypotenuse of the the small right triangle in the bottom left with one leg equal to D, and the whole base L + x is one leg of a large right triangle whose other leg is p.
These two triangles are similar, so the hypotenuse of the larger right triangle is px/D. By Pythagoras, we get
p\^2 + (L + x)\^2 = (px/D)\^2.
Now s = sec a = x/D, so we can rewrite the equation in terms of s:
p\^2 + (L + Ds)\^2 = (ps)\^2, or
(p\^2 - D\^2)s\^2 - 2LDs - (L\^2 + p\^2) = 0
In your picture p > D. In this case, this quadratic equation has only one positive solution s. Then a = arcsin(1/s).