How to rotate a stack of shapes and make them move at a same pace?


Hello there!
A beginner here experimenting with star-shaped polygons. I just made them rotate on top of each other. They are now spinning around on a certain angle - however, the bigger the star, the slower it seems to rotate.

Any ideas on how to fix the ofRotate -command to make the stars look like they spin at the same pace? I have a hunch that I should translate the angle to respond to the length of the radius, but I don’t know how.

Big thanks for any help and guidance!

Here’s what I got now:

**void** ofApp::draw(){


**float** resolution = ofMap(mouseX, 0, ofGetWidth(), 3, 20, **true** );
**float** radius1 = 200;
**float** radius2 = ofMap(mouseY, 0, ofGetHeight(), 50, 400, **true** );
**float** noOfStars;
noOfStars = 20;

    for (float noOfStars= 0; noOfStars < 20; noOfStars++) {
        ofSetColor(ofMap(noOfStars, 0, 20, 0, 255, true));
        ofTranslate(ofGetWidth()/2,ofGetHeight()/2, true);
        ofScale(1/noOfStars, 1/noOfStars);
        star(0, 0, radius1, radius2, resolution);

you’re using ofRotateRad(noOfStars * rotAngle); which means you’re doing for every step of the for loop,

0 * rotAngle
1 * rotAngle
2 * rotAngle
20 * rotAngle

Basically, the angle is being scaled by the element number, which is what’s making each polygon rotate at the rate of its index.

Simply doing ofRotateRad(rotAngle) should be enough to rotate them each at the same speed.

1 Like

Hi ayruos! Terribly delayed thank you!!! :blush: