# GLM::Rotate and the Aspect Ratio combination question

Ok, I’ve got a question about the GLM::Rotate function. :biggrin-new:

When I apply this rotation around a static, center of the screen 2D object…

Am I running into a combination of the GLM::Rotate function applying trig to the vertices, so the trigonometry is affecting the length of my object, or…
is it the aspect ratio of the screen that is changing the shape of my object as it rotates…or…
is it some combination of the two?

To tackle this problem, and make the 2D object (sprite) appear normal throughout the rotation, is it easier to just rotate the sprite images and load them in and work with them, or actually figure out the correct combination to undo the trig and aspect ratio combo that’s morphing the sprite as it rotates?

The closest I’ve come so far…is with the following code:

``````
glm::mat4 transform;
transform = glm::rotate(transform, glm::radians(shipRotation), glm::vec3(0.0, 0.0, 1.0));
// width goes from 128 to 226 from angle 0 to 90. aspect ratio 1 / 1.778 = 0.5625
// figure out aspect ratio adjustment for rotation
shipScaleX = 1.0f +(0.778f * glm::abs(glm::sin(glm::radians(shipRotation))));
shipScaleY = 1.0f -(0.4375f * glm::abs(glm::sin(glm::radians(shipRotation))));
transform = glm::scale(transform, glm::vec3(shipScaleX, shipScaleY, 1.0));

``````

This code makes the 2D sprite maintain as close to it’s shape as possible as it rotates (5 degree increments), but it still wobbles noticeably in and out of shape as it rotates.

I am very good at math, once upon a time, being a calculus tutor in college, but it’s been a while…

Alright, I’m still working on this tonight for at least another hour, then I’ll start again tomorrow with another program, or any solutions that you guys could help me with.

Jeff

Ok, so I re-visited my problem, and decided that my rotation delta was too little. It was 4 degrees.

I changed it to 22.5, so it will only have 16 points of rotation total for 360 turn, which makes the graphic look like it’s unchanged as it rotates.

I still want to re-visit this math problem, but for now, it’s a little too … mathematical. lol

I am still keeping this on the table, and as I work on a solution, I will update this thread.

Thanks guys,

Jeff

P.S. oh, and guys, I’m not a robot, and I can verify that with street sign identification…ok? rofl