当我有 roll pitch 、 yaw 、 len 时,我需要在我的世界空间中计算一个 3d 点。
需要一个像这样的函数为我返回一个 3dpoint :
Get3DpointFrom_yaw_pitch_roll(yaw,pitch,roll,len)
谢谢!
我尝试了这段代码,但问题是当偏航值为 0 时,y 将设置为零!
float x=0,y=0,z=0,r=30;float theta=0; float phi=0;
theta=-Camera_Yaw*3.1415/180;
phi=(3.1415/2)-(-Camera_Pitch*3.1415/180);
x = r*sin(theta)*cos(phi);
y = r*sin(theta)*sin(phi);
z = r*cos(theta);
最佳答案
如果您有球坐标,则变换简单地由下式给出
x = r*sin(theta)*cos(phi)
y = r*sin(theta)*sin(phi)
z = r*cos(theta)
我不从事飞行业务,但如果我正确理解维基百科,那么 theta = yaw
和 phi = pi/2-pitch
。另一方面,不需要滚动角,因为如果你寻找一个点,那么你可以沿着它的轴尽可能多地滚动它,它不会改变它的坐标(刚体的情况不同,当然)。
关于c++ - 如何使用 Yaw、Pitch、Roll 和 len 在我的空间中获取 3D 点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17059641/