quaternion to rotation vector - sin(theta/2)=sqrt(1-quaternion.w^2)?

129 Views Asked by At

I want to figure out why sin(theta/2)=sqrt(1-quaternion.w^2)

here is part of my code to conver quaternion to rotation vector

m = ( acos(w)*2.0 )/sqrt(1-q.w*q.w);
data[0] = q.x*m;
data[1] = q.y*m;
data[2] = q.z*m;

I wrote it 2 years ago and I do not remember everything where it comes from.

From this site i know that 'm' should be 'sin(theta/2)' but in my code exist 'sqrt(1-w*w)'. For sure I checked everything in excel and it look like it's true. But my question is where it may come from that replacement? I dig many sites and I can not find my source of that part or any proof if it's true. I'm not good at mathemathics and programming, I just do it for hobby.

1

There are 1 best solutions below

2
On

You can represent the quaternion as $$q=w+xi+yj+zk=\cos\frac\theta2+\sin\frac\theta2(ai+bj+ck)$$ Then you can write the angle as $$\theta=2\arccos w$$ To get the direction of the axis, you need $\sin\frac\theta2$ first, which you can get from $\sin^2\alpha+\cos^2\alpha=1$, so $$\sin\frac\theta2=\sqrt{1-\cos^2\frac\theta2}=\sqrt{1-w^2}$$