0
$\begingroup$

I need some help with understanding the rotation angle determination via atan2. The formula which I found in this forum is following:

$\phi=2\tan^{−1}(\sin(\phi/2)/\cos(\phi/2))$

This is derived from the unit quaternion. $a=(\cos(\phi/2),\sin(\phi/2)\vec{n})$

I understand that I get following equation by transforming the scalar part of the quaternion: $\phi=2\cos^{-1}(a_1)$

But how do I get the atangens equation ?

$\endgroup$
2
  • 1
    $\begingroup$ $\vec{n}$ is a unit vector, so $\sqrt{a_i^2+a_j^2+a_k^2}=\sin(\phi/2)$. $\endgroup$ Commented Feb 2, 2021 at 22:47
  • $\begingroup$ $$\phi=2\operatorname{atan2}(a_1,\sqrt{a_2^2+a_3^2+a_4^2}).$$ I would consider using this only if you also use quaternions that are not normalized to have (4-dimensional) length equal to one. If normalized, then $\phi=2\arccos a_1$ is the way to go. Do observe that the square root is always positive, so using atan2, a function specifically coded to deal with the four quadrants, is a bit of overkill. $\endgroup$ Commented Feb 8, 2021 at 6:24

1 Answer 1

1
$\begingroup$

Polar form for quaternions uses three variables, which I will denote as r, p, and n. To find the atan of a quaternion the variable n is needed: the quaternion a+bi+cd+dj is expressed as a+v, n = v/abs(v)

atan(q) = -(n/2) ln( (n-q)*((n+q)^-1) )

This is essentially the formula for atan of a complex number because just as a function of a complex number can be obtained as a two-dimensional stretch, shift, or rotation, the same thing can be done with quaternions, and, most stretches, shifts, or rotations only require points on a plane, n essentially denotes a plane slicing through four dimensions, and technically treating anything like a complex number, where the complex part, instead of i, is a unit versor n, works just fine.

For example, the cos of a quaternion:

a = r(cos(p))

cos(q)

= cos(r(cos(p)+n sin(p)))

= cos(a+n*sin(p))

= cos(a) cos(n r sin(p)) - sin(a) sin(n r sin(p))

= cos(a) cosh(r sin(p)) - n sin(a) sinh(r sin(p))

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .