You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Lance Norskog <go...@gmail.com> on 2011/10/14 08:42:32 UTC

Point-to-line / point-to-vector?

Is there an n-dimensional point-to-line or point-to-vector or point-to-ray
distance method somewhere?

Is this the easiest to do?
http://mathforum.org/kb/message.jspa?messageID=1072518&tstart=0

For the truly obsessed: N-dimensional CGI artifacts such as normals,
bounding boxes, etc.
http://www.cs.indiana.edu/pub/hanson/Siggraph01QuatCourse/ggndgeom.pdf

Re: Point-to-line / point-to-vector?

Posted by Ted Dunning <te...@gmail.com>.
>From the original equation that Sean used.

On Fri, Oct 14, 2011 at 10:08 PM, Lance Norskog <go...@gmail.com> wrote:

> Where did Z come from?
>
> On Fri, Oct 14, 2011 at 9:58 AM, Ted Dunning <te...@gmail.com>
> wrote:
>
> > Argh...
> >
> > Make that
> >
> >      c - n \cdot p
> >
> > It always helps to check that points on a line are zero distance from the
> > line.
> >
> > On Fri, Oct 14, 2011 at 9:57 AM, Ted Dunning <te...@gmail.com>
> > wrote:
> >
> > > This form is equivalent to a dot product:
> > >
> > >       n \cdot x = c
> > >
> > > where n is the normalized vector n = (A, B, ...) / | (A, B, ...) |, x
> is
> > > the vector form of the point and c = Z / | n |
> > >
> > > The vector n is unit length and orthogonal to the line and c is the
> > > shortest distance to the origin.
> > >
> > > The distance from point p to the line is just
> > >
> > >      n \cdot p + c
> > >
> > >
> > > On Fri, Oct 14, 2011 at 12:37 AM, Sean Owen <sr...@gmail.com> wrote:
> > >
> > >> I forget what the answer is for the Ax + By + ... = Z form; I should
> > >> really look it up. I missed that day in 6th grade or something.
> > >>
> > >
> > >
> >
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>

Re: Point-to-line / point-to-vector?

Posted by Lance Norskog <go...@gmail.com>.
Where did Z come from?

On Fri, Oct 14, 2011 at 9:58 AM, Ted Dunning <te...@gmail.com> wrote:

> Argh...
>
> Make that
>
>      c - n \cdot p
>
> It always helps to check that points on a line are zero distance from the
> line.
>
> On Fri, Oct 14, 2011 at 9:57 AM, Ted Dunning <te...@gmail.com>
> wrote:
>
> > This form is equivalent to a dot product:
> >
> >       n \cdot x = c
> >
> > where n is the normalized vector n = (A, B, ...) / | (A, B, ...) |, x is
> > the vector form of the point and c = Z / | n |
> >
> > The vector n is unit length and orthogonal to the line and c is the
> > shortest distance to the origin.
> >
> > The distance from point p to the line is just
> >
> >      n \cdot p + c
> >
> >
> > On Fri, Oct 14, 2011 at 12:37 AM, Sean Owen <sr...@gmail.com> wrote:
> >
> >> I forget what the answer is for the Ax + By + ... = Z form; I should
> >> really look it up. I missed that day in 6th grade or something.
> >>
> >
> >
>



-- 
Lance Norskog
goksron@gmail.com

Re: Point-to-line / point-to-vector?

Posted by Ted Dunning <te...@gmail.com>.
Argh...

Make that

      c - n \cdot p

It always helps to check that points on a line are zero distance from the
line.

On Fri, Oct 14, 2011 at 9:57 AM, Ted Dunning <te...@gmail.com> wrote:

> This form is equivalent to a dot product:
>
>       n \cdot x = c
>
> where n is the normalized vector n = (A, B, ...) / | (A, B, ...) |, x is
> the vector form of the point and c = Z / | n |
>
> The vector n is unit length and orthogonal to the line and c is the
> shortest distance to the origin.
>
> The distance from point p to the line is just
>
>      n \cdot p + c
>
>
> On Fri, Oct 14, 2011 at 12:37 AM, Sean Owen <sr...@gmail.com> wrote:
>
>> I forget what the answer is for the Ax + By + ... = Z form; I should
>> really look it up. I missed that day in 6th grade or something.
>>
>
>

Re: Point-to-line / point-to-vector?

Posted by Ted Dunning <te...@gmail.com>.
This form is equivalent to a dot product:

      n \cdot x = c

where n is the normalized vector n = (A, B, ...) / | (A, B, ...) |, x is the
vector form of the point and c = Z / | n |

The vector n is unit length and orthogonal to the line and c is the shortest
distance to the origin.

The distance from point p to the line is just

     n \cdot p + c


On Fri, Oct 14, 2011 at 12:37 AM, Sean Owen <sr...@gmail.com> wrote:

> I forget what the answer is for the Ax + By + ... = Z form; I should
> really look it up. I missed that day in 6th grade or something.
>

Re: Point-to-line / point-to-vector?

Posted by Sean Owen <sr...@gmail.com>.
I always remember the point-to-line formula in vector-land by thinking
of a point A and line through points B and C. The norm of AB x AC is
twice the area of the triangle ABC. Twice the area of the triangle is
also base times height; base is the norm of BC, and height is what you
want. So the distance is norm(AB x AC) / norm(BC).

I forget what the answer is for the Ax + By + ... = Z form; I should
really look it up. I missed that day in 6th grade or something.

Point-to-ray distance is either the distance to the corresponding
line, or the distance to the endpoint -- depends on whether the point
in question lies on the right "side" of that endpoint.

You'd have to define what you mean by point-to-vector. If you mean
distance to a line segment, it's the same argument as for rays but
with two endpoints to think about.

On Fri, Oct 14, 2011 at 7:42 AM, Lance Norskog <go...@gmail.com> wrote:
> Is there an n-dimensional point-to-line or point-to-vector or point-to-ray
> distance method somewhere?
>
> Is this the easiest to do?
> http://mathforum.org/kb/message.jspa?messageID=1072518&tstart=0
>
> For the truly obsessed: N-dimensional CGI artifacts such as normals,
> bounding boxes, etc.
> http://www.cs.indiana.edu/pub/hanson/Siggraph01QuatCourse/ggndgeom.pdf
>