whats difference beetween angvel and rotvec?

21 views (last 30 days)
Blazej Dobija
Blazej Dobija on 13 Jul 2020
Answered: Brian Fanous on 24 Jul 2020
As in title. They both seems to do similar job but angvel return odd values that I can not understand where it comes from.
q = quaternion(1,0,0,0);
q0 = quaternion(eul2quat(([0 1 0]),'XYZ'));
angvel(q0,1,'frame',q) % 0 0.9589 0 - undexpected
rotvec(q0) % 0 1.0000 0 - expected

Answers (2)

James Tursa
James Tursa on 15 Jul 2020
Edited: James Tursa on 16 Jul 2020
I don't have a version of MATLAB installed that has the angvel( ) and rotvec( ) functions, so I can only make an educated guess. Can you open up the code for angvel.m or rotvec.m and see what is actually going on? It could be a variation of the following:
For the 'frame' convention, the quaternion is a right-chain Hamilton quaternion. So the derivative of an arbitrary quaternion q in this convention would be:
qdot = (1/2) * q * w
Solving for the angular velocity w gives
w = 2 * q^-1 * qdot
Then suppose you had two different quaternions q1 and q2 and wanted to know the angular velocity that would result in q1 being rotated into q2 in some delta time dt.
A crude numerical approximation to qdot could be:
qdot = deltaq / dt = (q2 - q1) / dt
So you would get the following approximate expression for the angular velocity w:
w = 2 * q1^-1 * (q2 - q1) / dt
Now just plug in your initial quaternion q for q1 and your final quaternion q0 for q2 and you get for your particular case:
w = 2 * q^-1 * (q0 - q) / dt
Then pick off the vector part of the result for the angular velocity vector. E.g.,
>> q = quaternion(1,0,0,0);
>> q0 = quaternion(eul2quat(([0 1 0]),'XYZ'));
>> Q = double(q)';
>> Q0 = double(q0)';
>> dt = 1;
>> 2*quatmultiply(quatinv(Q),(Q0-Q)/dt)
ans =
-0.2448 0 0.9589 0
>> ans(2:4)
ans =
0 0.9589 0
Again, this is all just an educated guess.
Bottom line is this is just a 1st order crude numerical approximation, not an angular rate vector derived from pure rotation principles. For a "large" rotation angle this would give poor results.
For more information on quaternion conventions, see the following links:

Brian Fanous
Brian Fanous on 24 Jul 2020
angvel gives you the angular velocity – essentially, change in orientation over time.
rotvec is simply an alternate expression of orientation (along the lines of Euler angles or a rotation matrix). It is the axis of orientation, scaled by the angle of rotation.

Community Treasure Hunt

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

Start Hunting!