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 16:11:38 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 61 Message-ID: <fl377q$4ip$1@fred.mathworks.com> References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <fjj9nj$fia$1@fred.mathworks.com> <fjk0tg$jli$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1198858298 4697 172.30.248.38 (28 Dec 2007 16:11:38 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 28 Dec 2007 16:11:38 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1223357 Xref: news.mathworks.com comp.soft-sys.matlab:443714 "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <fjk0tg$jli$1@fred.mathworks.com>... > "salih tuna" <salihtuna@gmail.com> wrote in message <fjj9nj$fia > $1@fred.mathworks.com>... > > hello, > > how can i calculate the angles so that they are in the range 0-360 degrees? > > thanks > > salih > > > > "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 > -------- > Y Mehta's question involved angles between vectors in three-dimensional > space. I can think of no reasonable definition for a canonical angle between > such vectors which ranges from 0 to 360 degrees (0 to 2*pi radians.) > > However, if you are in two-dimensional space, then you can speak of the > non-negative angle measured counterclockwise from vector a to vector b, > and this would give the range you have requested. If a = [x1,y1] and b = > [x2,y2], then such an angle is given in matlab by: > > angle = mod(atan2(y2-y1,x2-x1),2*pi); % Range: 0 to 2*pi radians > > (Multiply this answer by 180/pi to get degrees.) > > Roger Stafford 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