You are given the slope of one line (m1) and you have to find the slope of another line which is perpendicular to the given line.
Input : 5 Output : Slope of perpendicular line is : -0.20 Input : 4 Output : Slope of perpendicular line is : -0.25
Suppose we are given two perpendicular line segments AB and CD. The slope of AB is m1 and line CD is m2 .
m1 * m2 = -1
From above, we can say
m2 = – 1/( m1 ) .
How does above formula work?
Let slope of line AB be m1 and we need to find slope of line CD. Below diagram gives an idea about working of formula.
- Slope of the line parallel to the line with the given slope
- Program to find slope of a line
- Perpendicular distance between a point and a Line in 2 D
- Find points at a given distance on a line of given slope
- Find foot of perpendicular from a point in 2 D plane to a Line
- Length of the perpendicular bisector of the line joining the centers of two circles
- Find the foot of perpendicular of a point in a 3 D plane
- Chain Code for 2D Line
- Find the other end point of a line with given one end and mid
- Reflection of a point about a line in C++
- Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not
- Check whether the point (x, y) lies on a given line
- How to check if two given line segments intersect?
- Represent a given set of points by the best possible straight line
- Program to find the mid-point of a 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.