I keep running into a problem when I try to figure out a generalized way of rotating about $(1, 0, 0)$ or $(0, 0, 1)$, then trying to do the equivalent of either pitch up or turn. I would have gone to stackoverflow, but I don't have any proper code to speak of, at least not anymore, and I'm trying to figure out how quaternions work in general.

I'm trying to keep track of how the point $(0 + 0i -1j + 0k)$ is moved. I know that if I multiply:

$$(0.92 + 0i + 0j + 0.39k) * (0 + 0i -1j + 0k) * (0.92 + 0i + 0j - 0.39k)$$

then I'll get this as a result:

$$0 + 0.7176i - 0.6943j + 0k$$

However, this is where things get tricky for me. I know I can generalize movement around the k axis or i axis in this order,

k axis for turning:

$$cos(x) + 0sin(x)i + 0sin(x)j + 1sin(x)k$$

i axis for pitching:

$$cos(x) + 1sin(x)i + 0sin(x)j + 0sin(x)k$$

But any starting point other than $(1 + 0i + 0j + 0k)$ is a conundrum for me. I know if I could just figure out how to change the axis of rotation with a given increase or decrease in angle that would accomplish what I want it to do. That's why I'm asking whether it's possible to figure out what $q$ and $q^{-1}$ is when I know $p$ and the output. For instance, it is possible to know what $q$ is when you know this:

$$q(0 + 0i - 1j + 0k)q^{-1} = 0 + 0.7176i - 0.6943j + 0k$$

Why do I want to know how to do that? Because I'm reasonably confident if I keep i and j's coefficients in the same ratio up until $(0 + 0i -1j + 0k)$ is moved to $(0 + 0i + 0j + 1k)$, then I'll get the same thing as pitching. But in order to do that I need to know $q$ when $p$ is $-j$ and is all equal to some arbitrary unit quaternion.

If that's not possible, then how does the axis of rotation and the angle relate to each other to get the equivalent of pitching after turning some arbitrary amount about the k axis?

Edit 1: Okay, so I was able to brute force a series of quaternions where I rotated about the k axis and then keep the moved I point in place as I have a python script try to "pitch up". First I multiplied $$(0.92 + 0i + 0j + 0.4k) * (0 + 1i + 0j + 0k) * (0.92 + 0i + 0j - 0.4k)$$ and the ending quaternion was this: $$(0.641 - 0.66i - 0.2869j + 0.2787k) * (0 + 1i + 0j + 0k) * (0.641 + 0.66i + 0.2869j - 0.2787k)$$.

Now why did I use the point I, instead of -J? Because if I want the equivalent of pitch I have to keep the moved I point is place... If that makes any sense. Something interesting I found with the change in the i part of the rotation axis is that it seemed to have the pattern of this:

$$f(x) = e^{3-\pi^{2}(x-0.087)}-0.87$$

Why that formula?

Edit 2: Here's a chart of i coefficients I plotted out on libre calc: i coefficients chart

Edit 3: I found a few more equations which somewhat satisfy what I'm looking for, but they're off by quite a bit given the fact that unit quaternions are so sensitive change due to their small range of values.

I'd like to you to look at this axis of rotation: $(-0.86, -0.36, 0.36)$ This is the final axis, and the starting axis was $(0, 0, 1)$

Make it such that: $$x_n = -0.86$$ $$y_n = -0.36$$ $$z_n = 0.36$$

Assume this: $$1r + ai + bj + ck$$ Where $a$, $b$, and $c$, are the axis of rotation.

The starting angle is also important, so see this: $$cos(0.42) + 0sin(0.42)i + 0sin(0.42)j + 1sin(0.42) = 0.92 + 0i + 0j + 0.4k$$

Finally, this: $$\theta_0 = 0.42$$

Now here's where the interesting part comes in: $$a = \frac{1}{\frac{\theta_0}{2} * 100 * (\theta + x_n)} + (\frac{1 - z_n}{10} - 1)$$

$$b = \frac{1}{z_n * 10 * (\theta - z_n)} - \theta_0$$

$$c = \frac{1}{z_n * 10 * (\theta - 1 + x_n)}$$

I don't know if these will work in general, but they kind of work for the points I brute forced earlier.

  • $\begingroup$ Welcome to MSE. Please edit and use MathJax to properly format math expression. $\endgroup$ – Lee David Chung Lin Apr 20 at 0:45

If you know $p$ and $p'=qpq^{-1}$, you can only recover $q$ up to a quaternion which commutes with $p$. This is not special to quaternions, and is valid in any algebra. Indeed, suppose $q_0$ is any invertible quaternion which commutes with $p$. Then $$(qq_0)p(qq_0)^{-1} = q(q_0pq_0^{-1})q^{-1}=p'.$$ I'll let you figure out why the converse is also true.

Note that if $p$ is a non-zero pure quaternion (which seems to be your assumption), then the quaternions which commute with $p$ are those of the form $a+bp$ with $a,b\in \mathbb{R}$.

  • $\begingroup$ What is required of an invertible quaternion to be able to commute with $p$? Can I make $q_0 = 0.71 + 0i + 0j + 0.71k$ if $p = 0 + 0i - 1j + 0k$ and $p' = 0 + 0.7176i - 0.6943j + 0k$? Can any invertible unit quaternion commute with $p$? I know that might sound like a silly question because I'm definitely missing something. $\endgroup$ – berylliumquestion Apr 24 at 2:58
  • $\begingroup$ Two quaternions commute when their axis of rotation is the same. i.e., both are rotations in the plane . $\endgroup$ – Mauricio Cele Lopez Belon Apr 26 at 4:26
  • $\begingroup$ @berylliumquestion I don't understand your question, I'm not sure you understand what "commute" means. The question is not whether a quaternion "can" commute with another or not. It either commutes with it or it doesn't. I gave in my answer a pretty clear (I think) description of which quaternions commute with $p$. To take your example, if $p=-j$ then the quaternions wich commute with $p$ are those of the form $a+bj$ for any $a,b\in \mathbb{R}$. $\endgroup$ – Captain Lama Apr 26 at 5:50
  • $\begingroup$ Well, I probably have a good amount of holes in my knowledge, so an answer which is clear, may not be clear to me. However, this is the only way I can get myself to actually fill in the gaps, without it I have no motivation and I just go nowhere. That said, I did this $q = jqj^{-1}$, then $p' = qpjqj^{-1}$, because $p$ happens to be $-j$, and because $jj^{-1}$ is $1$, I can remove that so that then $p' = q^{2}j^{-1}$. So then I went searching for square roots of quaternion and found this math.stackexchange.com/questions/382431/…, and then I realized why $\endgroup$ – berylliumquestion Apr 27 at 2:26
  • $\begingroup$ $a + bj$ was relevant, but I don't if I have valid reasoning there. $\endgroup$ – berylliumquestion Apr 27 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.