planangle = new PVector(location.x-plan.location.x, location.y-plan.location.y);
// if (-90<velocity.heading() && velocity.heading()<90) {
// planangle.rotate(PI);
//}
if (dist(location.x, location.y, plan.location.x, plan.location.y)<plan.r+r+8) {
location = new PVector(cos(location.heading())*(location.mag()), sin(location.heading())*(location.mag()));
println("heading ", velocity.heading(),planangle.heading());
println("velocity ", velocity);
println("planangle ", planangle);
if(velocity.heading() > 0 && velocity.heading()<radians(90)){
velocity.rotate(PI);
velocity.rotate(2*PVector.angleBetween( planangle,velocity)).mult(0.95);
}
if(velocity.heading() >= 90 && velocity.heading()<radians(180)){
velocity.rotate(PI);
velocity.rotate(-2*PVector.angleBetween( planangle,velocity)).mult(0.95);
}
println("alpha angle ",PVector.angleBetween(planangle,velocity));
}
I’m making a project with forces for a class, and I’m trying to get a smaller circle to bounce off the larger circle kind of how it would act like in gravity. I have a vector that pulls the smaller circle in. It works mostly, but every 3-5 bounces it just clips through the large circle and falls down it, and then resumes working normally. Help!