hi
is there methode to calculate angle or quaternion using sin and cos?
because i have note the angle but i have the cos and the sin
calculate quaternion using cos and sin
-
- Greenskin
- Posts: 131
- Joined: Sun Apr 22, 2012 1:55 pm
-
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 535
Re: calculate quaternion using cos and sin
The formula for a quaternion is:
w = cos(angle/2)
x = axis.x * sin(angle/2)
y = axis.y * sin(angle/2)
z = axis.z * sin(angle/2)
But as you can see there you need the cos and sin of half the angle. If you have cos and sin of the whole angle, it won't work directly (need to get back to the angle so you can halve it).
w = cos(angle/2)
x = axis.x * sin(angle/2)
y = axis.y * sin(angle/2)
z = axis.z * sin(angle/2)
But as you can see there you need the cos and sin of half the angle. If you have cos and sin of the whole angle, it won't work directly (need to get back to the angle so you can halve it).
-
- Greenskin
- Posts: 105
- Joined: Fri Feb 08, 2013 11:30 am
- Location: Oslo
- x 16
Re: calculate quaternion using cos and sin
Or you could use the fact that cos(angle) = 2 * cos(angle/2)^2 - 1 = 1 - 2 * sin(angle/2)^2 , but I'm not sure it would be more efficient than using acos to recover the angle and then cos and sin again.
-
- Greenskin
- Posts: 131
- Joined: Sun Apr 22, 2012 1:55 pm