Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: RotMatrixBUG???? Date: Mon, 06 Jul 1998 11:55:18 +0100 Organization: Sony Computer Entertainment Europe Lines: 65 Message-ID: <35A0AD16.42E3885E@scee.sony.co.uk> References: <01bda686$31300120$4fa1f7c2@manolo> NNTP-Posting-Host: camfw01.millennium.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (Win95; I) To: Emanuele Diotallevi Emanuele Diotallevi wrote: > > Why Rotmatrix function rotate the object on local Z,Y axes and on Daddy's X > axe . > > How we can rotate the object on his X local axe without using RotMatrixX > that has a scale matrix side effect?????? When you call RotMatrix, it creates a single matrix based on the transformation of a rotation about Z, followed by a rotation about Y, followed by a rotation about X. This is what is causing the effect in your demo. What you wanted was a rotation about X followed by a Rotation about Y, which is _not_ what RotMatrix performs. There are two solutions. 1) Create two matrices one using RotMatrixX() and one using RotMatrixY(), then multiply the result together to calculate RotMatrixY() * RotMatrixX(). This is easier to understand, but slower than: 2) Create your own "My_RotMatrix()" function which creates the matrix for you. All you have to do is multiply the the standard Y rotation by the standard X matrix and plug in the appropriate values. This matrix is (according to the Yaroze manuals): cy = cos(y_rotation angle), cx = cos(x_rotation angle), sy = sin(y_rotation angle), etc [cy 0 -sy] [1 0 0] [0 1 0 ] * [0 cx -sx] [sy 0 cy] [0 sx cx] which equals (by my calculation) (and I haven't done matrix multiplication by hand in about 4 years :) [cy -sy*sx -sy*cx] [0 cx -sx ] [sy cy*sx cy*cx] So your function is basically going to look like: void MyRotMatrixXY(SVECTOR *rotation, MATRIX *m) { sx = sin(rotation->vx); // These sin/cos values are between 0 and 4096 cx = cos(rotation->vx); sy = sin(rotation->vy); cy = cos(rotation->vy); m->m[0][0] = cy; m->m[0][1] = -sy*sx; m->m[0][2] = -sy *cx; m->m[1][0] = 0; m->m[1][1] = -cx; m->m[0][2] = -sx; m->m[2][0] = sy; m->m[2][1] = cy*sx; m->m[2][2] = cy *cx; } This, of course, doesn't do any rotation about the Z, but you can see how I've done Y and X, so it's easy to add in the Z one too. Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe If at first you don't succeed, skydiving isn't for you.