Square both sides of both the given equations and then add,
a2cos2θ+b2sin2θ+2abcosθsinθ+a2cos2θ+b2sin2θ−2abcosθsinθ=p2+q2
a2(cos2θ+sin2θ)+b2(cos2θ+sin2θ)=p2+q2
a2+b2=p2+q2
If acosθ−bsinθ=c, prove that asinθ+bcosθ=±√a2+b2−c2