Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or not
Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6)
Input: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5)
Approach: The key observation in the problem is three points form a triangle only when they don’t lie on the straight line, that is an area formed by the triangle of these three points is not equal to zero.
The above formula is derived from shoelace formula.
So we will check if the area formed by the triangle is zero or not.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check whether triangle is valid or not if sides are given
- Check whether the triangle is valid or not if angles are given
- Check whether right angled triangle is valid or not for large sides
- Count Integral points inside a Triangle
- Program to check if a date is valid or not
- Check if the given Prufer sequence is valid or not
- Check whether Quadrilateral is valid or not if angles are given
- Check if the given Binary Expressions are valid
- Check if the number is valid when flipped upside down
- Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not
- Program to check if three points are collinear
- Check if the given 2-D points form T-shape or not
- How to check if given four points form a square
- Check whether four points make a parallelogram
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check if two people starting from different points ever meet
- Program to check whether 4 points in a 3-D plane are Coplanar
- Check whether a straight line can be formed using N co-ordinate points
- Check if the given point lies inside given N points of a Convex Polygon
- Check if right triangle possible from given area and hypotenuse
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.