View Full Version : Decomposing model view matrix

rbalaji

06-20-2002, 07:23 PM

I am manipulating model view matrix myself by

concatenating some trackball rotation to the existing model view matrix. I want to extract the camera's src, dest and up vector from the mv matrix, can anyone know/implemented to get the 3 camera vectors from the mv matrix? pseudo/sample is welcome.

Thanks a lot,

Julien Cayzac

06-20-2002, 11:59 PM

Assuming "ModelView" is a 16-float array holding your matrix:

float9 rotation = upper left part of ModelView;

float9 transpose = transpose of rotation;

vector sight = (0,0,1) transformed by transpose;

vector up = (0,1,0) transformed by transpose;

vector side = (1,0,0) transformed by transpose;

V-man

02-11-2003, 07:05 PM

Hey, I have a similar problem and having difficulty solving it.

Let's say we have something like

glRotatef(....);

glTranslatef(...);

glRotatef(....);

and you end up with a matrix. Has anyone attempted to decompose such a matrix back into the commands?

I'm using Maple to try to solve it but it seems to fail.

gator

02-12-2003, 12:14 PM

For some heavy duty decomposition, see:

Graphic Gem IV

Polar Matrix Decomposition by Ken Shoemaker

decomp/

/* Decompose 4x4 affine matrix A as TFRUK(U transpose), where t contains the

* translation components, q contains the rotation R, u contains U, k contains

* scale factors, and f contains the sign of the determinant.

* Assumes A transforms column vectors in right-handed coordinates.

* See Ken Shoemake and Tom Duff. Matrix Animation and Polar Decomposition.

* Proceedings of Graphics Interface 1992.

*/

I don't really understand what U and K are for, but it seems to work.

V-man

02-13-2003, 08:17 AM

Too bad I don't have that book, but I found a PDF that refrences the Gems book 2 and 4.

Do you have Gems 2? Look at page 320-323.

"Decomposing a matrix into simple transformations"

gator

02-13-2003, 10:55 AM

Thanks, I found the code you were referring to here (unmatrix.c.):

http://www.acm.org/pubs/tog/GraphicsGems/

I haven't tried it yet. Needs some hacking to fit into my

code. Does it work? http://www.opengl.org/discussion_boards/ubb/smile.gif

Maybe this can help : http://www.makegames.com/3Drotation/

Although be careful, it is written for left handed coordinate system and OpenGL's is right handed.

gator

02-13-2003, 01:28 PM

Matrix decomposition and Matrix extraction mean two different things to

me. The original poster was probably looking for some simple matrix

extraction. Just extract the rows or cols whether you are using a LH

or RH matrix. Matrix decomposition was something another poster was after.

As in stripping the matrix down to its purest elements of translation,

rotation, and scale.

MickeyMouse

02-14-2003, 04:20 AM

Originally posted by V-man:

Let's say we have something like

glRotatef(....);

glTranslatef(...);

glRotatef(....);

and you end up with a matrix. Has anyone attempted to decompose such a matrix back into the commands?

How do you imagine solution for this?

You could quite easily find one of them, but there's infinite number of ways of decomposing (no matter how you call it) it to glRotates, glTranslates etc...

You only know start and end points of a dog. It's not enough to say what way did it go to change its position http://www.opengl.org/discussion_boards/ubb/smile.gif

V-man

02-15-2003, 08:36 AM

Originally posted by gator:

Thanks, I found the code you were referring to here (unmatrix.c.):

http://www.acm.org/pubs/tog/GraphicsGems/

I haven't tried it yet. Needs some hacking to fit into my

code. Does it work? http://www.opengl.org/discussion_boards/ubb/smile.gif

It doesn't take much hacking, but I didn't try it out since I don't know what exactly it attempts to do.

The sequence of transformations seems to be

scale, shear, rotate, translate, P(?)

I'm guessing P means project.

Anyway, I think it is solvable because you can start by one of the elements of the matrix and figure out the rest.

When you have

rotate, translate, rotate

the problem becomes immedialty much more difficult. Someone who knows Maple's other packages tried it out for me and the result was 1, meaning no trivial solution.

V-man

02-15-2003, 08:42 AM

Originally posted by MickeyMouse:

How do you imagine solution for this?

You could quite easily find one of them, but there's infinite number of ways of decomposing (no matter how you call it) it to glRotates, glTranslates etc...

I don't imagine! But it's worth looking at the problem and having an algorithm that attempts to find it (by any mean necessary) would be nice to have.

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.