# Quaternion Rotation Question

Hello everyone! I am using a quaternion rotation to rotate my character! The problem is, when I set my rotation to (0,1,0,0) he rotates a full 180 degrees. As the quaternion values must be integers, I don’t see how I can rotate him just 45 degrees, let alone anything less than 180. Can anyone help me?

o_0

First, where are you getting that the quaternion values must be integers?!? They are absolutely floating point values.

However, they are magic numbers. They are not angles. They are definitely not degrees. You can’t just set them to whatever you want.

You should instead use any of the many fromXXX methods for getting your values into a quaternion. I suggest using radians and fromAngles(). http://hub.jmonkeyengine.org/javadoc/com/jme3/math/Quaternion.html#fromAngles(float,%20float,%20float)

You will find very few things in 3D graphics use degrees, anyway. It’s radians all the way.

2 Likes
@pspeed said: You will find very few things in 3D graphics use degrees, anyway. It's radians all the way.

And JME was nice enough to supply us with FastMath.DEG_TO_RAD and RAD_TO_DEG you can use to convert between the two. Though I would suggest getting used to using Radian… because PI is your friend and drugs are bad, mmmk?

1 Like

I just need to figure out how to get a 135 degree turn now.

@007-Winner said: I just need to figure out how to get a 135 degree turn now.

[java]
quat.fromAngleAxis(angle, Vector3f.UNIT_Y);
[/java]

1 Like

I find that the angle axis thing really confuses people and then they over-complicate things later. So the alternative to that is:
[java]