Equation of a straight line passing through a point and making a given angle with a given line
Given four integers a, b, c and d, representing coefficients of a straight line with equation (ax + by + c = 0), the task is to find the equations of the two straight lines passing through a given point and making an angle α with the given straight line.
Input: a = 2, b = 3, c = -7, x1 = 4, y1 = 9, α = 30
Output: y = -0.49x +10
y = -15.51x + 71
Input: a = 3, b = -2, c = 4, x1 = 3, y1 = 4, α = 55
Output: y = 43.73x -127
y = -0.39x +5
- Let P (x1, y1) be the given point and line LMN (In figure 1) be the given line making an angle θ with the positive x-axis.
- Let PMR and PNS be two required lines which makes an angle (α) with the given line.
- Let these lines meet the x-axis at R and S respectively.
- Suppose line PMR and PNS make angles (θ1) and (θ2) respectively with the positive direction of the x-axis.
- Then using the slope point form of a straight line, the equation of two lines are :
and are the slopes of lines PMR and PNS respectively.
- Now consider triangle LMR:
Using the property: An exterior angle of a triangle is equal to the sum of the two opposite interior angles
- Now consider triangle LNS:
- Now we calculate the value of (tanθ):
slope of given line
- Now substitute the values of (tan(θ1)) and (tan(θ2)) from equations (3) and (4) to equations (1) and (2) to get the final equations of both the lines:
Line PMR :
Line PNS :
Below is the implementation of the above approach:
y = -0.49x +10 y = -15.51x +71
Time Complexity: O(1)
Auxiliary Space: O(1)