How can I find angle between two vectors in 3D ranging from 0 to 360 or -180 to +180?

18 Ansichten (letzte 30 Tage)
I already saw some similar questions and applied those answers. But the problem is that I can't get the angle with directional information. For example, I've used atan2d(norm(cross(v1,v2)),dot(v1,v2)) command, but it gave me the angle in between 0 to 180 degree. I want to get the angle ranging from 0 to 360 (-180 to +180 will also work). I will be really grateful if someone helps me in this regard.
NB: the vectors are in 3D space
  3 Kommentare
David Goodmanson
David Goodmanson am 8 Sep. 2018
Hi K M,
How do you define an angle between two 3d vectors to be in the range from -180 to 180? Assume you find the plane such that both vectors lie in that plane. Let's say that in that plane, vector v2 is counterclockwise from vector v1 by 45 degrees. Suppose ccw angles are defined as positive, so the angle is +45. If you go around and look at the plane from the back side, now v2 is clockwise from v1, which is an angle of -45. Both views are equally valid, so how do you distinguish between them?
The only way is to define a unit normal to the plane in some fashion, and to require that the unit normal is pointing e.g. out of the page. The only available unit normal comes from the cross product (v1 x v2). If you orient the plane with that unit normal out of the page, then in that view v2 is always counterclockwise from v1 by an angle between 0 and +180 degrees. A range from -180 to 180 does not happen. Same argument for 0 to 360 since it is merely a constant offset from -180 to 180.
K M RIZWANUR RAHMAN
K M RIZWANUR RAHMAN am 10 Sep. 2018
Thanks a lot guys.. It helped me to find the way to solve the problem.. :) :)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

James Tursa
James Tursa am 31 Mär. 2023

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by