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.
- Coordinates of rectangle with given points lie inside
- Minimum number of points to be removed to get remaining points on one side of axis
- Queries on count of points lie inside a circle
- Check whether a straight line can be formed using N co-ordinate points
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Check whether triangle is valid or not if three points are given
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check whether two convex regular polygon have same center or not
- Find whether only two parallel lines contain all coordinates points or not
- Count maximum points on same line
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Number of Integral Points between Two Points
- Prime points (Points that split a number into two primes)
- Find points at a given distance on a line of given slope
- Check whether the point (x, y) lies on a given line
- Find X and Y intercepts of a line passing through the given points
- 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
- 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 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.