Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h17g2000yqn.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Cosine between two segment lines
Date: Wed, 22 Jun 2011 00:37:33 -0700 (PDT)
Organization: http://groups.google.com
Lines: 27
Message-ID: <b8a7c1b7-1db1-4dbc-a6af-7231c8ce5fd1@h17g2000yqn.googlegroups.com>
References: <its4te$hap$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 195.18.217.10
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1308728702 8549 127.0.0.1 (22 Jun 2011 07:45:02 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 22 Jun 2011 07:45:02 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h17g2000yqn.googlegroups.com; posting-host=195.18.217.10; posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLEUHCNK
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
 2.0.50727; InfoPath.2; MS-RTC LM 8; .NET CLR 1.1.4322),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:733139

On Jun 22, 9:17 am, "Liana " <liananapalk...@email.arizona.edu> wrote:
> Hi!
>
> My question is the following. There are two segment lines defined by two data sets. I need to know the deviation of the first curve from the second curve. For this purpose I suppose to use cosine angle. I want to go through the segment lines and estimate cosine angle step-by-step in case of any deviation. My code is the following:
>
> data_set1 = [1 1 2; 2 3 4; 2 1 1];
> data_set2 = [1 1 2; 2 4 4; 2 2 1];
> Cosine = dot(data_set1',data_set2')/(norm(data_set1')*norm(data_set2'));
> CosineInDegrees = acos(Cosine)*180/pi;
> Avg = sum(CosineInDegrees)/length(CosineInDegrees);
>
> Please give me a feedback if this is the correct and most efficient solution of the problem.

To check if this is correct, use a simple example
as starting point (e.g. vectors in the (x,y) plane)
and work out the solution by hand. If the results
from the hand computations and your program don't
match, ther is a problem somewhere. (NB: The converse
is *not* true!)

Rune