I have a model rotated by a quaternion. I can only set the rotation, I can't add or subtract from anything. I need to get the value of an axis, and than add an angle to it (maybe a degree or radian?) and than re-add the modified quaternion.

I think you need to clarify a bit further. You say you can only set the rotation... A quaternion serves the same purpose as a rotation matrix. The difference being that the quaternion is numerically stable, they are more expensive to apply to 3d geometry but are less expensive for concatenation... So they are typically used when long series of rotations need to be applied and then they are transformed back to rotation matrices before application. Please clarify what you mean by answer on each axis, perhaps you want quaternion -> three rotation matrix where each is about one axis?
–
QuaternionDec 14 '10 at 7:27

1 Answer
1

You can multiply two quaternions together to produce a third quaternion that is the result of the two rotations. Note that quaternion multiplication is not commutative, meaning order matters (if you do this in your head a few times, you can see why).

You can produce a quaternion that represents a rotation by a given angle around a particular axis with something like this (excuse the fact that it is c++, not java):

So if I want to create a quaternion with a -15 degrees rotation on the X axis, I should call createFromAxisAngle(1, 0, 0, -15*PI/180)? Thanks!
–
HubrusOct 25 '12 at 13:15

2

@Hubrus: Yep, that'd be correct. Then, if you call that quaternion x and your model quaternion y, you would normally set the total rotation using x * y (depending on how you implement multiplication of course).
–
sje397Oct 25 '12 at 22:44