Given three lines equation,
a1x + b1y + c1 = 0
a2x + b2y + c2 = 0
a3x + b3y + c3 = 0
The task is to check whether the given three lines are concurrent or not. Three straight lines are said to be concurrent if they pass through a point i.e., they meet at a point.
Input : a1 = 2, b1 = -3, c1 = 5 a2 = 3, b2 = 4, c2 = -7 a3 = 9, b3 = -5, c3 = 8 Output : Yes Input : a1 = 2, b1 = -3, c1 = 5 a2 = 3, b2 = 4, c2 = -7 a3 = 9, b3 = -5, c3 = 4 Output : No
a1x + b1y + c1 = 0 ………. (1)
a2x + b2y + c2 = 0 ………. (2)
a3x + b3y + c3 = 0 ………. (3)
Suppose the eqn (i) and (ii) intersets at (x1, y1). Then (x1, y1) will satisfy bothe equations.
Therefore, solving (i) and (ii) using method of cross-multiplication, we get,
(x1/b1c2 – b2c1) = (y1/c1a2 – c2a1) = (1/a1b2 – a2b1)
x1 = (b1c2 – b2c1/a1b2 – a2b1) and
y1 = (c1a2 – c2a1/a1b2 – a2b1), a1b2 – a2b1 != 0
Therefore, the required coodinates of the point of intersection of the lines (i) and (ii) are
(b1c2 – b2c1/a1b2 – a2b1, c1a2 – c2a1/a1b2 – a2b1)
For, three of line to be concurrent, (x1, y1) must satisfy the equation (iii) as well.
a3x + b3y + c3 = 0
=> a3(b1c2 – b2c1/a1b2 – a2b1) + b3(c1a2 – c2a1/a1b2 – a2b1) + c3 = 0
=> a3(b1c2 – b2c1) + b3(c1a2 – c2a1) + c3(a1b2 – a2b1) = 0
So, we only need to check if above condition satisfy or not.
Below is the implemenatation of this 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 two straight lines are orthogonal or not
- Check if given two straight lines are identical or not
- Maximum points of intersections possible among X circles and Y straight lines
- Count of rectangles possible from N and M straight lines parallel to X and Y axis respectively
- Count straight lines intersecting at a given point
- Number of triangles formed from a set of points on three lines
- Python - Find the maximum number of triangles with given points on three lines
- Check whether a straight line can be formed using N co-ordinate points
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Check whether a number has exactly three distinct factors or not
- Check whether triangle is valid or not if three points are given
- Find whether only two parallel lines contain all coordinates points or not
- Number of lines from given N points not parallel to X or Y axis
- Represent a given set of points by the best possible straight line
- Length of the normal from origin on a straight line whose intercepts are given
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Area of triangle formed by the axes of co-ordinates and a given straight line
- Straight-line Number
- Puzzle | Place numbers 1 to 9 in a Circle such that sum of every triplet in straight line is 15
- Check if a number can be written as sum of three consecutive integers
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.