Given the intercepts of a straight line on both the axes as m and n. The task is to find the length of the normal on this straight line from the origin.
Input: m = 5, n = 3
Input: m = 13, n = 9
Approach: A normal to a line is a line segment drawn from a point perpendicular to the given line.
Let p be the length of the normal drawn from the origin to a line, which subtends an angle Θ with the positive direction of x-axis as follows.
Then, we have cos Θ = p / m and sin Θ = p / n
Since, sin2 Θ + cos2 Θ = 1
So, (p / m)2 + (p / n)2 = 1
We get, p = m * n / √(m2 + n2)
Below is the implementation of the above approach:
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Represent a given set of points by the best possible straight line
- Check if a line passes through the origin
- Check if it is possible to draw a straight line with the given direction cosines
- Area of triangle formed by the axes of co-ordinates and a given straight line
- Number of jump required of given length to reach a point of form (d, 0) from origin in 2D plane
- Klee's Algorithm (Length Of Union Of Segments of a line)
- Length of the perpendicular bisector of the line joining the centers of two circles
- Check if three straight lines are concurrent or not
- Check whether two straight lines are orthogonal or not
- Check if given two straight lines are identical or not
- Find K Closest Points to the Origin
- Count of different straight lines with total n points with m collinear
- Find the maximum possible distance from origin using given points
- Lexicographically Kth smallest way to reach given coordinate from origin
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.