I’m trying to rotate a planet. I’m using the rotate(float, float, float) function to rotate a spatial.
I want it to rotate -90 degrees (-0.5 radians) on the x-axis and 23.5 degrees (0.41 radians) on the y-axis.
Thus, I write:

pc.getModel().rotate(-0.5f,0,0.41f);

pc is a planet control, don’t worry about that. It doesn’t rotate anything.

Someone can jump in and correct me if I’m wrong here, but I think when constructing a Quaternion from Euler angles as in that tutorial (quat.fromAngles(x,y,z)) you need to remember they are applied in a specific order, in JME’s case that is YZX.

So if it were me to get your rotation I would do

Quaternion r1 = new Quaternion();
r1.fromAngleAxis(xAmount, Vector3f.UNIT_X);//xAmount around X

Quaternion r2 = new Quaternion();
r2.fromAngleAxis(yAmount, Vector3f.UNIT_Y);//yAmount around Y

r1 = r1.mult(r2);

The order in the mult step matters, so in this case its the X rotation, then the result is rotated around Y.

Annnnnd as I typed this I realised your -90 degrees value in radians is wrong

The rotate mehtod does use angles in radian, like the documentation of this method says: Rotates the spatial by the xAngle, yAngle and zAngle angles (in radians), (aka pitch, yaw, roll) in the local coordinate space.

You can directly insert you angles in degrees if you multiply it with pi/180 like that: spatial.rotate(0, 90 * FastMath.DEG_TO_RAD, 0);

Here is a link to a tutorial which explains vectors and quaternions in JME:

90 degrees is not 0.5 radians. 90 degrees is PI/2 radians.

Just a note in case you meant something else… it would be clearer to say “around the X-axis”. Rotating a planet around the x-axis is strange so I thought I’d clarify that point. For example, if you wanted to simulate time of day then you’d rotate around the y axis.

I understand what you mean by this, and yes, I want to rotate it on (around) the X axis. As you can see in the non-rotated picture, the north pole points towards the sun. It should point kind of upwards.

Yes, but the actual code is like a huzzled combination of spaghetti, tomatoes, meatballs, and weird back and fro references. It’s supposed to be neatly organised, but I haven’t put enough time into it. Thus I checked my code and gave the lines I thought were important to save some of your time.

I solved the problem by multiplying Math.PI. I forgot that.