# Image speeds up while moving and or rotating instead of constant speed

I'm having a problem with rotating/moving an image. I've set one of my images to rotate on it's z-axis buy updating the angle, but when I run my game, the image starts slowly starts to rotate from a stationary position as if to build up momentum. Once it reaches a certain speed, it begins to slow down to almost a stop, then repeats the process over. Furthermore, when it starts to rotate, it's rotating clockwise. But halfway before it stops, it's now rotating counter-clockwise.

If I were to only update it's x or y position or both, the image will move slow, then speed up to the desired speed, instead of moving at the desired speed at start.

Lastly, if I were to rotate AND move the image, the image shakes erratically while rotating. My suspicion is that I'm calculating something wrong.

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
....
gl_Position = projection * view * model * vec4(position, 1.0);


init()

        projection = glm::ortho(LEFT, RIGHT, BOTTOM, TOP, ORTHO_NEAR, ORTHO_FAR);

mSprite.init("res/texture/foo.png", 1.0f);
mSprite.setPosition(mPosition);
mSprite.setRotation(rot, glm::vec3(0, 0, 1));

glm::vec3 pos(1.5, 0.5, 0.0);
mSprite2.init("res/texture/bar.png", 1.0f);
mSprite2.setPosition(pos);
mSprite2.setRotation(0.0f, glm::vec3(0, 1, 0));


update()

        mPosition.x += 0.000005f;
mPosition.y += 0.000005f;
mSprite.setPosition(mPosition);

rot += 0.0005f;
mSprite.setRotation(rot, glm::vec3(0, 0, 1));


render()

        mShader->start();


        shader->LoadViewMatrix(view);
// Draw image...

void setPosition(glm::vec3 position)
{
mModel = glm::translate(mModel, position);
}

void setRotation(GLfloat angle, glm::vec3 axis)
{
mModel = glm::rotate(mModel, angle, axis);
}

• What kind of timestep are you using? When you translate something you usually multiply it by the delta time. That way when your program is running fast it translates less. When it's running slow it translates more, so it appears to be perfectly linear movement. Without it that would cause some jittery movement. – Andrew Wilson Jul 27 '15 at 10:56
• Do you ever push/pop the model matrix? Or reset to the identity? It sounds like you're applying transformations on top of each other while you should probably push the matriz, apply the transformations, then pop. Watch out for the order in which you apply translation and rotation simultaneously. Also you stopped the shader before drawing the image? – aslg Jul 28 '15 at 9:12