Original Post
🔒 Locked
3d vector => matrix
Advertisement
actually I have 3 vectors that represent the positive x, y, and z axis relative to the object. If I simply perform rotations on the points around axis represented by one of the vectors I should end up rotating around the relative x,y,z axis, correct? So this should work:
right is the x-axis, dir is the z-axis (where the object is facing), and up is the y-axis.
But then how do I convert one of those three vectors (or two of them? or all three?) into a rotation matrix?
~BenDilts( void );
right is the x-axis, dir is the z-axis (where the object is facing), and up is the y-axis.
RotateRelative(float x, float y)
{
D3DXMATRIX m;
D3DXMatrixRotationAxis(&m, &right, D3DXToRadian(x));
D3DXVECTOR4 vec4;
D3DXVec3Transform(&vec4, &dir, &m);
dir.x = vec4.x;
dir.y = vec4.y;
dir.z = vec4.z;
D3DXMatrixRotationAxis(&m, &up, D3DXToRadian(y));
D3DXVec3Transform(&vec4, &dir, &m);
dir.x = vec4.x;
dir.y = vec4.y;
dir.z = vec4.z;
}
But then how do I convert one of those three vectors (or two of them? or all three?) into a rotation matrix?
~BenDilts( void );
I have 3 vectors that represent the positive x, y, and z axis relative to the object
Then you don''t need to perform any further rotations..
PlayerMatrix =
[Xvector.x, Xvector.y, Xvector.z, 0]
[Yvector.x, Yvector.y, Yvector.z, 0]
[Zvector.x, Zvector.y, Zvector.z, 0]
[Xposition, Yposition, Zposition, 1]
- Matt
Then you don''t need to perform any further rotations..
PlayerMatrix =
[Xvector.x, Xvector.y, Xvector.z, 0]
[Yvector.x, Yvector.y, Yvector.z, 0]
[Zvector.x, Zvector.y, Zvector.z, 0]
[Xposition, Yposition, Zposition, 1]
- Matt
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement