# [osg-users] Quaternion problem

Antonin Linares Antonin.Linares at onera.fr
Tue Mar 17 07:33:00 PDT 2009

```Hi Steven,

Maybe, i'm not clear, I want to keep the current yaw angle, and change
pitch and roll by the terrain normal.
So i use getRotate to find my previous yaw angle, like you Steven, i
thinks thats not the solution. Maybe i need to store this yaw angle in
custom data.

Hi JP i use osg 2.8 an getRotate seem to returns angle and vector.

Antonin Linares

Steven Saunderson a écrit :
> Hi Antonin,
>
> I may be getting way out of my depth here but when I saw your problem this morning it looked very similar to a problem I had just recently.
>
> Looking at your original post :
>
>
> Antonin Linares wrote:
>
>> //get height and normal under the tank
>> osg::Vec3f pos =
>> lsi->getFirstIntersection()->getWorldIntersectionPoint();
>> osg::Vec3f normal =
>> lsi->getFirstIntersection()->getWorldIntersectionNormal();
>>
>> //Set up height
>> pat->setPosition(pos);
>>
>
> All looks fine so far
>
>
> Antonin Linares wrote:
>
>> //Set up alignment with terrain
>> float rotation;
>> osg::Vec3f origine;
>> pat->getAtitude().getRotate(rotation, origine);
>>
>> if((origine*normal) != 0){
>> osg::Quat corect;
>> corect.makeRotation(origine, normal);
>>
>> pat->setAtitude(corect);
>>
>
>
> I don't understand why you have the getAtitude() here.  It will return a quat and the .getRotate will convert the value into an angle and vector.  But what quat value is it converting ?
>
> What happens if you always calculate "corect" as you are doing and then apply "rot" in the setAtitude call (i.e. pat->setAtitude (rot * corect) ) ?
>
> //Set up alignment with terrain
> float rotation;
> osg::Vec3f origine (0,0,1);
> osg::Quat corect;
> corect.makeRotation(origine, normal);
>
> // I'm not sure where you get rotation from ??????
>
> osg::Quat rot(rotation, origine);
> pat->setAtitude(rot*corect);
>
> I hope this helps or entices someone more knowledgeable to assist here.
>
> ------------------------
> -- Steven Saunderson
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=8598#8598
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>

```