# Deriving a straight line equation from its slope and distance from origin

#### ubisum

##### New member
Hello everyone.
The only data I have about a straight line is its slope and distance from origin.
I know that it's easy to use slope to obtain the angular coefficient m if I want line in the form y + mx +c.
Anyway, I still have no idea about how to find y-intercept c.
Do you know how I could do that?
Alternatively, do you know another way to get line's equation starting from slope and distance?

Thanks for help.

#### Subhotosh Khan

##### Super Moderator
Staff member
Hello everyone.
The only data I have about a straight line is its slope and distance from origin.
I know that it's easy to use slope to obtain the angular coefficient m if I want line in the form y + mx +c.
Anyway, I still have no idea about how to find y-intercept c.
Do you know how I could do that?
Alternatively, do you know another way to get line's equation starting from slope and distance?

Thanks for help.
I am assuming that means - perpendicular distance from the origin.

If that is the case - draw sketch of a line with x-intercept = a and y-intercept = b

m = tan(180 - Θ) = -b/a

Drop a perpendicular from the origin (O) to the line - intersecting at P. We know OP = k (given distance)

and continue .....

#### ubisum

##### New member
I am assuming that means - perpendicular distance from the origin.

If that is the case - draw sketch of a line with x-intercept = a and y-intercept = b

m = tan(180 - Θ) = -b/a

Drop a perpendicular from the origin (O) to the line - intersecting at P. We know OP = k (given distance)

and continue .....

would you explain better how to derive intercept on Y axis, starting from OP distance?

#### ksdhart

##### Full Member
Alright so, if you know the slope of the line, and Subhotosh Khan is correct that by "distance from the origin" you actually mean "perpendicular distance from the origin," then let's look at how to find the y-intercept. One form of a line is: Ax + By + C = 0. If you know the slope, then you know A and B (Remember: the slope is A/B), and the only unknown is the y-intercept, or C. Now you also know the perpendicular distance from the origin. The perpendicular distance from a line to a point (m, n) is:

$$\displaystyle d=\frac{\left|Am+Bn+C\right|}{\sqrt{A^2+B^2}}$$

Plugging in (0,0) as the point, we get:

$$\displaystyle d=\frac{\left|C\right|}{\sqrt{A^2+B^2}}$$

As established, you know A and B, so solve for C using the known distance d.

#### Ishuda

##### Elite Member
Btw, there will always be 2 possible y-intercepts.
Corresponding to the negative y intercept of
C = $$\displaystyle \pm\, d\, * \sqrt{s^2\, +\, 1}$$
where s is the slope of the original line -s x + y + C = 0.

EDIT: Change dumb misteak of s to the proper -s in the equation for the line.

Last edited:

#### ubisum

##### New member
My professor suggested me a solution. He wrote it to me by mail, so I can't tell you how he derived it.
Given the couple <rho, theta>, where rho is the distance from origin and theta is the angle between the line and X axis, he told me to derive line's coefficents acconding to the following formulae:

a = cos(theta)
b = sin(theta)
c = -rho

Using this coefficients, I derived that line must certainly pass through points A(-c/a, 0) and B(0, -c/b).
I should handle cases when a or b are equal to zero, but at the moment I'm just performing a test.

Do you think all this makes sense?

#### ubisum

##### New member
Corresponding to the negative y intercept of
C = $$\displaystyle \pm\, d\, * \sqrt{s^2\, +\, 1}$$
where s is the slope of the original line -s x + y + C = 0.

EDIT: Change dumb misteak of s to the proper -s in the equation for the line.
I divided the expression under the root operator by $$\displaystyle B^2$$ and I got $$\displaystyle B\sqrt{s^2+1}$$. What happened to $$\displaystyle B^2$$ in your calculations?