由 2 个角度定义的 3D 矢量 [英] 3D Vector defined by 2 angles

查看:20
本文介绍了由 2 个角度定义的 3D 矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我正在寻找一种使用 2 个角度计算向量的 x、y 和 z 分量的方法,如下所示:其中 alpha 是 2D 角,beta 是 y 角.到目前为止,我一直在使用的 2D 向量是:

So basically I'm looking for a way to calculate the x, y and z component of a vector using 2 angles as shown: Where alpha is the 2D angle and beta is the y angle. What I've been using uptill now for 2D vectors was:

x = Math.sin(alpha);
z = Math.cos(alpha);

在stackexchange math上搜索后,我发现这个论坛不能正常工作:

After searching on stackexchange math I've found this forumula doesn't really work correctly:

 x = Math.sin(alpha)*Math.cos(beta);
 z = Math.sin(alpha)*Math.sin(beta);
 y = Math.cos(beta);

注意:当以 β 角接近 90 度时,x 和 z 分量应接近零.所有帮助将不胜感激.

Note: when approaching 90 degrees with the beta angle the x and z components should approach zero. All help would be appreciated.

推荐答案

正确的公式是

x = Math.cos(alpha) * Math.cos(beta);
z = Math.sin(alpha) * Math.cos(beta);
y = Math.sin(beta);

这篇关于由 2 个角度定义的 3D 矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆