I have a simple sketch with circle and a rotating arm, rotating clockwise from the center of the circle. In the sketch there are two smaller ellipses to the left of the center.
I am looking for a way to detect when the rotating arm has collided with the smaller ellipses, because of how it's rotating the arm is going the hit the ellipse closer to the center first. Im having a bit of trouble in fully realising this idea and I'm wondering if anyone has encountered this before?
Here some code to better illustrate my point
hope this makes sense!
let angle;
function setup() {
createCanvas(400, 400);
angleMode(RADIANS);
angle = 0.00;
}
function draw() {
background(220);
translate(width / 2, height / 2);
noFill();
ellipse(0, 0, 400);
fill(255, 0, 0, 40);
ellipse(60, 0, 30);
ellipse(160, 0, 30);
stroke(0, 200);
strokeWeight(3);
rotate(angle);
line(0, 0, 0, -200);
angle += 0.015;
}
function doSomthing() {
// when arm collides with smaller circles
// do somthing.
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>