Official solution
From Sine Rule
\[{{AB} \over {\sin \theta }} = {{\sqrt {{p^2} + {q^2}} } \over {\sin \left( {\pi - \left( {\theta + \alpha } \right)} \right)}}\]
\[AB = {{\sqrt {{p^2} + {q^2}} \sin \theta } \over {\sin \theta \cos \alpha + \cos \theta \sin \alpha }}\]
\[ = {{\left( {{p^2} + {q^2}} \right)\sin \theta } \over {q\sin \theta + p\cos \theta }}\]
(As \[\cos \alpha = {q \over {\sqrt {{p^2} + {q^2}} }}\] and \[\sin \alpha = {p \over {\sqrt {{p^2} + {q^2}} }}\] )