From: Rune Allnor <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Projection of a point over a line
Date: Thu, 24 Nov 2011 09:46:38 -0800 (PST)
Lines: 30
Message-ID: <>
References: <jaluhs$ep8$>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: 1322156798 14300 (24 Nov 2011 17:46:38 GMT)
NNTP-Posting-Date: Thu, 24 Nov 2011 17:46:38 +0000 (UTC)
Injection-Info:; posting-host=; posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLUEHNKC
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
 Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022;
 .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe)
Xref: comp.soft-sys.matlab:750379

On 24 Nov, 18:23, "Waleed El-Badry" <> wrote:
> Hi,
> I recently created read an algorithm for finding the coordinates of projected point on a line
> The problem is the formula only works if the line is horizontal and fail in case of vertical or inclined line !
> Do I miss something?

I don't know, as I have no idea how you were
thinking when you wrote that code.

The way to do these kinds of things is to
set up matrix/vector expressions for the
point and the line:

Assume the vector u represents the point and
the vector v represents the line (through origo).

In that case the vector P representing the projected
point is computed as (u and v column vectors)

P = vv'u.

If the line doesn't intersect origo, you need a
modification which is simple if you understood a word
above what I explained above (that is, if you
know linear algebra), and rather uncomprehensable
if not.