We are given co-ordinates of a triangle. The task is to classify this triangle on 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 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
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.