Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Angle between two vectors
Date: Sat, 20 Aug 2011 00:25:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <j2mut5$inu$1@newscl01ah.mathworks.com>
References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <j2mpke$4cu$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1313799909 19198 172.30.248.47 (20 Aug 2011 00:25:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 20 Aug 2011 00:25:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:740665

"Jonathan " <Johnhadida@hotmail.fr> wrote in message <j2mpke$4cu$1@newscl01ah.mathworks.com>...
> "y Mehta" <mehtayogesh@gmail.(DOT).com> wrote in message <ef5ce9c.-1@webcrossing.raydaftYaTP>...
> > How do I find the angle between two unit vectors a and b? I know I
> > can find cosine theta by the following formula:
> > 
> > theta = acos(dot(a,b));
> > 
> > However, how do I know whether the angle is actually theta, or -theta
> > or pi-theta or pi+theta??
> > 
> > Notice that the vectors are in three dimension (3d).
> > 
> > Thanks,
> > -YM
> 
> You don't need to know the angle between [0,2pi]. All you need is:
> angle = acos( dot(a,b) / (norm(a)*norm(b)) );
> 
> Then if you want to rotate:
>  * a towards b: you should rotate a of +'angle' radians around the axis cross(a,b)
>  * b towards a: you should rotate b of +'angle' radians around the axis cross(b,a)
> 
> The cross-product will have the right orientation depending on what you want to do.
- - - - - - - - - - -
  Jonathan, this thread was begun over four years ago and has now stretched to no less than 70 articles.  Moreover it concerns a very elementary subject in which every conceivable aspect of the original question seems to have been thoroughly explored.  Don't you think we ought to let the thread finally come to a peaceful termination?

Roger Stafford