Objects move after rotation when they shouldn't

Hi. I have a utility method called rotateRandomly(TriMesh) that does exactly what it says:

public static void rotateRandomly(TriMesh obj) {
   Quaternion quat = new Quaternion();
   float x = randomFloat(-FastMath.PI/4f, FastMath.PI/4f);
   float y = randomFloat(-FastMath.PI/4f, FastMath.PI/4f);
   float z = randomFloat(-FastMath.PI/4f, FastMath.PI/4f);
   quat.fromAngles(new float[] {x,y,z});

After passing a Sphere type object to this, whose coordinates have been using the full constructor, the Sphere is rotated, but also moved. I tried to even explicitly set the local and even world translation after this method was called, but to no avail. Calling Sphere.getLocalTranslation() returns the expected values that I gave it, but in the game I can see clearly that the object is not where it should be (because I have several such spheres that should be on the same plane, yet some are higher than others).

Any ideas as to what's wrong?

You’ve probably translated your spheres before the rotation so they are no longer rotating around the same point. Make sure you do your rotation first then do any translations.

Ah, right you are! Silly me, that’s what I get for using the wrong constructor! Thanks! :slight_smile:

Awesome … I’m glad it was something simple. You have no idea how often I used to do that :smiley: