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

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

问题描述

因此,基本上,我正在寻找一种使用2个角度来计算向量的x,y和z分量的方法,如下所示: 其中alpha是2D角,beta是y角. 我现在一直在为2D向量使用uptill的是:

So basicly 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数学之后,我发现此论坛实际上无法正常工作:

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天全站免登陆