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.
alpha : 90 betta : 45 gamma : 45
This article is contributed by Pratik Chhajer . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Find all angles of a triangle in 3D
- Find other two sides and angles of a right angle triangle
- Program to find the angles of a quadrilateral
- Program to find smallest difference of angles of two parts of a given circle
- Find Perimeter of a triangle
- Program to find Circumcenter of a Triangle
- Program to find the Centroid of the triangle
- Find the dimensions of Right angled triangle
- Find other two sides of a right angle triangle
- Program to find area of a triangle
- Program to find third side of triangle using law of cosines
- Program to find the Radius of the incircle of the triangle
- Find the altitude and area of an isosceles triangle
- Find the hypotenuse of a right angled triangle with given two sides
- Find coordinates of the triangle given midpoint of each side
Improved By : MohitDhariwal