   Matrix class?
  here is my vector class:class Matrix{public:Matrix(){LoadIdentity();}void LoadIdentity(){for( int i = 0; i < 4; ++i ){for( int j = 0; j < 4; ++j ){if( i == j )m[j] = 1;elsem[j] = 0;}}}void Rotate( float yaw, float pitch, float roll ){float cosYaw = cos( yaw );float sinYaw = sin( yaw );float cosPitch = cos( pitch );float sinPitch = sin( pitch );float cosRoll = cos( roll );float sinRoll = sin( roll );m[0][0] = cosYaw * cosPitch;m[0][1] = cosYaw * sinPitch * sinRoll - sinYaw * cosRoll;m[0][2] = cosYaw * sinPitch * cosRoll + sinYaw * sinRoll;m[1][0] = sinYaw * cosPitch;m[1][1] = sinYaw * sinPitch * sinRoll + cosYaw * cosRoll;m[1][2] = sinYaw * sinPitch * cosRoll - cosYaw * sinRoll;m[2][0] = -sinPitch;m[2][1] = cosPitch * sinRoll;m[2][3] = cosPitch * cosRoll;}void Translate( float x, float y, float z ){m[3][0] = x;m[3][1] = y;m[3][2] = z;}Vector3 Transform( Vector3 vector ){float vec[4];for( int i = 0; i < 4; ++i )vec = m[3];//multiply matrix by vector.. argfor( int i = 0; i < 3; ++i ){for( int j = 0; j < 3; ++j )vec += (m[j] * vector);}return Vector3( vec[0], vec[1], vec[2] );}protected:float m[4][4];};</cpp>i dont know if this is right,but i use it like so:<cpp>Matrix m;m.Rotate( yaw, pitch, roll );//m.Translate( -planex, -planey, -planez );Vector3 trans = m.Transform( Vector3( 0.0f, 0.0f, -1.0f ) );printf("Transform from: %f %f %f, to: %f %f %f\n", 0, 0, -1, trans[0], trans[1], trans[2] );glTranslated( trans[0], trans[1], trans[2] );</cpp>this should, in theorey… rotate the vector (0, 0, -1) around each axis determined by yaw, pitch, and roll… then i wish to translate my object along this axis (im using GL there).but this doesnt work. it causes my object to jerk around as the rotations change. am i doing something wrong?  </i>  
  How about this: //multiply matrix by vector.. argfor( int i = 0; i < 3; ++i ){ for( int j = 0; j < 3; ++j )vec[i] += (m[i][j] * vector[j]);} [edited by - sjelkjd on February 12, 2004 3:16:43 AM];  This may or may not be your problem, but you cannot directly multiply a vector with three components by a 4x4 matrix. You have to use a 4D vector (add a 1 as the w component depending on what you want the result to be), then multiply that by the matrix. Afterwards, you have to divide the resulting x, y, and z components by w to project it back into w = 1. // Vector3 *= Matrix4;Vector3 const& Vector3::operator *= ( Matrix4 const mat ) {// multiply by matrixfloat _x, _y, _z, _w;_x = this->x * mat._11 + this->y * mat._21 + this->z * mat._31 + mat._41;_y = this->x * mat._12 + this->y * mat._22 + this->z * mat._32 + mat._42;_z = this->x * mat._13 + this->y * mat._23 + this->z * mat._33 + mat._43;_w = this->x * mat._14 + this->y * mat._24 + this->z * mat._34 + mat._44;// reproject into w = 1;if( _w != 1.0f ) {float InverseW = 1.0f / _w;_x *= InverseW;_y *= InverseW;_z *= InverseW;}// copy into selfthis->x = _x;this->y = _y;this->z = _z;return *this;};  He''s not using general 4x4 matrices, but only rotate & translate.  Notice how he sets the vector to the translation before multiplying it by the rotation matrix. 