Skip to content
Advertisement

What is the best way to determine whether a bezier is overlapping a circle?

In Java / Processing, I want to test whether a bezier curve is overlapping a circle, so that I can shift one of them out of the way.

Is there a simple way to do this?

Advertisement

Answer

You can use the bezierPoint() function to get a series of points along a Bezier curve.

Then you could test those points against your circle.

From the reference:

noFill();
bezier(85, 20, 10, 10, 90, 90, 15, 80);
fill(255);
int steps = 10;
for (int i = 0; i <= steps; i++) {
  float t = i / float(steps);
  float x = bezierPoint(85, 10, 90, 15, t);
  float y = bezierPoint(20, 10, 90, 80, t);
  ellipse(x, y, 5, 5);
}


(source: processing.org)

1 People found this is helpful
Advertisement