How can I find the angle between two vectors that answer should be between 0 to 2*pi
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Luca Ferro
el 31 de Mzo. de 2023
Editada: Luca Ferro
el 31 de Mzo. de 2023
0 votos
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.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!