Given coordinates of all three vertices of the triangle in the 2D plane, the task is to find all three angles.
Input : A = (0, 0), B = (0, 1), C = (1, 0) Output : 90, 45, 45
To solve this problem we use below Law of cosines.
c^2 = a^2 + b^2 - 2(a)(b)(cos beta)
beta = acos( ( a^2 + b^2 - c^2 ) / (2ab) )
In trigonometry, the law of cosines (also known as the cosine formula or cosine rule) relates the lengths of the sides of a triangle to the cosine of one of its angles.
First, calculate the length of all the sides. Then apply above formula to get all angles in radian. Then convert angles from radian into degrees.
Below is implementation of above steps.