Rotation angle from quaternion via atan2

773 Views Asked by At

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 ?

1

There are 1 best solutions below

0
On

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))