0
$\begingroup$

I have both the endpoints of the Bezier Curve also I know the length of the curve and x' coordinate of the control point. So how can I find the y' coordinate of the control point?

I went through control polygon length approach of this link but solving it results into quartic equation which makes it difficult to find roots since I am trying to implement this in my code.

image

$\endgroup$
1
  • $\begingroup$ From a programming perspective, this is not necessarily a problem as there are formulas for roots of a general quartic polynomial: en.wikipedia.org/wiki/… So with a few new variables and ifs, you can be on your way. Of course, this does not mean there are not simpler ways to proceed. $\endgroup$ May 14, 2020 at 6:08

2 Answers 2

1
$\begingroup$

Your reference How long is that Bézier? has a link to A Primer on Bézier Curves, where they find an explicit expression for the arc length of a quadratic Bézier. Turn this into a function of $y'$ and use numerical methods such as binary search to find one of the solutions.

As starting points for a binary search, picking $y'$ such that the control point is collinear with the endpoints should result in a too short curve (at least if $x'$ is between $x_1$ and $x_2$), and by a simple estimate (using the polygonal bound after one subdivision) says that $$ y'=2\ell-\frac32|y_2-y_1|+\max\{y_1,y_2\}=2\ell-\frac12|y_2-y_1|+\min\{y_1,y_2\}$$ is a feasible initial choice for $y'$ that makes the curve too long.


Of course if you already reduced the problem to finding a root of a quartic, you can also take that as a starting point for a numerical search for a root (e.g., by Newton's method).

$\endgroup$
0
$\begingroup$

Simplistic approach.

enter image description here

Let the arc length of the quadratic Bezier segment $\operatorname{Bez_2}(A,B,C)$ with control points $A,B,C$ be $L$.

The points of the Bezier segment are found as \begin{align} P(t)=(P_x(t),P_y(t)) ,\\ P_x(t)&= A_x\,(1-t)^2+2\,B_x(1-t)t+C_x\,t^2 \tag{1}\label{1} ,\\ P_y(t)&= A_y\,(1-t)^2+2\,B_y(1-t)t+C_y\,t^2 \tag{2}\label{2} . \end{align}

Given $A,C$ and $B_x$, we can find $t=t_x$ from \eqref{1}, and \eqref{2} will provide the relation between the $y$-coordinate of the point on the segment with given $x=B_x$, and corresponding value of the $y$-coordinate of the control point.

Consider an ellipse with the foci at $A,C$, which intersects the line $x=B_x$ at the points $E$ and $F$,

\begin{align} |AE|+|CE|&=|AF|+|CF|=L . \end{align}

These points define the range $B_{\max}B_{\min}$ on the line $x=B_x$, where the control point $B$ must be located in order to get the arc length $L$ of the Bezier segment.

So, we can choose any point \begin{align} B_t&=B_{\max}(1-t)+B_{\min}\,t ,\quad t\in[0,1] \end{align} in that range, find corresponding control point $B_{\mathrm{mid}}$ and check if the segment $\operatorname{Bez_2}(A,B_{\mathrm{mid}},C)$ has the length $L$ withing a suitable error range.

In general, there are two control points, $B_1$ and $B_2$, separated by the line through $A,C$, that produce two different quadratic Bezier segments with the same arc length $L$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .