C ++计算两个3D矢量之间的角度(0到360)

时间:2017-05-03 01:14:49

标签: c++ math 3d trigonometry angle

假设我有2个3D矢量

Vec3 v1, v2;

v1.x = 203;
v1.y = 355;
v1.z = 922;

v2.x = 6;
v2.y = 13;
v2.z = 198;

我如何计算v1&之间的角度? v2?即最终答案将在0360

之内

我试过

Vec3 angle = v1 - v2;

还有一些其他的东西,但我似乎无法让它正常工作。

1 个答案:

答案 0 :(得分:1)

您需要使用dot product来实现此目标,一旦完成,您就可以关注standard method。 例如:

if (This an intentional behavior of the variadic syntax) {
    Can someone reference some documentation so that I can learn more?
} else if (This a known clang decision or problem) {
    Can someone reference some discussion?
} else {
    Can someone please name the issue / mistake?
}