Solve triangles using the law of cosines