The D3DXMatrixRotationYawPitchRoll()
function builds a matrix with a specified yaw, pitch, and roll. Is there an equivalent function for iphone developers??
I found a beautiful little sample project for drawing a winding road or rollercoaster here.
It's not a lot of code, and the comments seem mostly understandable, but the code is relying on a few DirectX functions that I'm not yet smart enough to recreate in C for use in my iphone project.
Could someone point me in the right direction here? I need to create a rotation matrix from yaw,pitch,roll values.
This directX function signature is this:
D3DXMATRIX * D3DXMatrixRotationYawPitchRoll(
__inout D3DXMATRIX *pOut,
__in FLOAT Yaw,
__in FLOAT Pitch,
__in FLOAT Roll
);
Is there a glu*() equivalent for this?
(...hours of reading later)
Well, after quite a bit of reading (with lots more to go), this is what I've gathered:
This site was a great help!
It appears that I will need to convert the 3 euler angles (that's what pitch,roll,yaw are called) into three independent unit quaternions:
Qx = [ cos(a/2), (sin(a/2), 0, 0)]
Qy = [ cos(b/2), (0, sin(b/2), 0)]
Qz = [ cos(c/2), (0, 0, sin(c/2))]
And then combine these into one quaternion with:
Qcombined = Qx * Qy * Qz
Then I can convert this resulting "unit" quaternion back to the kind of rotation matrix that openGL will like by doing this:
Matrix = [ 1 - 2y2 - 2z2 2xy - 2wz 2xz + 2wy
2xy + 2wz 1 - 2x2 - 2z2 2yz - 2wx
2xz - 2wy 2yz + 2wx 1 - 2x2 - 2y2 ]