Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate bezier curve control points that avoid objects?

Tags:

People also ask

How are Bezier curve control points calculated?

To find any point P along a line, use the formula: P = (1-t)P0 + (t)P1 , where t is the percentage along the line the point lies and P0 is the start point and P1 is the end point. Knowing this, we can now solve for the unknown control point.

How many control points can a Bezier curve have?

As the algorithm is recursive, we can build Bezier curves of any order, that is: using 5, 6 or more control points. But in practice many points are less useful. Usually we take 2-3 points, and for complex lines glue several curves together. That's simpler to develop and calculate.

Does Bezier curve pass through all control points?

k=0: The Bezier curve starts at the first control point and stops at the last control point. (In general, it will not pass through any other control point.) k=1: The vector tangent to the Bezier curve at the start (stop) is parallel to the line connecting the first two (last two) control points.

How do you find the equation of a Bezier curve?

Number of points i.e. k=4, Hence, we know that the degree of the Bezier curve is n= k-1= 4-1= 3. Hence, P0(2,2,0) and B0,3=(1−u)3,P1(2,3,0) and B1,3=3u(1−u)2,P2(3,3,0) and B2,3=3u2(1−u) andP2(3,2,0) and B3,3=u3.


Specifically, I'm working in canvas with javascript.

Basically, I have objects which have boundaries that I want to avoid, but still surround with a bezier curve. However, I'm not even sure where to begin to write an algorithm that would move control points to avoid colliding.

The problem is in the image below, even if you're not familiar with music notation, the problem should still be fairly clear. The points of the curve are the red dots

Also, I have access to the bounding boxes of each note, which includes the stem.

enter image description here

So naturally, collisions must be detected between the bounding boxes and the curves (some direction here would be good, but I've been browsing and see that there's a decent amount of info on this). But what happens after collisions have been detected? What would have to happen to calculate control points locations to make something that looked more like:

enter image description here