Rotating from two different start points (should be super easy)

Hey all
I’m looking to make two circles rotate from two different points in the rotation cycle. While both rotate on separate parts of the screen, the distance between them stays the same at all times because they both start at the top of the cycle and loop back around to the top of their respective cycles at the same time. I would like the second circle to start at the bottom of the cycle, or anywhere in between, so the two circles aren’t in sync.

Thanks!

void ofApp::setup() {
refCircle1.set(150, 150); //refCircle = ofVec2f(150, 150);
refCircle2.set(550, 350);
theta = 0;
multiplier = 100;
oscSpeed = 0;
}

//--------------------------------------------------------------
void ofApp::update() {
theta += 0.005;
oscSpeed += 0.1;

float x = cos(theta);
float y = sin(theta);

sinCircle.set(refCircle1.x + oscSpeed, (refCircle1.y + ymultiplier));
cosCircle.set(refCircle1.x + x
multiplier, refCircle1.y + oscSpeed);

rotateCircle1.set(refCircle1.x + xmultiplier, refCircle1.y + ymultiplier);
rotateCircle2.set(refCircle2.x + xmultiplier, refCircle2.y + ymultiplier);
}

//--------------------------------------------------------------
void ofApp::draw() {

ofSetColor(255, 0, 0);
ofDrawCircle(refCircle1, 10);

ofSetColor(255, 255, 0);
ofDrawCircle(rotateCircle1, 10);

ofSetColor(255, 255, 0);
ofDrawCircle(rotateCircle2, 10);

ofSetColor(255);
ofDrawLine(rotateCircle1, rotateCircle2);

}

Hi!

If you do something like this:

rotateCircle1.set(refCircle1.x + x * multiplier, refCircle1.y + y * multiplier);

x = cos(theta + PI);
y = sin(theta + PI);

rotateCircle2.set(refCircle2.x + x * multiplier, refCircle2.y + y * multiplier);

You are now offseting theta by PI (which is half a circle).

Edit: Also, welcome to the forum! :smiley:

This works,

Thanks !