Path: news.mathworks.com!not-for-mail 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$1@fred.mathworks.com> References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <fjj9nj$fia$1@fred.mathworks.com> <fjk0tg$jli$1@fred.mathworks.com> <fl377q$4ip$1@fred.mathworks.com> <fl3moi$pvc$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1198875002 4012 172.30.248.35 (28 Dec 2007 20:50:02 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 28 Dec 2007 20:50:02 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1223357 Xref: news.mathworks.com comp.soft-sys.matlab:443746 "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <fl3moi$pvc$1@fred.mathworks.com>... > "baris kazar" <mbkazar.nospam@gmail.com> wrote in message <fl377q$4ip > $1@fred.mathworks.com>... > > 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. I > > wanna know the angle between 2 vectors in the range 0- 2pi. > > or at least -pi to pi. I have 3 vectors. One (First) > > vector is the same all the time. I wanna know the relative > > positions of the other two vector wrt the firsy one. Thus, > > 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