We are given coordinates of a triangle. The task is to classify this triangle on the basis of sides and angle.
Input: p1 = (3, 0), p2 = (0, 4), p3 = (4, 7) Output: Right Angle triangle and Isosceles Input: p1 = (0, 0), p2 = (1, 1), p3 = (1, 2); Output: Triangle is obtuse and Scalene
- We can solve this problem by first calculating the side length and then classifying on comparing of side lengths. Classification by sides is simple, if all sides are equal, triangle will be equilateral, if any two sides are equal triangle will be Isosceles otherwise it will be Scalene.
- Now angle can be classified by Pythagoras theorem, if sum of square of two sides is equal to square of the third side, triangle will be right angle, if less triangle will be acute angle else it will be obtuse angle triangle.
Below is written simple code for classification of triangle:
Triangle is right and Isosceles Triangle is obtuse and Scalene
This article is contributed by Utkarsh Trivedi. 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.
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 coordinates of the triangle given midpoint of each side
- Find the coordinates of a triangle whose Area = (S / 2)
- Check if a right-angled triangle can be formed by the given coordinates
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Find the original coordinates whose Manhattan distances are given
- Find the type of triangle from the given sides
- Find all possible coordinates of parallelogram
- Find whether only two parallel lines contain all coordinates points or not
- Coordinates of rectangle with given points lie inside
- Minimum length of square to contain at least half of the given Coordinates
- 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
- Count of integral coordinates that lies inside a Square
- Maximum Manhattan distance between a distinct pair from N coordinates
- Program to find area of a triangle
- Program to find Circumcenter of a Triangle
- Program to find third side of triangle using law of cosines
- Program to find the Centroid of the triangle
- Program to find the Radius of the incircle of the triangle
- Program to find Area of Triangle inscribed in N-sided Regular Polygon