I have two points, a and b. I need to calculate the angle between them, so I treat them like vectors. However vector a will always be defined as [0 0 0]. Reading over the MATLAB Newsreader, "Angle between two vectors", three solutions are provided:
x1 = 0;
y1 = 0;
z1 = 0;
x2 = 0;
y2 = 1;
z2 = 0;
a = [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 as acos has accuracy problems as theta nears zero, yet out of the three equations, only acos provides the correct solution.
Should I continue to use acos or is there a better solution?