Hello. I'm having a similar problem where I want the angle added to the knob to be relative (because, let's face it, making it absolute is silly)
However, like all functions based on tangent, there's an asymptote at -PI and +PI. This makes things rather annoying if you cross over the boundary between the bottom left corner to the top right corner.
How does one handle free movement so that you can just keep rotating any way you want?
Code:float angle = PI;
void setup(){
size(300,300);
smooth();
}
void draw(){
background(200);
noFill();
strokeWeight(1);
ellipse(width/2, height/2, 200,200);
fill(255);
strokeWeight(6);
arc(width/2, height/2, 200,200, 0, angle);
pushMatrix();
translate(width/2, height/2);
rotate(angle);
line(0,0,100,0);
popMatrix();
}
void mouseDragged(){
float thisAngle = atan2(mouseY-height/2, mouseX-width/2);
float prevAngle = atan2(pmouseY-height/2, pmouseX-width/2);
angle += thisAngle - prevAngle;
println(angle);
}
(by the way, i realize that the arc can't render in negatives, so don't worry about that. I'm more concerned for the angle value getting messed up)