I started writing this, as a solution, but I didn't end up on a neat solution (although I am certain it exists). In any case you can find a solution with numerical methods at end. If I find the neater way I will update.
Assuming that :
the end of bar s is point S
the end of bar p is point P
the length of bar p,q,s are respectively $L_p, L_q, L_s$