Given an integer m which is the slope of a line, the task is to find the slope of the line which is parallel to the given line.
Input: m = 2
Input: m = -3
Let P and Q be two parallel lines with equations y = m1x + b1, and y = m2x + b2 respectively.Here m1 and m2 are the slopes of the lines respectively. Now as the lines are parallel, they don’t have any intersecting point, and hence there will be no system of solutions for the lines. So, let us try to solve the equations,
For y, m1x + b1 = m2x + b2
m1x – m2x = b2 – b1
x(m1 – m2) = b2 – b1
The only way there can be no solution for x is for m1 – m2 to be equal to zero.
m1 – m2 = 0
This gives us m1 = m2 and the slopes are equal.
Below is the implementation of the above approach:
- Slope of perpendicular to line
- Program to find slope of a line
- Find points at a given distance on a line of given slope
- Find the slope of the given number
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Find the other end point of a line with given one end and mid
- Chain Code for 2D Line
- Reflection of a point about a line in C++
- How to check if two given line segments intersect?
- Count maximum points on same line
- Check if a line passes through the origin
- Perpendicular distance between a point and a Line in 2 D
- Bresenham's Algorithm for 3-D Line Drawing
- Program to find the mid-point of a line
- One line function for factorial of a number
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.