How to get direction for 3d angles between 2 vectors

28 ビュー (過去 30 日間)
Archa Rajagopalan
Archa Rajagopalan 2019 年 5 月 10 日
コメント済み: Archa Rajagopalan 2019 年 5 月 12 日
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.

採用された回答

James Tursa
James Tursa 2019 年 5 月 10 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by