Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Vectors and Matrices Mini Tutorial Date: Thu, 09 Jul 1998 09:46:00 +0100 Organization: Sony Computer Entertainment Europe Lines: 46 Message-ID: <35A48348.930D42AF@scee.sony.co.uk> References: <35A25BBF.F272A126@scee.sony.co.uk> <35a2e6c8.59132342@news.scea.sony.com> <35A349BF.1C739D7D@scee.sony.co.uk> <35a42c22.89797019@news.scea.sony.com> 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) Jamin Frederick wrote: > > But isn't rotation around Z supposed to be (assuming theta goes from X > to Y): > > cos(t) -sin(t) 0 > sin(t) cos(t) 0 > 0 0 1 > > You still have: > > cos(t) sin(t) 0 > -sin(t) cos(t) 0 > 0 0 1 They are both correct! It all depends on which side you are multiplying your 3D vector from. Call your matrix (the top one) A, and my matrix (the bottom one) B, and the vector we're multiplying by C. Assuming C is a 3x1 vector (3 down, 1 across), then A*C will give you another 3x1 vector which is the rotation about the Z axis. But assuming C is a 1x3 vector(3 across, 1 down), then C*B will give you another 1x3 which is ALSO the rotation about the Z axis! In the first version of my tutorial I accidentally mixed both cases, multiplying the vector on the _right_ of the matrix while having matrices which were designed to be multiplied with the vector on the _left_. Now all the matrices in my tutorial are designed to be multiplied by a vector on the left, which is the most common way I've seen in graphics books. If you have a matrix which was designed to be multiplied from the right and you want to turn it into a matrix which can be multiplied from the left (or vice versa), then all you have to do is 'flip' the matrix about the diagonal line running from top left to bottom right (Pedant note: this only works for some matrices, but will work for the standard rotation, scaling and translation matrices we know and love). And we can see that matrix A is just matrix B 'flipped', and vice versa. Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe A diagnostic is someone who doesn't know if there are two Gods.