Calculate the angle between multiple points

1 visualización (últimos 30 días)
Laura
Laura el 13 de Jun. de 2013
Comentada: Jess Smith el 3 de Dic. de 2018
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 comentario
Jan
Jan el 13 de Jun. de 2013
There is no "angle between points". Do you mean the angle between two vectors?

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 13 de Jun. de 2013
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 comentarios
Stephen Devlin
Stephen Devlin el 16 de Mzo. de 2018
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 el 3 de Dic. de 2018
@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

Iniciar sesión para comentar.

Más respuestas (1)

michael scheinfeild
michael scheinfeild el 9 de Jul. de 2014
what is v1 v2 can yo give example

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by