# Rotating a circle on its axis

I have a circular shape object, which I want to rotate like a fan along it's own axis.

I can change the rotation in any direction i.e. dx, dy, dz using my transformation matrix.

The following it's the code:

 Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
Matrix4f.translate(translation, matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1,0,0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0,1,0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0,0,1), matrix, matrix);
Matrix4f.scale(new Vector3f(scale,scale,scale), matrix, matrix);


My vertex code:

 vec4 worldPosition = transformationMatrix * vec4(position,1.0);
vec4 positionRelativeToCam = viewMatrix*worldPosition;
gl_Position = projectionMatrix *positionRelativeToCam;


But, it's not rotating along its own axis, it is flipping like a coin instead. What am I missing here?

• The above one is for Y rotation , while moving along Z axis it's rotating fine but it's Y position changes Commented Oct 1, 2016 at 14:07
• If you want it to rotate around its own axis, then how about doing a rotation around its own axis, instead of 3 rotations around the X/Y/Z axes? Commented Oct 3, 2016 at 1:58

You apply your transformations in the wrong order. The usual way is scale first, then rotate, and lastly translate. Currently you are translating first, then rotating, and finally scaling.