[Math] Closest Point on 2D Implicit Line

geometry

Consider the infinite line, $L$ in $2D$ consisting of all points $p$ such that $p.[0.3511 0.9263]= 6$. Find the point on the line closest to $(10, 20)$. Find the point on the line closest to $(4, 3)$. Find the distance from the line to both of these points.

Hi, I was reading the book $3D$ Maths Primer for Graphics and Game Development. The book mention about $2$ formulas but I don't know how to apply them.

$\text{Signed distance} = d-q.n$

$q' = q + (d-q.n)n$

for any point $q$, the point $q'$ that is the closest point on $L$ to $q$.

This is what I have tried,

Since the lines are parallel then the normal are the same so

$q' = q + (6 – q(0.3511 0.9263))(0.3511 0.9263)$

I'm stuck here.

Best Answer

If a line is given by $\vec{p}\cdot\vec{n}=d$ where $\vec{p}=(x,y)$ is a point on the line, then $\vec{n}$ is the unit normal vector to the line (perpendicular direction) and $d$ is the minimum distance to the origin. For your case you have $ \vec{p}\cdot(0.3511,0.9263)=6 $, but unfortunately $\vec{n}$ is not a unit vector here. To make it a unit vector you have

$$ \vec{p}\cdot(0.3544,0.9351)=6.0569 $$

with $\vec{n}=(0.3544,0.9351)$ and $ d=6.0569 $. The distance between the point P and the closest point to the line is the perpendicular projection of the difference between P and A where is any point on the line. I choose the point A with coordinates $\vec{a}=\vec{n}\,d=(2.1467,5.6637)$ representing the closest point of the line to the origin. The distance of P with the line is $r=\vec{n}\cdot(\vec{p}-\vec{a})$ or

$$ r = \vec{n}\cdot\vec{p}-d $$

with $r = 16.189 $ for P=(10,20).

The point P' closest to the line is offset from P by $r$, with the equation $\vec{p}'=\vec{p}-\vec{n}\,r = \vec{p}-\vec{n}(\vec{n}\cdot\vec{p}-d) $, or

$$ \vec{p}' = \vec{p}-(\vec{n}\cdot\vec{p}-d)\vec{n} $$

with $\vec{p}'=(4.2621,4.8619)$

Here is the checks I did with GeoGebra.

Line & Point

So proceed similarly with point Q = (4,3) to get Q' and the distance between P' and Q' as 0.415

Second Point

Related Question