math - Angle between two vectors in Matlab -


i have 2 points, a , b. need calculate angle between them, treat them vectors. vector a defined [0 0 0]. reading on matlab newsreader, "angle between 2 vectors", 3 solutions provided:

x1 = 0; y1 = 0; z1 = 0; x2 = 0; y2 = 1; z2 = 0; = [x1,y1,z1]; b= [x2,y2,z2];  theta = rad2deg(atan2(norm(cross(a,b)),dot(a,b))) theta = rad2deg(acos(dot(a,b))) theta = rad2deg(atan2(x1*y2-x2*y1,x1*x2+y1*y2))  

however acos has accuracy problems theta nears zero, yet out of 3 equations, acos provides correct solution.

should continue use acos or there better solution?

a vector has magnitude , direction, while a , b coordinate points in space. when treat a , b vectors, implicitly defining [0 0 0] origin point 2 vectors. however, since point a @ [0 0 0], vector 0 length.

if vector has 0 length, direction point in? answer nowhere. doesn't point in direction, , can't find angle between , vector.

i think maybe you've defined problem poorly. coordinate system have origin other [0 0 0]? trying find angle between line formed a , b , x-y plane?


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -