Calculate the angle between multiple points
3 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix A contain x values in the first column and y values in the second column. I want to calculate the angle between vectors.
1 件のコメント
採用された回答
Jan
2013 年 6 月 13 日
The ACOS and the corresponding ASIN approchs are numerically instable near to multiples of pi (half). Better use the more accurate ATAN2 method:
angle = atan2(norm(cross(v1,v2)), dot(v1,v2));
4 件のコメント
Stephen Devlin
2018 年 3 月 16 日
Hi, I have no idea if anyone will see this comment as it is years after the original post, but mathematically what is this expression:
"angle = atan2(abs(det([v1;v2])),dot(v1,v2));"
Jess Smith
2018 年 12 月 3 日
@stephen thats basically doing the inverse tangent of the cross product of 2D vectors over the dot product of those vectors, giving you the angle; cross product of a x b is |a||b|sin(theta) and dot product is |a||b|cos(theta) so dividing them by each other and taking inverse tan is the angle
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!