Expand the binomials, then simplify, then invoke the Pythagorean identity:
(p sin(B) - r cos(B))² + (r sin(B) + p cos(B))²
= (p² sin²(B) - 2pr sin(B) cos(B) + r ² cos²(B)) + (r ² sin²(B) + 2pr sin(B) cos(B) + p² cos²(B))
= p² (sin²(B) + cos²(B)) + r ² (cos²(B) + sin²(B))
= p² + r ²