Sign in to follow this  
dawidjoubert

Undo-Matrix Transform?

Recommended Posts

Okay great, so you transform a vector by the matrix. I do it like this
/*For this one i copied source from my old code, not to sure if its correct*/
// Input,matrix & vector
__declspec(dllexport) void mTransform(float *m,float &x,float &y,float &z)
{
	float tvx,tvy,tvz;
	tvx = x*m[0]+y*m[4]+z*m[8]  + m[12];
	tvy = x*m[1]+y*m[5]+z*m[9]  + m[13];
	tvz = x*m[2]+y*m[6]+z*m[10] + m[14];
	x = tvx;
	y = tvy;
	z = tvz;
}

Now I wrote this down on paper, tried some algebra and realised.. Hell no, it's not happening that way, atleast not on 2 a4 sides. So according to theory if i Invert the matrix M I can just apply the same transform (backwardly). Anyone has some source code on inversing a matrix 4x4?

Share this post


Link to post
Share on other sites
Search for something like 'inverse matrix' here on GDNet.

I found this.

Im not absolutely sure but from looking at your transform function there I think you might be able to optimise and get away with simply inverting the translation vector in the matrix then finding the inverse of the 3x3 rotation sub-matrix. Im sure somebody else here can confirm/deny that for you though.

Share this post


Link to post
Share on other sites
Well, there's a method to invert a matrix. Call A the matrix and B it's inverse.

If you do several operations over A's lines to get the indentity matrix, you can do those same operations on the identity to get to B. The problem is you shouldn't have floats and doubles in the matrix, this way, or you will lose precision. I once created an algorithm to echelon a matrix (or however you call it in english), but it was out of my mind, not using those more efficient stuff out there.

Share this post


Link to post
Share on other sites
Assuming you are using those matrix transformations for graphics you could always undo transform based on how the matrix was created. For instance if its a rotation matrix by 45 degrees, just use a rotation matrix by -45 degrees ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this