<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503</link>
    <title>MATLAB Central Newsreader - Find angles between two vectors</title>
    <description>Feed for thread: Find angles between two vectors</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 23 Jan 2008 23:25:04 -0500</pubDate>
      <title>Re: Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410987</link>
      <author>Justin Morehouse</author>
      <description>"Justin Morehouse" &amp;lt;norman_batez@MSN.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fn7egt$447$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
Wow, matlab is pretty neat, thanks for your help guys!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jan 2008 21:16:03 -0500</pubDate>
      <title>Re: Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410961</link>
      <author>Roger Stafford</author>
      <description>"Justin Morehouse" &amp;lt;norman_batez@MSN.com&amp;gt; wrote in message &amp;lt;fn7egt&lt;br&gt;
$447$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi there, I have a two vectors (3,5) and (5,6) and I was &lt;br&gt;
&amp;gt; wondering how do I get the angle between them in matlab.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; on paper I would multiply both vectors to get (15+30) to = &lt;br&gt;
&amp;gt; 45 and then square both (3,5) and (5,6) to get (9+25) and &lt;br&gt;
&amp;gt; (25+36). Then I would get the square root of both (34) and &lt;br&gt;
&amp;gt; (61) and multiply them together  and then divide 45 by that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Afterwhich  I would then use a trusty calc to do cos theta &lt;br&gt;
&amp;gt; of that, but how can math lab do that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
------------&lt;br&gt;
&amp;nbsp;&amp;nbsp;Another possible solution:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;x1 = 3; y1 = 5;&lt;br&gt;
&amp;nbsp;x2 = 5; y2 = 6;&lt;br&gt;
&amp;nbsp;ang = atan2(abs(x1*y2-y1*x2),x1*x2+y1*y2);&lt;br&gt;
&lt;br&gt;
where ang is measured in radians.  (Multiply by 180/pi to get degrees.)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;This method has a slight advantage over the arccosine method.  The acos &lt;br&gt;
function suffers an inherent loss of accuracy near angles 0 and pi, whereas &lt;br&gt;
the atan2 function maintains full accuracy for such cases.  (Make a plot of the &lt;br&gt;
acos curve from -1 to +1 to see why.)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;It is important to distinguish between two possible definitions of an angle &lt;br&gt;
between vectors in the x-y plane.  Above, the angle is considered as a non-&lt;br&gt;
negative quantity lying between 0 and pi.  It can also be defined as the angle &lt;br&gt;
measured counterclockwise from the first vector to the second one, which in &lt;br&gt;
general would be an angle ranging from 0 to 2*pi, or else from -pi to +pi &lt;br&gt;
with clockwise being considered negative.  For this latter meaning one would &lt;br&gt;
remove the 'abs' in the above expression.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jan 2008 14:08:02 -0500</pubDate>
      <title>Re: Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410866</link>
      <author>Anh Huy Phan</author>
      <description>"us " &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fn7gru$7jd$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Justin Morehouse":&lt;br&gt;
&amp;gt; &amp;lt;SNIP many many words...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Hi there, I have a two vectors (3,5) and (5,6) and I &lt;br&gt;
was &lt;br&gt;
&amp;gt; &amp;gt; wondering how do I get the angle between them in matlab.&lt;br&gt;
&amp;gt; &amp;gt; on paper I would multiply both vectors to get (15+30) to &lt;br&gt;
&amp;gt; = &lt;br&gt;
&amp;gt; &amp;gt; 45 and then square both (3,5) and (5,6) to get (9+25) &lt;br&gt;
and &lt;br&gt;
&amp;gt; &amp;gt; (25+36). Then I would get the square root of both (34) &lt;br&gt;
&amp;gt; and &lt;br&gt;
&amp;gt; &amp;gt; (61) and multiply them together  and then divide 45 by &lt;br&gt;
&amp;gt; that.&lt;br&gt;
&amp;gt; &amp;gt; Afterwhich  I would then use a trusty calc to do cos &lt;br&gt;
&amp;gt; theta &lt;br&gt;
&amp;gt; &amp;gt; of that, but how can math lab do that...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ML obeys your words... (as one of the solutions...)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      v1=[3,5];&lt;br&gt;
&amp;gt;      v2=[5,6];&lt;br&gt;
&amp;gt;      a=acosd(dot(v1,v2)/(norm(v1)*norm(v2)))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; us&lt;br&gt;
&lt;br&gt;
The same question was posted and available at the following &lt;br&gt;
address&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.mathworks.com/matlabcentral/newsreader/"&gt;http://www.mathworks.com/matlabcentral/newsreader/&lt;/a&gt;&lt;br&gt;
view_thread/151925&lt;br&gt;
&lt;br&gt;
It is better that you search your topic before posting a &lt;br&gt;
question about it.&lt;br&gt;
&lt;br&gt;
Anh Huy Phan&lt;br&gt;
RIKEN - BSI&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jan 2008 13:53:02 -0500</pubDate>
      <title>Re: Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410859</link>
      <author>us</author>
      <description>"Justin Morehouse":&lt;br&gt;
&amp;lt;SNIP many many words...&lt;br&gt;
&lt;br&gt;
&amp;gt; Hi there, I have a two vectors (3,5) and (5,6) and I was &lt;br&gt;
&amp;gt; wondering how do I get the angle between them in matlab.&lt;br&gt;
&amp;gt; on paper I would multiply both vectors to get (15+30) to &lt;br&gt;
= &lt;br&gt;
&amp;gt; 45 and then square both (3,5) and (5,6) to get (9+25) and &lt;br&gt;
&amp;gt; (25+36). Then I would get the square root of both (34) &lt;br&gt;
and &lt;br&gt;
&amp;gt; (61) and multiply them together  and then divide 45 by &lt;br&gt;
that.&lt;br&gt;
&amp;gt; Afterwhich  I would then use a trusty calc to do cos &lt;br&gt;
theta &lt;br&gt;
&amp;gt; of that, but how can math lab do that...&lt;br&gt;
&lt;br&gt;
ML obeys your words... (as one of the solutions...)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v1=[3,5];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v2=[5,6];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a=acosd(dot(v1,v2)/(norm(v1)*norm(v2)))&lt;br&gt;
&lt;br&gt;
us&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jan 2008 13:34:44 -0500</pubDate>
      <title>Re: Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410854</link>
      <author>tpl@eng.cam.ac.uk (Tim Love)</author>
      <description>"Justin Morehouse" &amp;lt;norman_batez@MSN.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt;Hi there, I have a two vectors (3,5) and (5,6) and I was &lt;br&gt;
&amp;gt;wondering how do I get the angle between them in matlab.&lt;br&gt;
&lt;br&gt;
There's a cart2pol function. Or you could use &lt;br&gt;
angle(complex(5,6)-complex(3,5))&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jan 2008 13:13:01 -0500</pubDate>
      <title>Find angles between two vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503#410850</link>
      <author>Justin Morehouse</author>
      <description>Hi there, I have a two vectors (3,5) and (5,6) and I was &lt;br&gt;
wondering how do I get the angle between them in matlab.&lt;br&gt;
&lt;br&gt;
on paper I would multiply both vectors to get (15+30) to = &lt;br&gt;
45 and then square both (3,5) and (5,6) to get (9+25) and &lt;br&gt;
(25+36). Then I would get the square root of both (34) and &lt;br&gt;
(61) and multiply them together  and then divide 45 by that.&lt;br&gt;
&lt;br&gt;
Afterwhich  I would then use a trusty calc to do cos theta &lt;br&gt;
of that, but how can math lab do that?&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
