Random non-intersecting cubic bezier curves between prescribed anchor points

734 Views Asked by At

I am given 4 pairs of red-green points in 2D. each pair corresponds to end points of a cubic bezier curve. My objective is to generate random control points for 4 curves (one going through each pair) such that the final curves have these two properties:

  1. Each curve should not intersect itself.
  2. Curves should not intersect each other.

Here is an example of of the output I am interested in:

An example of what I want

Now one easy way to generate bezier curves which aren't self-intersecting is to make sure the line segments between first point and first control point and the one between last point and 2nd control point do not intersect (red and blue lines in the image below). The curve can still have no self intersection if they do intersect but at least if they don't we can be sure it doesn't have any. With this in mind, for each curve I can simply generate totally random control points, and flip their order if these line segments intersect. but so far this only satisfies my 1st criteria while I might generate curves which intersect each other.

enter image description here

I was wondering if there's any joint strategy with which I can generate these control points such that both my constraits are met, while keeping in mind that I want curves to be as random as possible.

With the last remark I wanted to rule out simple solutions such as generating first curve, computing its convex hull (CH), and then generating next curve completely outside the CH, update CH to union of previous CH with the new curve's convex hull, and so on.