Extracting the Rotation information from current MODELVIEW matrix

Extracting the Rotation information from current MODELVIEW matrix

Post by djab » Thu, 13 Dec 2001 08:44:35



Hi.

My application needs to draw three lines at the lower left corner of the screen, which
indicates the 3 axis (x,y,z)
The idea is to make these lines represent the rotation status of the axis, so the user
don't loose orientation when rotating the models.
So basically I should save current modelview and projection matrices and reset them, make
a very small viewport, draw my 3 lines representing the 3 axis and restore everything,
including the previous viewport.
That's actually working but the lines are not rotated.
The problem is that these 3 lines must be drawn using the same rotation the system is
using right now, and only that. The current modelview matrix might be filled with scaling
and translations that the user did in his interaction and I must extract from it just the
rotation to draw these 3 lines.
Making the current interaction system give me feedback of the current rotation  will
require some code rewrite. If I could just extract that information from the current
MODELVIEW matrix that wouldn't be necessary...
Any ideas?

Thanks in advance!

 
 
 

Extracting the Rotation information from current MODELVIEW matrix

Post by Dan Pidco » Fri, 21 Dec 2001 02:30:13



>Hi.

>My application needs to draw three lines at the lower left corner of the screen, which
>indicates the 3 axis (x,y,z)
>The idea is to make these lines represent the rotation status of the axis, so the user
>don't loose orientation when rotating the models.

lose not loose.  (sorry one of my greatest spelling irritations on the
net)

Quote:>So basically I should save current modelview and projection matrices and reset them, make
>a very small viewport, draw my 3 lines representing the 3 axis and restore everything,
>including the previous viewport.
>That's actually working but the lines are not rotated.
>The problem is that these 3 lines must be drawn using the same rotation the system is
>using right now, and only that. The current modelview matrix might be filled with scaling
>and translations that the user did in his interaction and I must extract from it just the
>rotation to draw these 3 lines.
>Making the current interaction system give me feedback of the current rotation  will
>require some code rewrite. If I could just extract that information from the current
>MODELVIEW matrix that wouldn't be necessary...
>Any ideas?

I've not tried this but want to do something similar.

If you set the 4th component of the matrix to 0 (1?) that should get
rid of the translation I think.
And then maybe normalising the other 3 components will get rid of any
scaling.
I've not tried this so not sure if it will really work.

Dan
--
remove .hatespam to reply

 
 
 

Extracting the Rotation information from current MODELVIEW matrix

Post by Jeff Dunca » Fri, 21 Dec 2001 05:21:19


The rotation is the 3x3 matrix in the upper left corner of the 4x4 matrix
returned from OpenGL.

If your retrieved matrix is:
A B C D
E F G H
I J K L
M N O P

...then the rotation component is:
A B C
E F G
I J K

As a 4x4 matrix (what you would need to load), this would be:
A B C 0
E F G 0
I J K 0
0 0 0 1

Hopefully that will do something remotely similar to what you're asking
about...
-- Jeff



> >Hi.

> >My application needs to draw three lines at the lower left corner of the
screen, which
> >indicates the 3 axis (x,y,z)
> >The idea is to make these lines represent the rotation status of the
axis, so the user
> >don't loose orientation when rotating the models.

> lose not loose.  (sorry one of my greatest spelling irritations on the
> net)

> >So basically I should save current modelview and projection matrices and
reset them, make
> >a very small viewport, draw my 3 lines representing the 3 axis and
restore everything,
> >including the previous viewport.
> >That's actually working but the lines are not rotated.
> >The problem is that these 3 lines must be drawn using the same rotation
the system is
> >using right now, and only that. The current modelview matrix might be
filled with scaling
> >and translations that the user did in his interaction and I must extract
from it just the
> >rotation to draw these 3 lines.
> >Making the current interaction system give me feedback of the current
rotation  will
> >require some code rewrite. If I could just extract that information from
the current
> >MODELVIEW matrix that wouldn't be necessary...
> >Any ideas?

> I've not tried this but want to do something similar.

> If you set the 4th component of the matrix to 0 (1?) that should get
> rid of the translation I think.
> And then maybe normalising the other 3 components will get rid of any
> scaling.
> I've not tried this so not sure if it will really work.

> Dan
> --
> remove .hatespam to reply

 
 
 

Extracting the Rotation information from current MODELVIEW matrix

Post by Mitch Wolber » Sat, 22 Dec 2001 01:23:49


And if I wanted to set the ModelView to a known position, lets say 45deg
around the Y axis and 35deg around the Z, could I just plug those into
the 3x3 section?

Mitch Wolberg,
RockWare, Inc.


> The rotation is the 3x3 matrix in the upper left corner of the 4x4 matrix
> returned from OpenGL.

> If your retrieved matrix is:
> A B C D
> E F G H
> I J K L
> M N O P

> ...then the rotation component is:
> A B C
> E F G
> I J K

> As a 4x4 matrix (what you would need to load), this would be:
> A B C 0
> E F G 0
> I J K 0
> 0 0 0 1

> Hopefully that will do something remotely similar to what you're asking
> about...
> -- Jeff




> > >Hi.

> > >My application needs to draw three lines at the lower left corner of the
> screen, which
> > >indicates the 3 axis (x,y,z)
> > >The idea is to make these lines represent the rotation status of the
> axis, so the user
> > >don't loose orientation when rotating the models.

> > lose not loose.  (sorry one of my greatest spelling irritations on the
> > net)

> > >So basically I should save current modelview and projection matrices and
> reset them, make
> > >a very small viewport, draw my 3 lines representing the 3 axis and
> restore everything,
> > >including the previous viewport.
> > >That's actually working but the lines are not rotated.
> > >The problem is that these 3 lines must be drawn using the same rotation
> the system is
> > >using right now, and only that. The current modelview matrix might be
> filled with scaling
> > >and translations that the user did in his interaction and I must extract
> from it just the
> > >rotation to draw these 3 lines.
> > >Making the current interaction system give me feedback of the current
> rotation  will
> > >require some code rewrite. If I could just extract that information from
> the current
> > >MODELVIEW matrix that wouldn't be necessary...
> > >Any ideas?

> > I've not tried this but want to do something similar.

> > If you set the 4th component of the matrix to 0 (1?) that should get
> > rid of the translation I think.
> > And then maybe normalising the other 3 components will get rid of any
> > scaling.
> > I've not tried this so not sure if it will really work.

> > Dan
> > --
> > remove .hatespam to reply

 
 
 

Extracting the Rotation information from current MODELVIEW matrix

Post by Jeff Dunca » Sat, 22 Dec 2001 04:53:23


Just make sure you account for the column-major format of OpenGL matrices.
Should do.
-- Jeff


> And if I wanted to set the ModelView to a known position, lets say 45deg
> around the Y axis and 35deg around the Z, could I just plug those into
> the 3x3 section?

> Mitch Wolberg,
> RockWare, Inc.


> > The rotation is the 3x3 matrix in the upper left corner of the 4x4
matrix
> > returned from OpenGL.

> > If your retrieved matrix is:
> > A B C D
> > E F G H
> > I J K L
> > M N O P

> > ...then the rotation component is:
> > A B C
> > E F G
> > I J K

> > As a 4x4 matrix (what you would need to load), this would be:
> > A B C 0
> > E F G 0
> > I J K 0
> > 0 0 0 1

> > Hopefully that will do something remotely similar to what you're asking
> > about...
> > -- Jeff




> > > >Hi.

> > > >My application needs to draw three lines at the lower left corner of
the
> > screen, which
> > > >indicates the 3 axis (x,y,z)
> > > >The idea is to make these lines represent the rotation status of the
> > axis, so the user
> > > >don't loose orientation when rotating the models.

> > > lose not loose.  (sorry one of my greatest spelling irritations on the
> > > net)

> > > >So basically I should save current modelview and projection matrices
and
> > reset them, make
> > > >a very small viewport, draw my 3 lines representing the 3 axis and
> > restore everything,
> > > >including the previous viewport.
> > > >That's actually working but the lines are not rotated.
> > > >The problem is that these 3 lines must be drawn using the same
rotation
> > the system is
> > > >using right now, and only that. The current modelview matrix might be
> > filled with scaling
> > > >and translations that the user did in his interaction and I must
extract
> > from it just the
> > > >rotation to draw these 3 lines.
> > > >Making the current interaction system give me feedback of the current
> > rotation  will
> > > >require some code rewrite. If I could just extract that information
from
> > the current
> > > >MODELVIEW matrix that wouldn't be necessary...
> > > >Any ideas?

> > > I've not tried this but want to do something similar.

> > > If you set the 4th component of the matrix to 0 (1?) that should get
> > > rid of the translation I think.
> > > And then maybe normalising the other 3 components will get rid of any
> > > scaling.
> > > I've not tried this so not sure if it will really work.

> > > Dan
> > > --
> > > remove .hatespam to reply

 
 
 

1. How to get the current modelview matrix

Question :
After having built the modelview matrix,using several matrix
transformations, how to query the state variables in order to get back
the resulting matrix of all the transformations.

Context:
I have defined a scene where the mouse position over the window gives
the position in the scene.In one scene I am using a scale factor,
applied through a matrix transformation, and I would like to applied
the transformation to the mouse position too, that's why I need to
query the OpenGL engine to have the matrix transformation.

Thanks to anybody for the Help.

Julien Valette.

Sent via Deja.com http://www.deja.com/
Before you buy.

2. where do I get music?

3. PLEASE some help needed concerning rotations and the modelview matrix

4. Alien Autopsies, StudioZ RenderRAX III and the JPEG Wizard

5. clipping matrix = projection matrix X modelview matrix ?

6. FTP site for 3D models. Does this exist?

7. Clipping matrix = projection matrix X modelview matrix ?

8. How do I clear the rotation portion of the current matrix

9. Extract angles from rotation matrix

10. Wanted: Algorithm to extract scale/rotation factors from matrix

11. Extracting yaw,pitch,roll from a rotation matrix

12. Extracting rotation angles X,Y,Z from a matrix, with Z set to 0