1

I recently had to convert euler rotation rates to vectorial angular velocity. From what I understand, in a local referential, we can express the vectorial angular velocity by:

R = [rollRate, pitchRate, yawRate] (which is the correct order relative to the referential I want to use).

I also know that we can convert angular velocities to rotations (quaternion) for a given time-step via:

alpha = |R| * ts
nR = R / |R| * sin(alpha) <-- normalize and multiply each element by sin(alpha)
Q = [nRx i, nRy j, nRz k, cos(alpha)]

When I test this for each axis individually, I find results that I totally expect (i.e. 90°pitch/time-unit for 1 time unit => 90° pitch angle).

When I use two axes for my rotation rates however, I don't fully understand the results:

For example, if I use rollRate = 0, pitchRate = 90, yawRate = 90, apply the rotation for a given time-step and convert the resulting quaternion back to euler, I obtain the following results:

(ts = 0.1)  Roll:  0.712676, Pitch:  8.96267, Yaw:   9.07438
(ts = 0.5)  Roll: 21.058,    Pitch: 39.3148,  Yaw:  54.9771
(ts = 1.0)  Roll: 76.2033,   Pitch: 34.2386,  Yaw: 137.111

I Understand that a "smooth" continuous rotation might change the roll component mid way.

What I don't understand however is after a full unit of time with a 90°/time-unit pitchRate combined with a 90°/time-unit yawRate I end up with these pitch and yaw angles and why I still have roll (I would have expected them to end up at [0°, 90°, 90°].

I am pretty confident on both my axis + angle to quaternion and on my quaternion to euler formulas as I've tested these extensively (both via unit-testing and via field testing), I'm not sure however about the euler rotation rate to angular-velocity "conversion".

My first bet would be that I do not understand how euler rotation-rates axes interacts on themselves, my second would be that this "conversion" between euler rotation-rates and angular velocity vector is incorrect.

Axel Paccalin
  • 136
  • 1
  • 13

1 Answers1

1

Euler angles are not good way of representing arbitrary angular movement. Its just a simplification used for graphics,games and robotics. They got some pretty hard restrictions like your rotations consist of only N perpendicular axises in ND space. That is not how rotation works in real world. On top of this spherical representation of reper endpoint it creates a lot of singularities (you know when you cross poles ...).

The rotation movement is analogy for translation:

position       speed                    acceleration
pos = Integral(vel) = Integral(Integral(acc))
ang = Integral(omg) = Integral(Integral(eps))

That in some update timer can be rewritten to this:

vel+=acc*dt; pos+=vel*dt;
omg+=eps*dt; ang+=omg*dt;

where dt is elapsed time (Timer interval).

The problem with rotation is that you can not superimpose it like translation. As each rotation has its own axis (and it does not need to be axis aligned, nor centered) and each rotation affect the axis orientation of all others too so the order of them matters a lot. On top of all this there is also gyroscopic moment creating 3th rotation from any two that has not parallel axis. Put all of this together and suddenly you see Euler angles does not match the real geometrics/physics of rotation. They can describe orientation and fake its rotation up to a degree but do not expect to make real sense once used for physic simulation.

The real simulation would require list of rotations described by the axis (not just direction but also origin), angular speed (and its change) and in each simulation step the recomputing of the axis as it will change (unless only single rotation is present).

This can be done by using coumulative homogenous transform matrices along with incremental rotations.

Sadly the majority of programmers prefers Euler angles and Quaternions simply by not knowing that there are better and simpler options and once they do they stick to Euler angles anyway as matrix math seem to be more complicated to them... That is why most nowadays games have gimbal locks, major rotation errors and glitches, unrealistic physics.

Do not get me wrong they still have their use (liek for example restrict free look for camera etc ... but they missused for stuff they are the worse option to use for.

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • I do use Quaternions in my simulation (which for what I know, are safe from gimbal lock), I only use euler angles for human interaction (from my experience human brains don't like quaternions). I also use transform matrices when I have to project one (or more) POINT in a transformed / rotated space. But my question is not how a point is projected through a transformed space but rather how the space is transformed. For what you've answered on that subject, If I understand correctly, my problem comes from the fact that the rotation I'm trying to describe is not around a single axis, right ? – Axel Paccalin Apr 24 '20 at 22:57
  • I also understand that you're favoring 4*4 matrices over quaternions. Euler angles, I would understand but what are their advantages over quaternions ? Except the rotation origin (which makes no particular sense as long as you don't plan to project a point/shape through it)? – Axel Paccalin Apr 24 '20 at 23:06
  • @AxelPaccalin 4x4 matrix adhere cumulation of transforms intheir order. Quaternions do not as they are just rotation. Yes they can cumulate orientation but any translation must be defined elsewhere and once that is done you can not stack up transforms anymore. Instead you need to rotate from some start point in each frame,tick,whatever and do all the transforms over and over ... Also in 4x4 matrix you can directly access and use the represented coordinate system properties as you have its 3 basis vectors , and position. That is neat for local coordinate system transforms and movement. – Spektre Apr 25 '20 at 06:56
  • @AxelPaccalin Also you can derivate the matrix position to obtain speed, acc celeration. On top of all this linear algebra is applicable on them so you can do simple transformation to and back between any coordinate systems. Also deduce transforms from input and output etc... I do not use quaternions but I do not think they capable of any of it ... Quaternions where used in gfx because there where faster. That is not the case for a long time similar to Bresenham ... simpler techniques that where slower in the past are much faster due to change in CPU architecture. I think 486 was the threshold – Spektre Apr 25 '20 at 07:00
  • That's what I thought (I wrote a basic game engine a while ago, so I'm relatively familiar with these). Here however, I only need to represent rotations from the center of mass, so no translations, no scale, no shearing in play. For my original question then, If I'm not getting the output I expected is because the rotation I was trying expecting is not around a single axis ? Or is it because the cumulative rotation on each axis compound on the other ? Because I don't see reason for the axis-order to be a problem since the rotation vector is around a single axis (swirl). – Axel Paccalin Apr 25 '20 at 10:11
  • @AxelPaccalin the reasons might be two: 1. more than just single axis aligned rotation 2. not handling singularities correctly – Spektre Apr 25 '20 at 11:34
  • Ok, thank you, I think this is the 1st then. One last thing ain't quaternions free of the singularity problem ? I thought this was only a problem with euler angles ! – Axel Paccalin Apr 25 '20 at 12:22
  • @AxelPaccalin Do not know for sure as I am not that familiar with quaternions and not that good with math that I do not use. The singularity problem might lie in conversion to/from euler itself... as you used 90deg rate for a time ... try lower that and see if it changes or have 90deg/sec but evaluates at smaller time-steps – Spektre Apr 25 '20 at 15:27