Calculate the angle between multiple points

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
Jan 2013년 6월 13일
There is no "angle between points". Do you mean the angle between two vectors?

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2013년 6월 13일

1 개 추천

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

Roger Stafford
Roger Stafford 2013년 6월 17일
편집: Roger Stafford 2013년 6월 17일
In the two-dimensional x-y plane Mathworks' 'cross' function doesn't work. It requires three-element vectors. The two-dimensional expression should be:
angle = atan2(abs(det([v1;v2])),dot(v1,v2));
where v1 and v2 are assumed to be two-element row vectors.
(Corrected)
Jan
Jan 2013년 6월 18일
@Roger: Thanks! I forgot the limitations of cross.
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
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개)

michael scheinfeild
michael scheinfeild 2014년 7월 9일

0 개 추천

what is v1 v2 can yo give example

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2013년 6월 13일

댓글:

2018년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by