0

I'am working with Quaternion, I have two Quaternions, first is an initiale Quaternion, and I have a second Quaternion, I'd like to detect if my second Quaternion has rotate more than 90° in x or y is it possible? For now I can compute angle between two Quaternions, but I detect if I rotated more than 90 in x, y and z.

For example my initial Quaternion position (w, x, y, z) order 0.73 0.68 0.06 0.04

My second Quaternion 0.69 0.58 0.31 0.30

So I can compute total rotation like this

q3 = conjugate(q2);
q_multiply = multiply(q1, q3);
angle = (2 * acos(q_mulitply.w)) * RAD_TO_DEG;
if(angle > 90)
    do something

So now I have the angle between q1 and q2 but now I'd like to detect only if for example x or y has rotated more than 90°, I don't care about if my z rotated more than 90°.

simon
  • 101
  • 2
    It is not really clear what "rotated around x" means in this context. A general quaternion is a rotation around an arbitrary axis $(x,y,z)$. Maybe you want to convert to Euler angles and check them? In that case see https://math.stackexchange.com/questions/2975109/how-to-convert-euler-angles-to-quaternions-and-get-the-same-euler-angles-back-fr for some explicit code. – Simon Aug 04 '21 at 12:31
  • @Simon I don't want to use Euler because I don't want to face Gimbal lock. I'd like to compute pitch and roll between 2 quaternion without Euler angle with pure Quaternion – simon Aug 04 '21 at 14:29
  • My objective is to detect if my Quaternion has rotated in pitch or roll or pitch and roll more than 90° without using Euler beceause with Euler conversion I got Gimbal lock I've already tried. – simon Aug 04 '21 at 14:53
  • Okay. But without Euler angles, what does "more than 90 degrees rotation around x" even mean? For example consider a rotation by some degree around the diagonal (1,1,1) axis. How do you define what "the rotation around x" is for that? – Simon Aug 04 '21 at 15:28
  • Euler angles are one such possible definition, but it's not the only one,other definitions are possible. But: any mapping from the set of rotation onto three angles will have some singular point somewhere (ie. Gimbal lock). – Simon Aug 04 '21 at 15:30
  • 1
    If you want "pitch" and "roll" you are asking for some kind of Euler angles (in the most general sense). There also is the question of pitch and roll relative to what: are both orientations measured by the change from a base orientation, or is there some local frame of reference with respect to the first orientation (e.g., roll axis points straight ahead whichever way I'm pointing right now) and you just want to pitch, roll, and yaw to the new orientation from that local frame. – David K Aug 04 '21 at 18:19
  • Maybe it would be more helpful to show what you've already tried (the attempt that got you into gimbal lock). Maybe someone can spot what really is causing the problem. – David K Aug 04 '21 at 18:21
  • And if possible, use math notation as much as you can. Here's a starting point for the advice on how to make it legible to other people: https://math.stackexchange.com/help/notation – David K Aug 04 '21 at 18:23
  • @DavidK what I want is like you said I want pitch and roll measured by the change from a base quaternion. So I want to know pitch and roll from a quaternion compare to à base quaternion without Euler angle because I’am working at the limit of gimbal lock. Actually what I’am doing is working but I detect also a 90deg on yaw and I don’t want that. – simon Aug 04 '21 at 18:24
  • The $(x,y,z)$ in the quaternion give the axis of the rotation in 3D-space. They are unrelated to pitch/roll/yaw. At least it doesn't make any sense to say "$z$ rotated by more than 90 degrees". A single number does not rotate, a vector does. – Jyrki Lahtonen Aug 16 '21 at 05:13
  • Also, the quaternions are the rotations. How do you rotate a rotation? – Jyrki Lahtonen Aug 16 '21 at 05:32

0 Answers0