From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Angle between two vectors
Date: Fri, 28 Dec 2007 20:50:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 61
Message-ID: <fl3nhq$3tc$>
References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <fjj9nj$fia$> <fjk0tg$jli$> <fl377q$4ip$> <fl3moi$pvc$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1198875002 4012 (28 Dec 2007 20:50:02 GMT)
NNTP-Posting-Date: Fri, 28 Dec 2007 20:50:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1223357
Xref: comp.soft-sys.matlab:443746

"Roger Stafford" 
<> wrote in 
message <fl3moi$pvc$>...
> "baris kazar" <> wrote in 
message <fl377q$4ip
> $>...
> > Hi,-
> >  how can we generalize this to 3-D vectors? Think of a 
> > plane on 3-D space and you have vectors on this plane. 
> > wanna know the angle between 2 vectors in the range 0-
> > or at least -pi to pi. I have 3 vectors. One (First) 
> > vector is the same all the time. I wanna know the 
> > positions of the other two vector wrt the firsy one. 
> > i need angles in the range 0 to 2pi or -pi to pi.
> > Thanks in advance
> ---------
>   As Bruno has pointed out, the angle between two three-
dimensional vectors 
> depends on which sense one gives to a vector orthogonal 
to their plane.  It 
> isn't clear what you meant by, "the relative positions 
of the other two vector 
> wrt the firsy one."  The vector cross product of the 
second two vectors will be 
> a vector orthogonal to their plane.  Perhaps you mean 
that the angle between 
> them is to be considered positive if this cross product 
lies on the same side 
> of the plane as this first vector, and negative 
otherwise.  If that is the case, 
> then let your first, second, and third vectors be 
designated as x, y, and z, 
> respectively.  A matlab formula for calculating the 
angle between y and z will 
> then be:
>  c = cross(y,z);
>  angleyz = sign(dot(x,c))*atan2(norm(c),dot(y,z));
> The value of 'angleyz' will range from -pi to +pi.  If 
you want it to range from 
> 0 to 2*pi, then apply the 'mod' function as I did on 
Dec. 11 in this thread.
> Roger Stafford
Hi Roger,-
  yes, this is one step closer to what i need but not 
exactly. Let's take a numeric example:
x=(1,0,0); y=(1,0,1) and z=(1,0-1)
let's call the angle between x and y theta.
Then i wanna get 2pi-theta for the angle between x and z.
i dont have access y and z at the same time. 
hope that this problem statement is clear.
Thanks much for your reply
Best regards