[opensource-dev] converting degrees into quaternions

Sophira Crystal sl-dev at theblob.org
Tue Jul 31 05:38:42 PDT 2012


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


More information about the opensource-dev mailing list