Re: [osg-users] get the x-axis angle of a rotation

2009-06-04 Thread Christian Sam
Hi james,

regarding your last post, did you mean that you also tried to extract angles 
from a rotation with the website's matrixToEuler or a similar approach, but 
you encountered  problems that were depended on your current 
camera-orientation? 

i think the same happened to me: i wanted to get the pitch-angle of the 
camera-orientation, to adjust the camera looking straight forward in certain 
cases. (think of some: reset view, but only for the pitch angle). i encountered 
that multiplying with the inverse rotation matrix of that angle didn't work if 
a left or right camera-rotation has been done before.
(actualy these negative-effects were only obvious when left/right rotation was 
larger than 45°. so i don't know if also minor yaw-rotations did harm, or only 
rotations exceeding a 45° threshold)

in the end, it put out that i had to build the adjustment-rotation matrix not 
with the pitch but the roll angle of the current camera-rotation in cases of 
previous left/right camera-rotations from 45° to 135° (respectively -45° to 
-135°) 

3.)
i'm not sure what you are meaning with ..it was not a success.. 
does the attachment you included work, and won't it suffers from symptoms, like 
described above?


Thanks in advance,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13519#13519





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-04 Thread James Killian

 regarding your last post, did you mean that you also tried to extract
angles from a rotation with the website's matrixToEuler or a similar
approach, but you encountered  problems that were depended on your current
camera-orientation?

It was quat to Euler
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm


 i'm not sure what you are meaning with ..it was not a success..
 does the attachment you included work, and won't it suffers from symptoms,
like described above?

The code is correct to the best of knowledge and of the tests I did, it
worked well.  The problem is that it wasn't compatible to the needs of what
I needed to do.  It has been over a year since I had dealt with it, and so I
don't quite remember the details except to say that it appeared to always
interpret the delta's from a global orientation perspective.  What I needed
is the deltas from its current local perspective, so for example if I just
turned the yaw, and watched the numbers... it looked correct.  The same is
true for the pitch and roll where I would start from the global orientation
and turn one axis exclusively.  Now lets say I apply a 45 angle pitch and
then apply a pure yaw rotation from this new orientation the Euler angles
would interpret that both yaw and pitch were changing, because from a global
orientation they were.

Once I figured out that this wasn't what I needed I finally saw the beauty
of the quaternion and the code snip that I initially sent is what I use
today.


- Original Message - 
From: Christian Sam osgfo...@tevs.eu
To: osg-users@lists.openscenegraph.org
Sent: Thursday, June 04, 2009 1:51 PM
Subject: Re: [osg-users] get the x-axis angle of a rotation


 Hi james,

 regarding your last post, did you mean that you also tried to extract
angles from a rotation with the website's matrixToEuler or a similar
approach, but you encountered  problems that were depended on your current
camera-orientation?

 i think the same happened to me: i wanted to get the pitch-angle of the
camera-orientation, to adjust the camera looking straight forward in certain
cases. (think of some: reset view, but only for the pitch angle). i
encountered that multiplying with the inverse rotation matrix of that angle
didn't work if a left or right camera-rotation has been done before.
 (actualy these negative-effects were only obvious when left/right rotation
was larger than 45°. so i don't know if also minor yaw-rotations did harm,
or only rotations exceeding a 45° threshold)

 in the end, it put out that i had to build the adjustment-rotation matrix
not with the pitch but the roll angle of the current camera-rotation in
cases of previous left/right camera-rotations from 45° to 135°
(respectively -45° to -135°)

 3.)
 i'm not sure what you are meaning with ..it was not a success..
 does the attachment you included work, and won't it suffers from symptoms,
like described above?


 Thanks in advance,
 Christian

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=13519#13519





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-04 Thread Christian Sam
Hi james,

thanks for the quick reply, now everything is clear. 

Best regards,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13531#13531





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] get the x-axis angle of a rotation

2009-06-03 Thread Christian Sam
Hi,

i have a manipulator which stores the rotation in a quaternion. i would like to 
extract the angle of the, in matrix-words, x-axis of that rotation.
(think of a firstperson-view - i would like to extract the angle which defines 
how much i look up/down)

is there an easy way to get this done?


Thanks in advance,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13417#13417





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-03 Thread Maxime BOUCHER
Hi,

Your X-rotation is pure in the quaternion.
In the matrix all rotations in each plane will be mixed and, except in the case 
where Y-rotation and Z-rotation are equal to 0, you will get a very perturbated 
information.

But if you really want to get a matrix, you can declare one and then call the 
setRotate method given your quaternion as parameter.

Cheers,
Maxime

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13422#13422





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-03 Thread Maxime BOUCHER
You really should work with the quaternion.

I tried once to avoid it, it was a very bad idea.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13423#13423





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-03 Thread Christian Sam
Hi max, thanks for the hint

i needed some time to inform myself about quaternions, because like you, i 
tried to avoid using them. 

you mentioned Your X-rotation is pure in the quaternion., nevertheless i 
don't know how to get only the Pitch-rotation (to say it in euler words) out of 
them.

e.g: if the camera first rotates 30° to the right and then 15° down, how can i 
get the information of -15° out of the quaterion?



best regards,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13429#13429





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-03 Thread James Killian

This is how I do it... not sure if it is best, but it works for me:
Everyone feel free to poke holes at this, as I'd like to know what is best.  ;)

The context of this code is for flight dynamics and the class natively works 
with m_QuatToUse.  It only extracts frame size delta's in a form of yaw pitch 
and roll, but everything is preserved in quats.


osg::Vec3d ComputeAngularDistance(const osg::Vec3d lookDir,const osg::Vec3d 
UpDir)
{
 osg::Vec3d ret(0.0,0.0,0.0);
 

 //Default 0,1,0   Yaw,Pitch,Roll
 //Look up negative, down positive
 //Look left negative right positive


 //printf(\r %f %f %f camera   
,lookDir[0],lookDir[1],lookDir[2]);
 osg::Vec3d CurrentOrientation(m_QuatToUse.conj()*lookDir);
 //printf(\r %f %f %f ship   
,CurrentOrientation[0],CurrentOrientation[1],CurrentOrientation[2]);
 ret[0]=atan2(CurrentOrientation[0],CurrentOrientation[1]);  //Angle in radians
 if (CurrentOrientation[1]0.0)
  ret[1]=atan2(CurrentOrientation[2],CurrentOrientation[1]);  //Angle in radians
 else
  ret[1]=atan2(CurrentOrientation[2],-(CurrentOrientation[1]));  //Angle in 
radians

 osg::Vec3d RollOrientation(m_QuatToUse.conj()*UpDir);
 //printf(\r %f %f %f ship   
,RollOrientation[0],RollOrientation[1],RollOrientation[2]);

 ret[2]=atan2(RollOrientation[0],RollOrientation[2]);  //Angle in radians
 //printf(\r %f degrees  ,RAD_2_DEG(RollOffset));
 return ret;
}

- Original Message - 
From: Christian Sam osgfo...@tevs.eu
To: osg-users@lists.openscenegraph.org
Sent: Wednesday, June 03, 2009 6:59 AM
Subject: [osg-users] get the x-axis angle of a rotation


 Hi,
 
 i have a manipulator which stores the rotation in a quaternion. i would like 
 to extract the angle of the, in matrix-words, x-axis of that rotation.
 (think of a firstperson-view - i would like to extract the angle which 
 defines how much i look up/down)
 
 is there an easy way to get this done?
 
 
 Thanks in advance,
 Christian
 
 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=13417#13417
 
 
 
 
 
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 ___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] get the x-axis angle of a rotation

2009-06-03 Thread Christian Sam
Hi,

i had to do a little further research on the web because first i didn't 
understand what your code-snippet is doing. i found a website which describes 
the whole topic: 
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm;
 

thank you james and max for posting the clues/code.
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13462#13462





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org