Here side #p# is opposite #/_P#, side #q# is opposite #/_Q# and side #r# is opposite #/_R#.
#cosQ# is then (sum of squares of other (other than #q#) two sides minus square of side opposite #/_Q# i.e #q#) divided by (twice the product of other two sides).