Does anyone have the code for the quat2euler fuction?

I am trying to convert a quaternion (Nx4, with a scalar as the first column) to euler angles for various sequences of rotation (ie. XYZ, YXZ, ZXY, etc). I believe there is a function "quat2euler", but I dont have access to that toolbox?

Answers (1)

I would recommend the SpinCalc FEX submission by John Fuller:
I don't recall at the moment if the scalar is in the first or last element for this code ... you should check that before using it.

2 Comments

I have been using that, but there is something off with with how it calculates the angle from my inputs. You are right that the issue has to be the input format. That code defines the quaternion input as "Q - [q1,q2,q3,q4] (Nx4) row vector list defining quaternion of rotation. q4 = cos(MU/2) where MU is Euler rotation angle". Do you know how cos(MU/2) is related to the scalar?
Yes. The cos(etc) spot defines where the scalar is. So if cos(etc) is in the q4 spot, that means that the scalar is in the q4 spot. Which would mean that the q1-q2-q3 spots are sin(etc)*u where u is the 3-element unit eigen-axis of rotation.

Sign in to comment.

Asked:

on 23 Jun 2016

Edited:

on 23 Jun 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!