The law of cosines is a generalization of the Pythagorean theorem that can be used to find unknown sides or angles of any triangle, not just right triangles. It states that c^2 = a^2 + b^2 - 2abcos粒, where c is the side opposite angle 粒. If 粒 is a right angle, it reduces to the Pythagorean theorem. The law of cosines can be used for triangulation and was developed by early Muslim mathematicians, building on a similar theorem in Euclid's Elements from the 3rd century BC.