0
$\begingroup$

I'm getting started with 2D graphics. I've read that a straight line can be expressed as the following implicit equation.

$\vec{N} \cdot \vec{L} + d = 0$

Where, $\vec{N}$ is normal vector and $\vec{L}$ is the position vector for a point on the line. I have confusion with $d$. Is it the distance of the line from the origin along the normal vector or against the normal vector? In other words, for a straight line $\{4\hat x,5\hat y\} \cdot \vec{L} + 4 = 0$ what will be the correct graphical representation, left one or the right one?

d is along the normal d is against the normal

The greenish blue line is the normal and the red one is the intended straight line drawn with cairo-graphics and GTK+.

$\endgroup$
1
$\begingroup$

Hint:

$\vec L$ is a generic vector $(x,y)^T$. Lock at what becomes your equation if $ d=0$, than do the same with a $d \ne 0$.


If $\vec N=(4,5)^T$ ( as in your example) , than for $d=0$ the equation becomes $ 4x+5y=0$ that, as you noted, is the equation of a line that passes thorough the origin since $(0,0)$ satisfies it.

If $d \ne 0$ the equation becomes $4x+5y+d=0$ ad you can see the for $x=0$ the equation is satisfied if $y=-d/5$ so the line intersect the $y$ axis at the point $(0,-d/5)$. In the same way you can find the intercept of the line with the $x$ axis that is $(-d/4,0)$.

If $\vec N=(a,b)$ is a unitary vector ( i.e. $\sqrt{a^2+b^2}=1$) than $|d|$ is the distance of the line from the origin.

This is the simpler interpretation of $d$.

$\endgroup$
  • $\begingroup$ The line will pass though origin if $d$ becomes 0, because then the position vector of any point on the line is perpendicular to the normal vector. But how does that help me finding whether $d$ is calculated along or against the normal? Sorry but I'm new to these. $\endgroup$ – Samik Feb 21 '16 at 16:33
  • $\begingroup$ I've added something to my answer. I hope it's useful. $\endgroup$ – Emilio Novati Feb 21 '16 at 16:44
  • $\begingroup$ I'm struggling with the interpretation here :( that means if $d=4$ the line should pass through $(0, -0.8)$ and $(-1,0)$, but the distance of that line from the origin is not 4, so is $d$ not the distance of the line from the origin? Or is that normalized co-ordinate? $\endgroup$ – Samik Feb 21 '16 at 17:00
  • $\begingroup$ $|d|$ is the distance of the line from the origin only if $|\vec N|=1$ ( added to the answer). $\endgroup$ – Emilio Novati Feb 21 '16 at 19:16
  • $\begingroup$ So a normalized normal makes $d$ the desired distance against the normal from the origin. Thanks, help much appreciated. Plotting is easier with the slope-intercept form as you mentioned. $\endgroup$ – Samik Feb 22 '16 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.