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 firstname.lastname@example.org. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find all angles of a triangle in 3D
- Find other two sides and angles of a right angle triangle
- Check whether the triangle is valid or not if angles are given
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Program to find smallest difference of angles of two parts of a given circle
- Program to find the angles of a quadrilateral
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- Check whether Quadrilateral is valid or not if angles are given
- Check if an N-sided Polygon is possible from N given angles
- Sum of internal angles of a Polygon
- Sum of upper triangle and lower triangle
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Program to print a Hollow Triangle inside a Triangle
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Sum of all the numbers present at given level in Modified Pascal’s triangle
- Program to find the Type of Triangle from the given Coordinates
- Find coordinates of the triangle given midpoint of each side
- Find area of triangle if two vectors of two adjacent sides are given
- Find the hypotenuse of a right angled triangle with given two sides