1
$\begingroup$

When an elliptic (or circular) arc is approximated with Bézier curves, for the same $t$ value (parametric time) I get almost the same point on the arc and on the curve chain. Almost, but not quite. The error decreases with increasing number of curve segments that make up the arc (i.e. the more segments I add, the better the curves approximate the arc and thus the closer the point on curve is to the point on the arc for the same $t$ value). But instead of increasing the number of segments for larger arcs, I would prefer to figure out what is the $t$ value on the Bézier curve chain (which curve and which $t$ value on that curve) that gets me the point that is closest to the point at a given $t$ value on the arc.

$\endgroup$
  • $\begingroup$ The man's name was Bézier. Not Bezier, and not bezier. $\endgroup$ – bubba Dec 26 '17 at 6:40
  • $\begingroup$ A brief answer below, but don't want to put more time into it until I properly understand what you mean by "synchronize". $\endgroup$ – bubba Dec 26 '17 at 7:07
  • $\begingroup$ @bubba thanks for answering! by synchronize I mean "what is the formula to get the t value on the bezier curve corresponding to a certain t value on the arc?" I'll update the answer with a better phrasing. $\endgroup$ – capr Dec 27 '17 at 16:39
  • $\begingroup$ It's still not 100% clear what "corresponding" means, but I can guess. See revised answer below. $\endgroup$ – bubba Dec 28 '17 at 5:58
2
$\begingroup$

Let's take a quarter of a unit circle as an example.

The original arc equation can be written $$ x(u) = \cos\tfrac12\pi u \quad ; \quad y(u) = \sin\tfrac12\pi u $$ A good Bézier cubic approximation of this circular arc has the form $$ \mathbf{P}(t) = (1-t)^3(1,0) + 3t(1-t)^2(1,p) + 3t^2(1-t)(p,1) + t^3(0,1) $$ Usually, $p$ is chosen to be either $\tfrac43(\sqrt2 - 1) \approx 0.5522847498308$ or a bit smaller. Roughly speaking, this minimizes the maximum distance between the cubic and the circular arc. For more details, see this answer, or this one, or this web site.

Now, suppose we are given a parameter value $u$. This gives us a point $\mathbf{C}(u) = \bigl(\cos\tfrac12\pi u, \sin\tfrac12\pi u\bigr)$ on the circular arc. Apparently, you want to find the value of $t$ such that the point $\mathbf{P}(t)$ on the cubic curve is "close" to $\mathbf{C}(u)$. It would be nice if $\mathbf{P}(u)$ was the closet point, but unfortunately that's not true.

Let's suppose $\mathbf{C}(u) = (h,k)$. At the closest point, the tangent vector $\mathbf{P}'(t)$ must be perpendicular to the vector $(h,k)$. So, we just need to form the equation $(h,k) \cdot \mathbf{P}'(t)=0$, and solve it for $t$. The equation is actually a quadratic in $t$, so it's easy to solve. The solution you want is the one that lies in the interval $[0,1]$.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.