We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to stick a rectangle on my moving arcs and I can't seem to get the logic down. Could someone help me out please?
To be specific, I want a rectangle attached to the arc and as the arc rotates the rectangle moves with it. Thanks so much!
Arc a1;
void setup(){
size(600,600);
background(0);
strokeWeight(4);
a1=new Arc(width/2,height/2,150,0,QUARTER_PI+PI);
noLoop();
}
void draw(){
clear();
float r1=0;
float r2=0;
stroke(153,255,51);
a1.display();
r1+=PI/25;
r2+=PI/25;
a1.rotate(r1,r2);
}
void mousePressed(){
loop();
}
void mouseReleased(){
noLoop();
}
class Arc
{
float xpos;
float ypos;
float size;
float astart;
float aend;
Arc(float x,float y,float asize,float start, float end){
xpos=x;
ypos=y;
size=asize;
astart=start;
aend=end;
}
void rotate(float posx, float posy){
astart+=posx;
aend+=posy;
}
void display(){
noFill();
arc(xpos,ypos,size,size,astart,aend);
}
}
Answers
There is a great Processing tutorial on some ideas related positioning things like this: https://www.processing.org/tutorials/trig/
I would've never gotten that far, trig wasn't my strongest suit. Thanks a lot man!