The law of cosines is a statement about a general triangle which relates the lengths of its sides to the cosine of one of its angles.
The formula can be used to compute the angles of a triangle if the three sides are known. Try dragging points A, B and C.
Law of cosines
Math.pow(CA, 2) = Math.pow(AB, 2) + Math.pow(BC, 2) - 2 * AB * BC * cos(ABC);
ABC = Math.acos((AB * AB + BC * BC - CA * CA) / (2 * AB * BC));
BCA = Math.acos((BC * BC + CA * CA - AB * AB) / (2 * BC * CA));
CAB = Math.acos((AB * AB + CA * CA - BC * BC) / (2 * AB * CA));
See 'Law of cosines - Wikipedia' for more about law of cosines.
sample movie and scripts



Leave a comment