Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w7g2000yqc.googlegroups.com!not-for-mail From: Rune Allnor <allnor@tele.ntnu.no> Newsgroups: comp.soft-sys.matlab Subject: Re: Projection of a point over a line Date: Thu, 24 Nov 2011 09:46:38 -0800 (PST) Organization: http://groups.google.com Lines: 30 Message-ID: <bbc677c8-d7e4-479c-b288-d0eeb1e62df3@w7g2000yqc.googlegroups.com> References: <jaluhs$ep8$1@newscl01ah.mathworks.com> NNTP-Posting-Host: 77.19.210.226 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1322156798 14300 127.0.0.1 (24 Nov 2011 17:46:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 24 Nov 2011 17:46:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w7g2000yqc.googlegroups.com; posting-host=77.19.210.226; 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: news.mathworks.com comp.soft-sys.matlab:750379 On 24 Nov, 18:23, "Waleed El-Badry" <wba...@must.edu.eg> 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. Rune