float cx, cy, cz, sx, sy, sz;
cx = (float) cos((double) g_pCamera->m_Rotation3fv[0]);
cy = (float) cos((double) g_pCamera->m_Rotation3fv[1]);
cz = (float) cos((double) g_pCamera->m_Rotation3fv[2]);
sx = (float) sin((double) g_pCamera->m_Rotation3fv[0]);
sy = (float) sin((double) g_pCamera->m_Rotation3fv[1]);
sz = (float) sin((double) g_pCamera->m_Rotation3fv[2]);
matrix[ 0] = cy * cz;
matrix[ 1] = sx * sy * cz - cx * sz;
matrix[ 2] = cx * sy * cz + sx * sz;
matrix[ 3] = 0.f;
matrix[ 4] = cy * sz;
matrix[ 5] = sx * sy * sz + cx * cz;
matrix[ 6] = cx * sy * sz - sx * cz;
matrix[ 7] = 0.f;
matrix[ 8] = - sy;
matrix[ 9] = sx * cy;
matrix[10] = cx * cy;
matrix[11] = 0.f;
matrix[12] = g_pCamera->m_Position3fv[0];
matrix[13] = g_pCamera->m_Position3fv[1];
matrix[14] = g_pCamera->m_Position3fv[2];
matrix[15] = 1.f;
Rotation around the x and y axis works perfectly, but the z axis rotation only works correctly when the camera faces down the world z axis. Otherwise the more the angle deviates from the world z-axis the more the rotation changes from a z-rotation to an x rotation.
Is there a flaw in my math?
[edited by - MindCode on December 2, 2002 4:31:16 PM]
Eular Rotation Matrix
I'm transforming coordinates into an opengl matrix:
That's just my understanding; I could be wrong.
some things to check:
- order that you do the rotations, i think the typical order is y,x,z
- are you storing your matrix in row or column order? if your storing in row order and then sending this off to OpenGL things will be screwy as gl uses column ordered matricies. just try transposing and see if that fixes the problem.
- order that you do the rotations, i think the typical order is y,x,z
- are you storing your matrix in row or column order? if your storing in row order and then sending this off to OpenGL things will be screwy as gl uses column ordered matricies. just try transposing and see if that fixes the problem.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement