Angle between two vectors 3D? python
<p>I am new in python.
I have two vectors in 3d space, and I want to know the angle between two</p>

<p>I tried:</p>

<pre><code>vec1=[x1,y1,z1]

vec2=[x2,y2,z2]

angle=np.arccos(np.dot(vec1,vec2)/(np.linalg.norm(vec1)*np.linalg.norm(vec2)))
</code></pre>

<p>but when change the order, vec2,vec1 obtain the same angle and no higher.
I want to give me a greater angle when the order of the vectors changes.</p>

<p>Since the dot product is <a href="https://en.wikipedia.org/wiki/Dot_product#Properties" rel="nofollow">commutative</a>, simply reversing the order you put the variables into the function will not work. </p>

<p>If your objective is to find the obtuse(larger) angle rather than the acute(smaller) one, subtract the value returned by your function from 360 degrees. Since you seem to have a criteria for when you want to switch the variables around, you should use that same criteria to determine when to subtract your found value from 360. This will give you the value you are looking for in these cases. </p>

python python-2.7 numpy computational-geometry