[opensource-dev] converting degrees into quaternions

Nexii Malthus nexiim at gmail.com
Tue Jul 31 08:14:33 PDT 2012


Hey Folks,

The C++ codebase doesn't have much to do with LSL, so llEuler2Rot won't
exactly help.

What you are looking for CJ are the helper functions for quaternions, maybe
this one will help:

 const LLQuaternion& setEulerAngles(F32 roll, F32 pitch, F32 yaw);

(form llquaternion<https://bitbucket.org/lindenlab/viewer-release/src/24c6da14256c/indra/llmath/llquaternion.h#cl-83>
)

- Nexii

On Tue, Jul 31, 2012 at 1:38 PM, Sophira Crystal <sl-dev at theblob.org> wrote:

> Hi,
>
> To follow up on this...
>
> The easiest way to do what you want is to make a vector made up of
> <roll, bearing, pitch> in degrees, multiply the vector by DEG_TO_RAD,
> and then put it through llEuler2Rot. You should then have a good
> rotation that you can pass to a function that needs it.
>
> Hope this helps!
>
>  - Sophie.
>
> On Tue, Jul 31, 2012 at 1:29 PM, Sophira Crystal <sl-dev at theblob.org>
> wrote:
> > Hi,
> >
> > You don't convert degrees to quaternions directly. You convert vectors
> > to rotations (which are quarternions), and you do that with the
> > llEuler2Rot function.
> >
> > As for the rest of your query, you might find
> > http://wiki.secondlife.com/wiki/Rotation helpful - I don't know much
> > about rotations, but I bet the answer you want is probably in there
> > somewhere.
> >
> > I hope my reply's been helpful, even though I personally don't know
> much...
> >
> >  - Sophie.
> >
> > On Tue, Jul 31, 2012 at 11:54 AM, CJ Davies <cjohndavies at gmail.com>
> wrote:
> >> I've been struggling with this for 2 days now & am no closer to working
> >> it out (despite investigating all sorts of examples online, including
> >> the SL wiki).
> >>
> >> I have a accelerometer/magnetometer that tells me orientation via
> >> compass bearing, pitch & roll. All of these are in degrees which can
> >> easily be converted to radians via foo*DEG_TO_RAD. I want to plug these
> >> values into llcoordframe methods to control where the camera points. All
> >> of the llcoordframe stuff works in quaternions & I can't for the life of
> >> me convert properly.
> >>
> >> I've just tried following this approach -->
> >>
> http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm
> >>
> >> But this results in output like this --> http://paste2.org/p/2089138
> >>
> >> Note how the calculated w/x/y/z values change drastically with tiny
> >> changes in the bearing/pitch/roll, eg between lines 43 & 50 (the
> >> accelerometer/magnetometer was motionless on the desk at the time!).
> >>
> >> Any help greatly appreciated.
> >>
> >> Regards,
> >> CJ Davies
> >> _______________________________________________
> >> Policies and (un)subscribe information available here:
> >> http://wiki.secondlife.com/wiki/OpenSource-Dev
> >> Please read the policies before posting to keep unmoderated posting
> privileges
> _______________________________________________
> Policies and (un)subscribe information available here:
> http://wiki.secondlife.com/wiki/OpenSource-Dev
> Please read the policies before posting to keep unmoderated posting
> privileges
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/opensource-dev/attachments/20120731/696674a2/attachment.htm 


More information about the opensource-dev mailing list