How can I find the angle between two vectors that answer should be between 0 to 2*pi
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Luca Ferro
2023년 3월 31일
편집: Luca Ferro
2023년 3월 31일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!