How to get direction for 3d angles between 2 vectors

6 views (last 30 days)
I have 2 3D vectors lying on a 3D plane, and I want to find the angle between them.
How can I find both the angles measured clockwise and counterclockwise (a positive and negative angle)?
I've tried using atan2d(norm(cross(v1,v2)), dot(v1,v2)), as to my understanding returns a negative angle if the angle is greater than 180 deg. However, it still only returns the smallest positive angle that is smaller than 180 deg. Changing the order of v1 and v2 doesn't make a difference either.
Thanks for all replies! I greatly appreciate it.

Accepted Answer

James Tursa
James Tursa on 10 May 2019
You will need to define in your code which direction is the clockwise and which is counterclockwise. You can do that by defining up front a normal vector to your 3D plane that can be used to distinguish this. E.g., something like
PlaneNorm = a 3-element vector defining the normal to the 3D plane for counterclockwise direction
ang = atan2d(norm(cross(v1,v2)), dot(v1,v2)); % angle without regard to "direction"
if( dot(cross(v1,v2),PlaneNorm) < 0 ) % if v1 X v2 is on the other side of the plane
ang = 360 - ang; % modify based on desired "direction"
end

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!