Given three integers a, b and c which represents coefficients of the equation of a line a * x + b * y – c = 0. Given two integer points (x1, y1) and (x2, y2). The task is to determine whether the points (x1, y1) and (x2, y2) lie on the same side of the given line or not.
Input : a = 1, b = 1, c = 1, x1 = 1, y1 = 1, x2 = 1, y2 = 2
Output : yes
On applying (x1, y1) and (x2, y2) on a * x + b * y – c, gives 1 and 2 respectively both of which have the same sign, hence both the points lie on same side of the line.
Input : a = 1, b = 1, c = 1, x1 = 1, y1 = 1, x2 = 0, y2 = 0
Output : no
Approach : Apply both the points on given line equation and check if the obtained values belong to same parity 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 a straight line can be formed using N co-ordinate points
- Minimum number of points to be removed to get remaining points on one side of axis
- Count maximum points on same line
- Represent a given set of points by the best possible straight line
- Program to find line passing through 2 Points
- Find X and Y intercepts of a line passing through the given points
- Find points at a given distance on a line of given slope
- Count distinct points visited on the number line
- Number of horizontal or vertical line segments to connect 3 points
- Number of ordered points pair satisfying line equation
- 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 triangle is valid or not if three points are given
- Check whether four points make a parallelogram
- Program to check whether 4 points in a 3-D plane are Coplanar
- Check if two people starting from different points ever meet
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check if a line passes through the origin
- Check whether the point (x, y) lies on a given line
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.