Find a Bézier for 3 points and derivatives

146 Views Asked by At

How to find a cubic Bézier curve in 2D space if the following is known:

  • the start point of the curve (P0)
  • the end point of the curve (P3)
  • a point in the middle the curve goes through (A), i.e. B(t) = A for some t
  • the first derivative in the start point (a direction from P0 to P1, call it u), the length of the vector is either 0 or 1
  • the first derivative in the end point (a direction from P3 to P2, call it v), the length of the vector is either 0 or 1
  • t is provided in which B(t) = A should be met

The goal is to compute P1 and P2.

Regarding the above, P1 = P0 + k * u and P2 = P3 + l * v for some k and l.

If the equations for P1 and P2 are put into the Bézier curve formula, only k and l are unknown. As the computation is made in 2D space, the formula splits to two, once for each dimension (x and y). As such, the problem is solvable.

However, when finding formulas for k and l there are two divisions made with denominators 3 * (1 - t)^2 * t * u.x and 3 * (1 - t) * t^2 * (v.y * u.x - v.x * u.y).

I am lost what to do when one of these denominators is 0 which should occur when:

  • t = 0, i.e. A = P0
  • t = 1, i.e. A = P3
  • u.x = 0, i.e. P0.x = P1.x
  • Cross product of u and v is 0, i.e. the derivatives in the start and end points have the same direction or they have the exact opposite direction (u || v) or one or both of them are a zero vector (u = 0 or v = 0)

Does the cubic Bézier curve exists in these cases? If so, how to find it?

Or is there a better approach?