<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109</link>
    <title>MATLAB Central Newsreader - Vectors</title>
    <description>Feed for thread: Vectors</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by 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>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 12 Nov 2008 12:56:02 -0500</pubDate>
      <title>Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610452</link>
      <author>M K</author>
      <description>I have 4 points of a plane, ABCD .Can i calculate the normal vector,n  of it?&lt;br&gt;
&lt;br&gt;
Is it n= cross(AB,CD)?</description>
    </item>
    <item>
      <pubDate>Wed, 12 Nov 2008 13:10:04 -0500</pubDate>
      <title>Re: Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610453</link>
      <author>M K</author>
      <description>Can the Dot product of two vectors, A and B in Matlab be written as&lt;br&gt;
&lt;br&gt;
dot(A,B)/norm(A)*norm(B)=cos(teta)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;M K&quot; &lt;br&gt;
&lt;br&gt;
&amp;lt;maha_k@mathworks.com&amp;gt; wrote in message &amp;lt;gfejp2$od9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have 4 points of a plane, ABCD .Can i calculate the normal vector,n  of it?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is it n= cross(AB,CD)?</description>
    </item>
    <item>
      <pubDate>Wed, 12 Nov 2008 13:23:02 -0500</pubDate>
      <title>Re: Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610454</link>
      <author>M K</author>
      <description>Sorry I should re-phrase that. &lt;br&gt;
&lt;br&gt;
Calculating the aangle between two vectors. I did a search on this forum and found another thread which gave two ways of calculating it &lt;br&gt;
&lt;br&gt;
1) the usual acos(dot(A,B)/(norm(A)*norm(B))&lt;br&gt;
&lt;br&gt;
2) angle = atan2(norm(cross(a,b)),dot(a,b));&lt;br&gt;
&lt;br&gt;
I get different answers when I use these two ... Any help will be appreciated!</description>
    </item>
    <item>
      <pubDate>Wed, 12 Nov 2008 13:28:01 -0500</pubDate>
      <title>Re: Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610455</link>
      <author>John D'Errico</author>
      <description>&quot;M K&quot; &amp;lt;maha_k@mathworks.com&amp;gt; wrote in message &amp;lt;gfejp2$od9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have 4 points of a plane, ABCD .Can i calculate the normal vector,n  of it?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is it n= cross(AB,CD)?&lt;br&gt;
&lt;br&gt;
Are these 4 points that lie in a plane in how many&lt;br&gt;
dimensions?&lt;br&gt;
&lt;br&gt;
In 3-d, only 3 points determine a plane. Are all 4&lt;br&gt;
points known to lie in the same plane? (If they are&lt;br&gt;
not coplanar, then you cannot determine a normal&lt;br&gt;
vector.)&lt;br&gt;
&lt;br&gt;
So what do you have? Perhaps the simplest solution&lt;br&gt;
to your question is to use null. Assuming that A,B,C,D&lt;br&gt;
are all row vectors, then do this:&lt;br&gt;
&lt;br&gt;
N = null([B-A;C-A;D-A]);&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Wed, 12 Nov 2008 13:31:49 -0500</pubDate>
      <title>Re: Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610456</link>
      <author>John D'Errico</author>
      <description>&quot;M K&quot; &amp;lt;maha_k@mathworks.com&amp;gt; wrote in message &amp;lt;gfekjc$46l$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Can the Dot product of two vectors, A and B in Matlab be written as&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; dot(A,B)/norm(A)*norm(B)=cos(teta)&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
First of all, if you have a new question, put it in a&lt;br&gt;
new thread!&lt;br&gt;
&lt;br&gt;
What is your question anyway?&lt;br&gt;
&lt;br&gt;
The dot product of two vectors is just&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;dot(A,B)&lt;br&gt;
&lt;br&gt;
or if A and B are row vectors, then just&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;A*B'&lt;br&gt;
&lt;br&gt;
Are you trying to compute the cosine of the&lt;br&gt;
angle between the vectors? Why not say it?&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Wed, 12 Nov 2008 18:02:01 -0500</pubDate>
      <title>Re: Vectors</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239109#610527</link>
      <author>Roger Stafford</author>
      <description>&quot;M K&quot; &amp;lt;maha_k@mathworks.com&amp;gt; wrote in message &amp;lt;gfelbm$cc9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Sorry I should re-phrase that. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Calculating the aangle between two vectors. I did a search on this forum and found another thread which gave two ways of calculating it &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1) the usual acos(dot(A,B)/(norm(A)*norm(B))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 2) angle = atan2(norm(cross(a,b)),dot(a,b));&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I get different answers when I use these two ... Any help will be appreciated!&lt;br&gt;
-----------&lt;br&gt;
&amp;nbsp;&amp;nbsp;I assume that you are dealing with three-element vectors in three-dimensional space, with the angle between vectors being regarded as lying somewhere between 0 and pi.  In theory the two formulas you mention should give exactly the same answers.  However, in terms of computational robustness the first formula suffers a loss of accuracy for angles that lie very near either 0 or pi.  The derivative of the 'acos' function approaches infinity at such values and this results in excessive computational errors.  The 'atan2' function avoids this difficulty for all angles in the range.  That might account for the differences you allude to.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;It would help if you could give a concrete example of the a and b vector values and the differences you are seeing between the two formulas' results.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>

