# Rotating an Object Around an 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;


Main Game Loop:

 Object.increaseRotation(dxf,dyf,dzf);


But, it's not rotating along it's own axis. What am I missing here? I want something like this. Please Help

• What is it doing instead? Is it rotating along a different axis? – Julien Guertault Oct 2 '16 at 11:35
• I wanted to read your question but that animated gif is too distracting. – 3Dave Oct 5 '16 at 23:07

Matrix4f translate = translate(translation,  new Matrix4F() /*identity*/);