Rotate Circle around center?

Hi, I have the following code :

    float rotate;
    glm::vec2 center;
    glm::vec2 radius;

void ofApp::draw(){

    ofTranslate(ofGetMouseX(), ofGetMouseY());
    ofDrawCircle(center, glm::distance(center, radius));

void ofApp::mouseDragged(int x, int y, int button){
    radius = glm::vec2(x,y);

void ofApp::mousePressed(int x, int y, int button){
    center = glm::vec2(x,y);

What I want to achieve is that circle to rotate around center.

that’s what this appears to do when i run the code - do you mean that the circle is centred and spins ‘on’ the


or rotates around


I mean spins on its center.

aha !

    ofDrawCircle(0,0, glm::distance(center, radius));

translate to where you want the circle drawn then draw at 0,0 (as this is now the centre of where you want it after the pushMatrix…

in the example you keep recentreing based on mousex & mouseY so it will keep moving where the circle is drawn but the circle will rotate on it;s own centre now.

1 Like

Thank you :slight_smile: I missed the 0,0 coordinates :wink: