Distance from a point to a line defined in R^N

  • Thread starter heymaniknowyou
  • Start date
  • Tags
    Line Point
In summary, the Euclidean distance from a point to a line formula in \mathbb{R}^n can be found by taking the dot product of the vector connecting the point and a general point on the line with the directional vector of the line, and dividing by the norm of the directional vector. This method can be used in any dimension using projective geometry.
  • #1
heymaniknowyou
3
0
[itex]\frac{}{}[/itex]Hello,

I've been trying to search for a general description for the Euclidean distance from a point to a line formula in [itex]\mathbb{R}^n[/itex]. This line is assumed to be a straight line where a directional vector [itex]f \in \mathbb{R}^n[/itex] is constant and known, and a constant point on the line is known, [itex]y \in \mathbb{R}^n[/itex].

For the 2D and 3D cases this is quite simple. Given a point [itex]X_0 = (x_0,y_0,z_0)[/itex] the distance is [itex]\frac{|f \times (y - X_0)|}{|f|}[/itex] where the cross product is obvious for these cases.

I guess what I'm most unclear on is the cross product in higher dimensions and furthermore the euclidean distance in higher dimensions. I think a general understanding of one will eventually lead into the other.

Thanks for your help.

Best
S
 
Physics news on Phys.org
  • #2
welcome to pf!

hello heymaniknowyou! welcome to pf! :smile:

hint: the general point on the line is y + ft,

and you want y + ft - x to be perpendicular to f :wink:
 
  • #3
Since you mentioned cross products and distance in higher dimensions, I'll expand a little on tiny-tim's answer. The norm [itex]|v|[/itex] of a vector [itex]v[/itex] in Euclidean space of any dimension is defined in terms of the dot product: [itex]|v|^2=v\cdot v[/itex]. Then the distance between vectors is just the norm of their difference: [itex]d(x,y)=|x-y|[/itex].

Cross products are more interesting. For some pretty high-tech reasons, the cross product (i.e. an anti-commutative function that takes two vectors and gives back one vector orthogonal to the given ones) exists only in dimensions 3 and 7. Luckily, as tiny-tim explained, you only need the scalar (dot) product to solve this problem in any dimension.
 
  • #4
Tinyboss said:
… the cross product (i.e. an anti-commutative function that takes two vectors and gives back one vector orthogonal to the given ones) exists only in dimensions 3 and 7.

how does it work in 7 ? :confused:
 
  • #5
It's basically voodoo in 7 dimensions. What people need is the wedge product, not the cross product, and an understanding of dealing with bivectors and other such objects.

It is really, really easy to geometry on objects that don't go through the origin using projective geometry. Consider a 2d space, spanned by basis vectors [itex]e_1, e_2[/itex]. Add one extra dimension with basis vector [itex]e_0[/itex]. The plane that is 1 unit from the origin in the [itex]e_0[/itex] direction is taken to be the real 2d plane.

The convenience of this geometry is that lines in our real 2d plane that don't go through the origin can be thought of as the intersections of 2d subspaces with our real 2d plane. Given two points on our real 2d plane [itex]p[/itex] and [itex]q[/itex], the real line containing them is [itex]L = p \wedge q[/itex], and the shortest distance from that line to the origin is [itex]e_0 \cdot (e_0 \wedge L)[/itex].

There are a lot of symbols here that might not be understood, so let me give an example. Let [itex]L[/itex] be the line through x=1, y=0 and x=0, y=1. By simple geometry, we know that the distance from the origin to this line is [itex]1/\sqrt{2}[/itex]. Let's verify that with projective geometry.

Let [itex]p = e_0 + e_1[/itex] and [itex]q = e_0 + e_2[/itex]. The line [itex]L[/itex] is then [itex]p \wedge q = e_0 \wedge e_2 + e_1 \wedge e_0 = e_{02} + e_{10} + e_{12}[/itex]. First, we find the volume that the 2d subspace makes with [itex]e_0[/itex]. To do this, we just wedge in another [itex]e_0[/itex] on the front:

[tex]e_0 \wedge L = e_0 \wedge (e_{02} + e_{10} + e_{12} = e_{012}[/tex]

And then we find the part of this volume that is perpendicular to [itex]e_0[/itex]. This gives us the "footprint" or "shadow" of the 2d subspace on the real 2d plane. This quantity is called the "moment" [itex]M[/itex] of the line.

[tex]M = e_0 \cdot (e_0 \wedge L) = e_{12}[/tex]

Now, we also need the direction of the line, which is found by [itex]a = e_0 \cdot L = e_0 \cdot (e_{02} + e_{10} + e_{12})= e_2 - e_1 + 0[/itex]. We need this because the moment is made up of two parts: the direction [itex]a[/itex] and a support vector [itex]d[/itex]--which is the vector to the closest point, which is what we're interested in. We just multiply the moment [itex]M[/itex] by [itex]a[/itex] on the right to help extract [itex]d[/itex]. More specifically, we're going to multiply by [itex]a^{-1} \equiv a/a^2[/itex] on the right:

[tex]d = Ma^{-1} =e_{12} (e_2 - e_1)/2 = (e_1 + e_2)/2[/tex]

The length of this vector is clearly [itex]\sqrt{2}/2[/itex], and we've found not only the distance but the vector to this point. You probably already know that vector if you have the equation of the line, but here we've found it just by starting with two points on the line.

We can extend this to arbitrary dimensions because the wedge product (and all of the generalized products used here) is valid in such spaces, where the cross product is not. So we just need the following:

[tex]\begin{align*}M &= e_0 \cdot (e_0 \wedge L) \\
a &= e_0 \cdot L \\
d &= Ma^{-1}
\end{align*}[/tex]

And that's it. This works in any number of dimensions. The projective geometry does introduce a little more overhead and may be a little harder to visualize, but it makes the process of finding the distance to a line (and indeed, to a plane or beyond) very mechanical.

This gives the distance from a line to the origin; translation should be enough to find the distance to an arbitrary point.

(You can also find the line [itex]L[/itex] with a point on the line and a direction also. Everything else follows from that.)
 
  • #6


tiny-tim said:
hello heymaniknowyou! welcome to pf! :smile:

hint: the general point on the line is y + ft,

and you want y + ft - x to be perpendicular to f :wink:

Hmmm. Okay. I definitely got it. Thanks for your help. For some reason I was thinking that the cross product would be the only way to go and I forgot completely about the pretty little dot product. So I just found the projection of (y - x) on f and subtracted that from (y - x), so simple that I can't believe it went over my head. Ha!

Thanks for your help. I appreciate it, also thanks for welcoming me to the community. I've always been a lurker, and never asked any questions or answered any questions, but I think I'll start now. :)

Best
S
 
  • #7
heymaniknowyou said:
… the pretty little dot product …

and so much more friendly :smile: than the cross product!
 
  • #8
tiny-tim said:
and so much more friendly :smile: than the cross product!

:approve: I should have just started with that route for this idea. oh well.
 

FAQ: Distance from a point to a line defined in R^N

1. What is the formula for finding the distance from a point to a line in R^N?

The formula for finding the distance from a point to a line in R^N is:
d = ||(x - x0) - ((x - x0) · n) * n||
where x is a point in R^N, x0 is a point on the line, and n is the unit normal vector to the line.

2. How do you find the unit normal vector to a line in R^N?

The unit normal vector to a line in R^N can be found by taking the cross product of any two non-parallel vectors on the line and normalizing the resulting vector.

3. Can the distance from a point to a line in R^N be negative?

No, the distance from a point to a line in R^N is always positive. If the point is on the line, the distance is 0. If the point is not on the line, the distance is the shortest distance from the point to the line.

4. Is there a simpler way to find the distance from a point to a line in R^N?

Yes, for a line defined by the equation ax + by + c = 0, the distance from a point (x0, y0) to the line can be found using the formula:
d = |ax0 + by0 + c| / √(a² + b²)

5. How is the distance from a point to a line in R^N used in real-world applications?

The distance from a point to a line in R^N is used in various fields such as geometry, engineering, and computer graphics. It can be used to determine the closest distance between an object and a line of sight, or to calculate the shortest distance between a point and a trajectory. It is also used in computer algorithms for collision detection and path planning.

Back
Top