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

13 次查看(过去 30 天)
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 个评论
David Goodmanson
David Goodmanson 2018-9-8
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.

请先登录,再进行评论。

回答(1 个)

James Tursa
James Tursa 2023-3-31

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by