loosing quadrant data using atan2 when finding angle between 3 points (in 3D space) in MATLAB
Ältere Kommentare anzeigen
I want to find the angle between O-F1 and O-Tp. Tp is a point that can vary depending on different inputs. So in the attached diagram I have shown 2 points Tp1 and Tp2. As indicated in the attached figure, the angle output by my code gives me an angle in the range of 0 to 180. However I want the range to be in the form of 0 to 360 or -180 to 180.
Some additional info: the 3 points (O, F1, Tp) lie on a plane formed by three other points(F1, F2 and F3) forming an equilateral triangle. F1 is the chosen reference point for measurement of the angle in clockwise direction. O is the centroid of the triangle.
I have tried several alternate equations and thought of using spherical/cylindrical coordinates. Haven't tried looking up quaternions yet. But I don't think this is supposed to be difficult. I feel I am messing something up.
%calculating unit vectors
v1 = OF1/norm(OF1);
v2 = OTp/norm(OTp);
%Angle Calculation
A = rad2deg(atan2(norm(cross(v1,v2)), dot(v1,v2)))
Picture - 1 = [diagram showing how the output to my code is giving the same angle for different points instead of showing one of them as -173 degrees or -187 degrees]
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!