How to find a bezier curve between two points and two tangents without anchor points

3.2k Views Asked by At

I was wondering how do you find the best fit bezier curve between two points with known tangents as in the most minimum curve of which the two handle points are not known.

Most guides explain how to calculate the curve of something like this:

enter image description here

But in my scenario i don't know P1 or P2 i only know P0 and P3 and their tangents that govern the direction of travel like so:

enter image description here

Is it possible to calculate a minimum bezier curve with such information, how would you find the curve in this situation ?

3

There are 3 best solutions below

6
On BEST ANSWER

The same question (Find the cubic bezier control points from end points and tangents) had been asked some time ago but with no validated answer.

It is well known that if we denote by $V_0$ (resp. $V_1$) the initial (resp. final) vector, we have:

$$V_0=3\vec{P_0P_1}=3(P_1-P_0) \ \iff \ P_1=P_0+\frac13 V_0$$

and:

$$V_1=3\vec{P_2P_3}=3(P_3-P_2) \ \iff \ P_2=P_3-\frac13 V_1$$

(Proof below).

If the norms of the vectors are unimportant, you can multiply them resp. by arbitrary constants $k_0, k_1$ giving, instead of (1),(2), the more general solutions:

$$P_1=P_0+k_0V_0$$

and

$$P_2=P_3-k_1V_1$$

Briefly said: take for $P_1$ any point on the line defined by $P_0$ and direction given by $V_0$. The same for $P_2$.

Proof for (1) and (2): the current point on the cubic Bezier is:

$$P_t=s^3P_0+3s^2tP_1+3st^2P_2+t^3P_3 \ \text{with} \ s:=1-t$$

The speed vector is: $$V_t=dP_t/dt=-3(1-t)^2P_0+3(1-4t+3t^2)P_1+3(2t-3t^2)P_2+3t^2P_3$$

If the given vectors $V_0$ and $V_1$ are interpreted as speed vectors, taking $t=0$ (resp. $t=1$) gives

$$V_0=-3P_0+3P_1=3\vec{P_0P_1} \ \ \text{and} \ \ V_1=-3P_2+3P_3=3\vec{P_2P_3}$$

0
On

There are an infinite number of Bézier curves that satisfy your constraints. In the answer from @Jean Marie, you can use any values you like for $k_0$ and $k_1$ (though you probably will be happier if you use positive values).

To choose a “good” curve, you have to tell us what additional properties you want.

If you don't care very much about the shape of the curve, the simplest idea is to choose $P_1$ so that the distance from $P_0$ to $P_1$ is 1/3 of the distance from $P_0$ to $P_3$, and similarly for $P_2$. This will at least prevent cusps or loops or extraneous inflexion in the curve, and will reproduce straight lines nicely.

Another way to produce a “nice” Bézier curve is to pretend that it’s a conic and then minimize its eccentricity. This is much more complex that the simple “1/3” rule described above, but it will sometimes produce better curves (in some sense). The details are explained here:

John C. Femiani, Chia-Yuan Chuang, Anshuman Razdan,
Least eccentric ellipses for geometric Hermite interpolation,
Computer Aided Geometric Design,
Volume 29, Issue 2, 2012, Pages 141-149.

5
On

I believe what you want to do can be achieved by the "Optimized Geometric Hermite Curve" mentioned in this paper.

Basically, you will use a cubic Hermite curve to interpolate the given position and first derivative vector at the end points. A cubic Hermite curve is defined by two end points and two tangent vectors at the end points. In this paper's case (which is the same as your case), the tangent vectors are only known for their directions and their magnitudes are determined by minimizing the "bending energy" of the curve, which will result in a pretty smooth curve.

The formula for the tangent vector's magnitudes $a^*_0$ and $a^*_1$ is listed as equation (4) in the paper.