0

I would like to construct a cubic Bezier curve. For this, I assume a known starting point $K_0$ as well as a known end point $K_2$. I would like my resulting curve to pass through another known point $K_1$. I also know the angles of the curve at the starting and end points $K_0$ and $K_2$. So the resulting curve has the form $$S(u)=B_0(u)K_0+B_1(u)P_1+B_2(u)P_2+B_3(u)K_2$$ where $u$ is the curve parameter that takes values from $0$ to $1$.

All the points are known except for the two control points $P_1$ and $P_2$. I understand that I have to make a set of equations using the known information in order to find the two unknown control points.

For this, I assume that the following applies:

  • The first derivative of the $S(t)$ function at $t=0$ must equal the tangent of the known angle of the curve at its beginning: $Sx'(0)=\tan(0)$, $Sy'(0)=\tan(0)$.

  • The first derivative of the $S(t)$ function at $t=1$ must equal the tangent of the known angle of the curve at its ending: $Sx'(1)=\tan(45^\circ)$, $Sy'(1)=\tan(45^\circ)$

  • The function $S(t)$ must be equal to $K_1$ point for some value $t': Sx(t')= K_1x, Sy(t')=K_1y$.

Assume that $t'$ can be found using a simple geometric relation between points $K_0$, $K_1$, $K_2$ such as: $$t' = \frac{\operatorname{dist}(K_0,K_1)}{\operatorname{dist}(k_0,k_1)+\operatorname{dist}(k_1,k_2)}. $$

Doing all of the above is not producing expected results. Any suggestions?

This is a rough sketch of the scematic in order to help you visualize my problem

  • I have tried to improve your formatting, but I am confused about a couple of things. What are $Sx$, $Sy$, $K_1x$, etc.? – Xander Henderson Nov 28 '19 at 19:04
  • Thank you for the formating. S(t) will be the Bezier Curve while Sx(t) and Sy(t) will give the curve's point coordinates. [K0x,K0y], [K1x,K1y], [K2x,K2y] are the known points and [P1x,P1y], [P2x,P2y] are the unknown control points – user729921 Nov 28 '19 at 19:10
  • This problem is underdetermined. Even if you arbitrarily fix one of the unknown control points, there will be multiple solutions for $t'$ and the position of the other unknown control point. – amd Nov 28 '19 at 19:46
  • But since K0, K1, K2 are given, t' will be just one unique number. I treat t' as the parameter that defines the relative location of K1 to the end points of the Bezier curve. I think that what I do not understand well is how the known tangents are properly used to find P1 and P2. – user729921 Nov 28 '19 at 19:50

1 Answers1

1

The first derivative of $S(u)$ at $u=0$ and $u=1$ should be represented as

$S'(0)=m_0(1,0)$
$S'(1)=m_1(\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}})$

where $m_0$ and $m_1$ are the magnitudes for $S'(0)$ and $S'(1)$.

We can also associate $S'(0)$ and $S'(1)$ to the control points as

$S'(0)=3(P_1-K_0)$
$S'(1)=3(K_1-P_2)$

Your cubic Bezier curve also needs to pass $K_1$ at $u=t'$. Therefore, you have

$S(t')_x=K_{1,x}$
$S(t')_y=K_{1,y}$

from which you can find the value for $m_0$ and $m_1$ and you will have a fully-defined cubic Bezier curve.

fang
  • 3,570
  • Wont the magnitudes be sqrt(S'(1)x^2 + S'(1)y^2) and sqrt(S'(0)x^2 + S'(0)y^2) ? – user729921 Nov 29 '19 at 10:22
  • Yes. But you don't know the exact value of S'(0)x and S'(0)y. You only know that S'(0)y/S'(0)x=0.0 and S'(1)y/S'(1)x=1.0. This is the reason we need to represent S'(0) and S'(1) as a vector with an unknown constant representing the magnitude. – fang Nov 29 '19 at 19:22