From: "Loren_Shure" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Angle between two vectors
Date: Mon, 19 Jul 2010 08:21:39 -0400
Organization: MathWorks
Lines: 31
Message-ID: <i21g0k$ker$>
References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <fjj9nj$fia$> <fjk0tg$jli$> <fl377q$4ip$> <fl3moi$pvc$> <i1su0s$deu$> <i1t7en$gvq$> <i1umi8$r2p$> <i1v3gj$8rh$> <i1vcn1$s7p$> <i1vhmb$1rq$> <i1vm13$ok8$>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 8bit
X-Trace: 1279542100 20955 (19 Jul 2010 12:21:40 GMT)
NNTP-Posting-Date: Mon, 19 Jul 2010 12:21:40 +0000 (UTC)
In-Reply-To: <i1vm13$ok8$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:654142

"Roger Stafford" <> wrote in 
message news:i1vm13$ok8$
> "Bard R." <> wrote in message 
> <i1vhmb$1rq$>...
>> This is exactly what I was looking for. And so much more compact than the 
>> solution I had put together during the day. It works if A and B are 
>> opposite (I had to do an extra check for that as well) and for my 
>> application N is by definition never parallell to neither A nor B.
>> Thanx a lot!
>> Bě±…rd
> - - - - - - - - - - - -
>  Well, if A and B, or even their projections, are in opposite directions, 
> the outcome can suddenly flip from one extreme to the other depending on 
> rounding.  A roundoff one way gets +pi as a result and in the other 
> direction flips the answer over to -pi.  I don't see any good way out of 
> that problem.  It is more or less inherent in the nature of numerical 
> computation of angles.  A digital computer cannot even compute the exact 
> value of pi itself.
> Roger Stafford

Have you checked out the function subspace: ?