How can I find the angle between two vectors that answer should be between 0 to 2*pi
17 ビュー (過去 30 日間)
古いコメントを表示
We have two points on a circle in 3D space, as well as the center point. How can we calculate the angle between the vector from the center to point one and the vector from the center to point two, with the calculation starting from vector one counter-clockwise to vector two? In other words, the angle should be calculated such that if our first vector is from (0,0,0) to (0,-1,0) and the second vector is from (0,0,0) to (0,0,-1), the angle should be 270 degrees or 3*pi/2, not 90 degrees.
0 件のコメント
採用された回答
Bjorn Gustavsson
2023 年 3 月 31 日
This question has been answered several times:
angle-betwen-two-3d-vectors-in-the-range-0-360-degree, angle-between-two-vectors-in-matlab. But you should also have a think about why your question isn't sufficiently well stated - what's the positive direction for your angle and why do you chose that direction?
HTH
9 件のコメント
James Tursa
2023 年 3 月 31 日
編集済み: James Tursa
2023 年 3 月 31 日
You still need an independent indicator to define what counter-clockwise means. Otherwise the 0-360 result doesn't make sense. E.g., you can't just pick cross(v1,v2) as this direction since it is not independent. You would always get +90 degrees for the hand example regardless of the hand orientation if you did that. You could pick the initial cross(v1,v2) as the indicator if you had streams of v1's and v2's. That would make sense. But you can't redefine the indicator on the fly this way.
Torsten
2023 年 3 月 31 日
You are right: keeping counterclockwise, the angle changes from 90 to 270 degrees depending on whether you look from above or from below the plane the circle is in.
その他の回答 (1 件)
Luca Ferro
2023 年 3 月 31 日
編集済み: Luca Ferro
2023 年 3 月 31 日
This question is a duplicate of: https://ch.mathworks.com/matlabcentral/answers/16243-angle-between-two-vectors-in-3d
As suggested there you can trya variation like this:
angle=180*atan2(norm(cross(a,b)), dot(a,b))
where a,b are your vectors.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!