How to calculate direction vector from yaw angle?

风流意气都作罢 提交于 2019-12-05 12:28:48

The rotation portion is a bit more complicated than you have it.

 R = yawMat.pitchMat.rollMat 

where:

    yawMat={ { cosZ, -sinZ, 0 }, { sinZ, cosZ , 0 }, {0,0,1 } };

    pitchMat =  { { cosY , 0 , sinY }, { 0, 1 , 0 }, { -sinY, 0, cosY } };

    rollMat = { {1,0,0 }, {0,cosX,-sinX }, {0,sinX,cosX } };

The dot product of the three is what makes up your 3x3 rotation matrix R inside the homogeneous transform. Order of the dot product does matter so keep it consistent.

Here is my reference.

Final 4x4 matrix should look like

T = {{R00,R01,R02,X},{R10,R11,R12,Y},{R20,R21,R22,Z},{0,0,0,1}}

Edit If you want to do one rotation at a time then the other two 3x3 matrices go to the identity so you would have for instance just a rotation in the yaw:

R = yawMat.I.I = yawMat

So:

R = { { cosZ, -sinZ, 0 }, { sinZ, cosZ , 0 }, {0,0,1 } }

Likewise for the others.

As you have it written in order to build your transformation matrix it should be:

Vector3f xAxis = new Vector3f(
    cosYaw*cosPitch,
    cosYaw* sinPitch*sinRoll - sinYaw*cosRoll,
    cosYaw*sinPitch*cosRoll + sinYaw*sinRoll
);

Vector3f yAxis = new Vector3f(
    sinYaw*cosPitch,
    sinYaw*sinPitch*sinRoll + cosYaw*cosRoll,
    sinYaw*sinPitch*cosRoll - cosYaw*sinRoll
);
Vector3f zAxis = new Vector3f(
    -sinPitch,
    cosPitch*sinRoll,
    cosPitch * cosYaw
);

Assuming fixed rotation order x -> y -> z followed by the translation X,Y,Z

y is always 0

x=sin (yaw)
z=cos (yaw)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!