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
- Ways to choose three points with distance between the most distant points <= L
- 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
- Program to check if three points are collinear
- 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
- Find whether only two parallel lines contain all coordinates points or not
- Check if the given Prufer sequence is valid or not
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- 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
- Minimum area of a Polygon with three points given
- Check whether four points make a parallelogram
- Program to check whether 4 points in a 3-D plane are Coplanar
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.