This project is read-only.

GetBasis# and m_afEntry

Dec 25, 2012 at 11:34 PM

It's really interesting that you keep the matrix in a 1D array instead of a 2D one or an array of 4 vectors,however I am a little confused on how you extract the matrix basis.Could you if possible comment a bit on that part and

int Matrix4f::I( int iRow, int iCol )
    return( 4*iRow + iCol );
 I've been trying to pull off something similar with a bit different format where the matrix is made of 4 vectors,but couldn't get it to work the same way yet xD

Jan 8, 2013 at 1:54 AM

The basis method call is simply returning the rotation portion of the transformation matrix - there isn't anything very fancy going on there.  Essentially it just returns the 3x3 subset of the overall 4x4 matrix, minus the translation portion.

The index method that you listed above is just a helper notation, where you pass in the row and column indices that you want to access and it returns the linear offset into the 1D array where you need to look.  The matrix classes themselves are used as row matrices in the engine, so every four elements represents one row.  This is purely a convenience method, and doesn't provide any special performance benefits or anything like that.

Does that answer your question?

Jan 10, 2013 at 5:01 AM

Yeah,thanks!If it's not much bother can I also ask you about the difference between your implementation of the Gram-Schmid orthogonalization of a matrix(Matrix3f::Orthonormalize) and the one from the SDK math headers - XMMatrixOrthographicLH(which takes view height,width and near/farZ as arguments).I managed to pull it off for a vector,but not sure about a matrix(the math is weak in me xD).

Jan 11, 2013 at 2:27 PM

I'm not familiar with the XMMatrixOrthographicLH function, but it sounds like a function that produces an orthographic projection matrix.  This is just a different type of projection matrix that doesn't do any perspective warping.  On the other hand, the Orthonormalize function in the Matrix3f class is a more general function.  It is used to ensure that all three of the basis vectors are orthogonal to one another (Ortho-) and that each of them are normalized in length (-normalize).

So these are probably two very different beasts ;)

Jan 14, 2013 at 9:19 PM
Edited Jan 14, 2013 at 9:21 PM

ok I think I got it,I just have to ask - since I can't open the website for the Wild Magic library,do they mean that in "M = [m0|m1|m2], then orthonormal output matrix is Q = [q0|q1|q2]," m# and q# are rows or are they columns?The way i'm doing it now is:

XMVECTOR m0 = rotation.r[0];
XMVECTOR m1 = rotation.r[1];
XMVECTOR m2 = rotation.r[2];

XMVECTOR q0 = m0 / XMVector3Length(m0);

XMVECTOR q1 = (m1-(XMVector3Dot(q0, m1)*q0)/XMVector3Length(m1-XMVector3Dot(q0, m1)*q0));

XMVECTOR q2 = (m2 -(XMVector3Dot(q0, m2)*q0-XMVector3Dot(q1, m2)*q1)/XMVector3Length(m2-XMVector3Dot(q0, m2)*q0-(XMVector3Dot(q1, m2)*q1)));

rotation.r[0] = q0;
rotation.r[1] = q1;
rotation.r[2] = q2;

XMStoreFloat3x3(&entity->Rotation(), rotation);

(where rotation is the XMMATRIX)

Which should be idential(if they meant rows in geometrictools) xD