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) = Afor somet - the first derivative in the start point (a direction from
P0toP1, call itu), the length of the vector is either0or1 - the first derivative in the end point (a direction from
P3toP2, call itv), the length of the vector is either0or1 tis provided in whichB(t) = Ashould 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 = P0t = 1, i.e.A = P3u.x = 0, i.e.P0.x = P1.x- Cross product of
uandvis0, 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 = 0orv = 0)
Does the cubic Bézier curve exists in these cases? If so, how to find it?
Or is there a better approach?