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:
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.
- 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
- Check whether Quadrilateral is valid or not if angles are given
- Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not
- Check whether a given point lies inside a triangle or not
- Check whether a number has exactly three distinct factors or not
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check whether given three numbers are adjacent primes
- Check if the given Prufer sequence is valid or not
- Find whether only two parallel lines contain all coordinates points or not
- Find the point on X-axis from given N points having least Sum of Distances from all other points
- Equation of circle when three points on the circle are given
- Python - Find the maximum number of triangles with given points on three lines
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- 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 2-D points form T-shape or not
- Count of Right-Angled Triangle formed from given N points whose base or perpendicular are parallel to X or Y axis
- Program to check if a date is valid or not
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.